PHPCSStandards / PHPCSUtils

A suite of utility functions for use with PHP_CodeSniffer
https://phpcsutils.com/
GNU Lesser General Public License v3.0
53 stars 7 forks source link

Numbers::is*(): remove fault tolerance for invalid numeric literals with underscores #620

Closed jrfnl closed 3 weeks ago

jrfnl commented 3 weeks ago

Numbers::is*(): remove fault tolerance for invalid numeric literals with underscores

Numeric literals with underscores have restrictions as to where the underscores are allowed.

The Numbers class did not take this into account to have some allowance for developer error, but as a bug has now been reported for the AbstractArrayDeclarationSniff::getActualArrayKey() method, which is due to this fault tolerance, the fault tolerance will be removed and the Numbers::is*() methods will now only allow underscore separators in places where PHP allows them.

Note: There is still one restriction which is not yet handled: 1__1, i.e. two underscores next to each. If at some point in the future a bug for this would be reported, this can be reconsidered.

Includes a plenitude of additional tests.

Fixes #619

Refs:

AbstractArrayDeclarationSniff::getActualArrayKey(): add extra tests