ValidIntegers: move to Numbers category, split the sniff & support PHP 7.4 numeric literals by jrfnl · Pull Request #1004 · PHPCompatibility/PHPCompatibility

added 7 commits

April 4, 2020 06:23
This is a BC-break and should be annotated as such in the changelog.
Split the `ValidIntegers` sniff in two:
* A new `PHPCompatibility.Numbers.RemovedHexadecimalNumericStrings` which examines hexadecimal numeric strings.
* The existing `ValidIntegers` sniff will now only focus on actual numbers (binary, octal).

This is a BC-break and should be annotated as such in the changelog.

Note: the new sniff implements the PHPCSUtils `Numbers::isHexidecimalInt()` method.
As the token "type" no longer needs to be checked as the sniff no longer looks for anything but `T_LNUMBER` tokens, a number of the private helper methods can be simplified and not passing the whole token stack to each function will reduce memory usage.
* Use the `Numbers::isBinaryInt()` method to determine if something is a binary integer.
* Use the `GetTokensAsString::normal()` method to retrieve a code snippet for display in an error message.
Just call the `Numbers::isBinaryInt()` method directly.
... by using the `Numbers::getCompleteNumber()` method to obtain the relevant information in a PHP + PHPCS cross-version compatible way.

wimg

wimg approved these changes Apr 10, 2020

@wimg wimg deleted the feature/validintegers-phpcsutils branch

April 10, 2020 13:27