Conversation
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
approved these changes
Apr 10, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ValidIntegers: move to the new
NumberscategoryPR #984 introduces a new
Numberscategory, so it seem appropriate to move the sniff to that category.New RemovedHexadecimalNumericStrings sniff, split off from ValidIntegers
Split the
ValidIntegerssniff in two:PHPCompatibility.Numbers.RemovedHexadecimalNumericStringswhich examines hexadecimal numeric strings.ValidIntegerssniff will now only focus on actual numbers (binary, octal).Note: the new sniff implements the PHPCSUtils
Numbers::isHexidecimalInt()method.ValidIntegers: reduce memory usage
As the token "type" no longer needs to be checked as the sniff no longer looks for anything but
T_LNUMBERtokens, a number of the private helper methods can be simplified and not passing the whole token stack to each function will reduce memory usage.ValidIntegers: use PHPCSUtils x 2
Numbers::isBinaryInt()method to determine if something is a binary integer.GetTokensAsString::normal()method to retrieve a code snippet for display in an error message.ValidIntegers: minor simplification
Just call the
Numbers::isBinaryInt()method directly.ValidIntegers: add unit tests for PHP 7.4 numeric literals with underscores
ValidIntegers: add support for PHP 7.4 numeric literals with underscores
... by using the
Numbers::getCompleteNumber()method to obtain the relevant information in a PHP + PHPCS cross-version compatible way.