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

Review sniff handling of PHP 7.4 numbers using numeric literal separator #1841

Closed
jrfnl opened this issue Dec 4, 2019 · 2 comments
Closed

Comments

@jrfnl
Copy link
Member

jrfnl commented Dec 4, 2019

PHP 7.4 introduces numeric literal separators.

The WPCS native sniffs will need to be reviewed to make sure that they handle those correctly.

As of PHPCS 3.5.3 the tokenization of numbers using separators is backfilled for older PHP versions, so I'd strongly recommend we update the minimum PHPCS requirement of WPCS to PHPCS 3.5.3 in the near future as it will be hard to handle this without the backfilled tokenization.

  • Any sniff which examines T_LNUMBER and T_DNUMBER tokens is affected for the token walking part until PHPCS 3.5.3.
  • If the numeric value of a T_LNUMBER of T_DNUMBER needs to be examined - like in the CronInterval sniff, but probably in a few more sniffs -, the numeric value of the $token['content'] will need to be cast to (int)/(float) before doing any comparison or calculations with that number.
  • ... tbd ...

Refs:

Related to #764

@jrfnl jrfnl added Status: Requirement not met On hold until WPCS supports a particular version of a dependency (PHP, PHP_CodeSniffer, etc.). Focus: Modern PHP labels Dec 4, 2019
@jrfnl
Copy link
Member Author

jrfnl commented Mar 14, 2020

PHPCSUtils contains a few utilities for recognizing and dealing with numeric literals with underscores for those PHPCS versions which don't properly support them yet (= PHPCS < 3.5.4. Support was added in 3.5.3, but very buggy, I fixed that in 3.5.4)

@jrfnl jrfnl added this to the 3.0.0 milestone Apr 1, 2020
@jrfnl jrfnl removed the Status: Requirement not met On hold until WPCS supports a particular version of a dependency (PHP, PHP_CodeSniffer, etc.). label Jun 30, 2020
@jrfnl
Copy link
Member Author

jrfnl commented Aug 18, 2023

All sniffs have been reviewed and fixed to support modern PHP in as far as my imagination reached.

If any more situations would be discovered which need to be taken into account, a new issue should be opened with code samples etc.

Closing this now as fixed.

@jrfnl jrfnl closed this as completed Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant