Skip to content

PHP 7.4: New NewNumericLiteralSeparator sniff#984

Merged
wimg merged 1 commit intodevelopfrom
php74/new-numeric-literals-sniff
Apr 10, 2020
Merged

PHP 7.4: New NewNumericLiteralSeparator sniff#984
wimg merged 1 commit intodevelopfrom
php74/new-numeric-literals-sniff

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Mar 27, 2020

New sniff to detect PHP 7.4 numeric literals with an underscore separator.

Added support for underscore separators in numeric literals. Some examples:

  6.674_083e-11; // float
  299_792_458;   // decimal
  0xCAFE_F00D;   // hexadecimal
   0b0101_1111;   // binary

Refs:

Related to #808

@jrfnl
Copy link
Member Author

jrfnl commented Mar 27, 2020

Note: I've added a new sniff category Numbers for this sniff and would like to suggest moving the PHPCompatibility.Miscellanous.ValidIntegers sniff to this category as well.

New sniff to detect PHP 7.4 numeric literals with an underscore separator.

> Added support for underscore separators in numeric literals. Some examples:
>
>       6.674_083e-11; // float
>       299_792_458;   // decimal
>       0xCAFE_F00D;   // hexadecimal
>        0b0101_1111;   // binary

Refs:
* https://www.php.net/manual/en/migration74.new-features.php#migration74.new-features.core.numeric-literal-separator
* https://github.com/php/php-src/blob/8f4e24eeef7bd1c39fabf5bea016abb287a4c606/UPGRADING#L189-L196
* https://wiki.php.net/rfc/numeric_literal_separator
* php/php-src#4165
* php/php-src@f74109d

Related to 808
@wimg wimg merged commit 27d1992 into develop Apr 10, 2020
@wimg wimg deleted the php74/new-numeric-literals-sniff branch April 10, 2020 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants