Skip to content

WIP: PHPCS 4.x changes#2

Closed
rodrigoprimo wants to merge 57 commits intodevelopfrom
phpcs-4
Closed

WIP: PHPCS 4.x changes#2
rodrigoprimo wants to merge 57 commits intodevelopfrom
phpcs-4

Conversation

@rodrigoprimo
Copy link
Owner

Creating this PR to test the GH action changes.

@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 11 times, most recently from 9f3968c to 1a6dc95 Compare August 8, 2025 11:56
@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 10 times, most recently from 12fcc3c to 93b53d0 Compare August 18, 2025 19:29
@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 5 times, most recently from c56ef1e to b5e1356 Compare August 21, 2025 19:08
@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 4 times, most recently from 159cbbc to 301638f Compare September 10, 2025 19:00
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization of fully qualified function/method calls when checking if the sniff can determine the key used to retrieve a value from the `$GLOBALS` array. The sniff was already handling this correct by chance due to a check that happens later in the code execution to bow out if `$var_name` is empty.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization of fully qualified function calls when checking if a nonce verification function is used in the code.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when skipping over function calls while checking the hook name.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when checking if a given fully qualified function is a target function. In those cases, the leading backslash is removed from the token content to allow for the function name comparisons to continue working as they worked in PHPCS 3.x.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when checking for calls to `define()` and hook functions to handle fully qualified calls correctly.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when checking if a given token is a target token.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when checking function calls after the `T_ASPERAND` token.
Check the way the tests are structured. There is for sure room to improve their organization.

Also check the way that I'm running the tests in the WordPress/Util/Tests in composer.json and the need to add a custom autoloader to bootstrap.php. There is probably a better way to achieve both.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when determining the name of the function being called.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when checking if a WP time constant was used.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when checking if a PHP native array key exists function was used.
…ive in constant alias

This method was incorrectly identifying constant alias as the use of a global constant which is incorrect. This change aligns this method with how the sibling method in PHPCompatibility behaves.
Check the way the tests are structured. There is for sure room to improve their organization.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when determining if a constant is global or not.
Check the way the tests are structured. There is for sure room to improve their organization.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when determining if a token is namespaced or not. Since the tokenization of namespaced names changed between PHPCS 3 and 4, it was necessary to use different logic depending on the PHPCS version.

TODO check if the approach to support both PHPCS 3 and 4 is good.
Add tests safeguarding that namespaced calls to functions named `define` are handled correctly.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization when checking the name of a given constants to see if it is one of the discouraged constants and when checking if `define()` was called.
…es are handled correctly

There were already a few tests with namespaced names, so this commit adds only what was missing in the existing tests.
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.

This commit adds handling for the new tokenization to this sniff.

Discuss if it is worth supporting `\true` and `\false` (and maybe even `\null`) in this sniff.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants