Skip to content

Implement Numeric Literal Separator RFC #4165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

theodorejb
Copy link
Contributor

https://wiki.php.net/rfc/numeric_literal_separator

Enables improved code readability by supporting an underscore between digits in numeric literals. For example:

usleep(350000); // without separator
 
usleep(350_000); // with separator

@petk petk added the RFC label May 16, 2019
@theodorejb theodorejb force-pushed the numeric-literal-separator branch 3 times, most recently from 81aae12 to 1d1a67c Compare May 20, 2019 16:44
@theodorejb theodorejb force-pushed the numeric-literal-separator branch from 1d1a67c to a1ec76e Compare May 26, 2019 15:39
@theodorejb theodorejb force-pushed the numeric-literal-separator branch from c5a72ff to 7aa4ff7 Compare May 27, 2019 15:41
@theodorejb theodorejb force-pushed the numeric-literal-separator branch 2 times, most recently from 8513393 to 4fab590 Compare May 31, 2019 21:53
@theodorejb theodorejb force-pushed the numeric-literal-separator branch from 4fab590 to 2e0d667 Compare June 13, 2019 20:32
@nikic
Copy link
Member

nikic commented Jun 14, 2019

Merged as f74109d into 7.4. Thanks!

@nikic nikic closed this Jun 14, 2019
@TomasVotruba
Copy link

@nikic Does this need to be reflected in php-parser? I don't see any grammar changes

@nikic
Copy link
Member

nikic commented Jun 14, 2019

@TomasVotruba It needs to be supported in the emulative lexer.

@TomasVotruba
Copy link

@nikic I see. I'll check it

jrfnl added a commit to jrfnl/PHPCompatibility that referenced this pull request Jun 29, 2019
✨ PHP 7.4: New NewNumericLiteralSeparator sniff

> 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://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
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this pull request Jun 29, 2019
✨ PHP 7.4: New NewNumericLiteralSeparator sniff

> 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://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
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this pull request Jun 30, 2019
✨ PHP 7.4: New NewNumericLiteralSeparator sniff

> 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://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
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this pull request Jul 1, 2019
✨ PHP 7.4: New NewNumericLiteralSeparator sniff

> 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://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
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this pull request Jul 1, 2019
✨ PHP 7.4: New NewNumericLiteralSeparator sniff

> 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://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
@theodorejb theodorejb deleted the numeric-literal-separator branch July 12, 2019 16:31
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this pull request Jul 22, 2019
✨ PHP 7.4: New NewNumericLiteralSeparator sniff

> 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://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
jrfnl added a commit to PHPCompatibility/PHPCompatibility that referenced this pull request 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:
* 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
jrfnl added a commit to PHPCompatibility/PHPCompatibility that referenced this pull request 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:
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants