Explicit octal notation for integers by Girgias · Pull Request #6360 · php/php-src

nikic

TysonAndre

nikic

@Girgias

@Girgias Girgias deleted the explicit-octal-notation branch

January 4, 2021 20:10

jrfnl added a commit to PHPCSStandards/PHPCSUtils that referenced this pull request

Feb 28, 2022
This add support for the explicit octal notation using a `0o`/`0O` prefix as supported in PHP as of PHP 8.1.

The only method which needed adjusting was the `Numbers::getCompleteNumber()` method, which now backfills the tokenization when needed.

For the `Numbers::isOctalInt()` method, a small tweak to the regex was all that was needed.

As for the `Numbers::getDecimalValue()` method: this already handled the conversion correctly due to the use of the PHP native `octdec()` function.

From the RFC:
> Surprisingly PHP already has support for this notation when using the `octdec()` and `base_convert()` functions.

Includes adding unit tests to safeguard support in all relevant methods in the class.

Refs:
* https://wiki.php.net/rfc/explicit_octal_notation
* php/php-src#6360
* squizlabs/PHP_CodeSniffer#3481
* squizlabs/PHP_CodeSniffer#3552

@jrfnl jrfnl mentioned this pull request

Feb 28, 2022

jrfnl added a commit to PHPCompatibility/PHPCompatibility that referenced this pull request

Dec 5, 2022

jrfnl added a commit to PHPCompatibility/PHPCompatibility that referenced this pull request

Dec 5, 2022

@jrfnl jrfnl mentioned this pull request

Dec 5, 2022