Skip to content
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

Implement Numeric Literal Separator RFC #4165

Closed
wants to merge 1 commit into from

Conversation

theodorejb
Copy link
Contributor

@theodorejb theodorejb commented May 15, 2019

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

Zend/zend_language_scanner.l Outdated Show resolved Hide resolved
@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
@theodorejb theodorejb force-pushed the numeric-literal-separator branch from 1d1a67c to a1ec76e Compare May 26, 2019
Zend/zend_language_scanner.l Outdated Show resolved Hide resolved
Zend/zend_language_scanner.l Outdated Show resolved Hide resolved
@theodorejb theodorejb force-pushed the numeric-literal-separator branch from c5a72ff to 7aa4ff7 Compare May 27, 2019
Zend/zend_language_scanner.l Outdated Show resolved Hide resolved
@theodorejb theodorejb force-pushed the numeric-literal-separator branch 2 times, most recently from 8513393 to 4fab590 Compare May 31, 2019
@theodorejb theodorejb force-pushed the numeric-literal-separator branch from 4fab590 to 2e0d667 Compare Jun 13, 2019
@nikic
Copy link
Member

@nikic nikic commented Jun 14, 2019

Merged as f74109d into 7.4. Thanks!

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

@TomasVotruba TomasVotruba commented Jun 14, 2019

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

@nikic
Copy link
Member

@nikic nikic commented Jun 14, 2019

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

@TomasVotruba
Copy link

@TomasVotruba TomasVotruba commented Jun 14, 2019

@nikic I see. I'll check it

jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue 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 issue 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 issue 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 issue 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 issue 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 Jul 12, 2019
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue 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 issue 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 issue 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.

None yet

5 participants