Skip to content

Conversation

@rodrigoprimo
Copy link
Owner

Creating this PR to test the GH action changes.

@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 4 times, most recently from f04e071 to c78b598 Compare September 19, 2025 17:57
@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 2 times, most recently from 50244fd to 4d6533c Compare October 2, 2025 22:20
@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 6 times, most recently from 3e1ea76 to 9aeec04 Compare October 21, 2025 19:25
@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 4 times, most recently from f7ad57e to 9e2a835 Compare October 30, 2025 17:10
@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 5 times, most recently from 8113034 to cd42bc6 Compare November 7, 2025 21:35
@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 5 times, most recently from a4c6ab1 to b4d3fb3 Compare November 18, 2025 13:33
@rodrigoprimo rodrigoprimo force-pushed the phpcs-4 branch 3 times, most recently from d8fd190 to d20de47 Compare November 19, 2025 15:21
Check the way the tests are structured. There is for sure room to improve their organization.

This commit is just the basic structure. Everything needs to be reviewed.
- Clarified that the method supports static method calls as well.
- Replaced incomplete description with a list of the three properties that may be automatically set: `$methodPtr`, `$i`, and `$end`.
- Added clarification that `$methodPtr` and `$i` may be set even when the method returns false (e.g., for property access like `$wpdb->show_errors`). I'm not sure if this should be mentioned or not, but I opted to keep it for now as the original version did mention the `$i` property.
- Updated `$stackPtr` parameter description to mention it can be a "wpdb class name token" as well.
Check the way the tests are structured. There is for sure room to improve their organization.

This commit is just the basic structure. Everything needs to be reviewed.
…method calls to non-global classes called wpdb

Potentially add the tests related to this fix to this commit instead of introducing them in the commit that adds tests to this method.
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 calls to WPDB methods and also ensure that the method bails when handling `T_NAME_QUALIFIED` and `T_NAME_RELATIVE` tokens.

As there are no dedicated tests for this trait, a test will be added in a later commit that will update the `PreparedSQLPlaceholders` sniff for PHPCS 4.0. The test can't be added now because the sniff code needs to be updated as well to handle the new PHPCS 4.0 tokenization.

CHECK: I might end up adding dedicated tests for this method.
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 searching for the function name in the ContextHelper::$arrayCompareFunctions array.
I'm adding two different tests for fully qualified global function calls to cover all the global functions that are referenced directly in the `EnqueuedResourceParametersSniff::process_parameters` method.
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 and static method calls to this sniff. It also updates a few of the test expectations as the number of errors vary depending on whether running PHPCS 3.x or 4.x.
Tests for namespaced calls to a function called sprintf() are not added in this commit as they currently result in false negatives. A subsequent commit will fix this problem and include those tests.
…thod calls to `sprintf()`

The sniff was incorrectly analyzing namespaced function calls and method calls to `sprintf()` as if they were calls to the global `sprintf()` function causing false negatives.

This commit introduces the `is_global_function_call()` helper method that properly distinguishes global function calls from method calls and namespaced function calls.

This issue only affected `sprintf()`. The detection of `implode()` and array_fill() was already correctly filtering out namespaced and method calls by checking the preceding token (excluding empty tokens and T_NS_SEPARATOR). That being said, the helper method is applied to all sprintf(), implode(), and array_fill() checks for consistency and future-proofing.
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 calls to `\wpdb::prepare()`, `\sprintf()`, `\implode()` and `\array_fill()`.
Update the expectation for three test cases as they are different between PHPCS 3.x and PHPCS 4.x (see WordPress#2665).
Need to check if this way is the best way to fix the problem and improve it (document, make more readable).
Check the way the tests are structured. There is for sure room to improve their organization.
Check the way the tests are structured. There is for sure room to improve their organization.
Check the way the tests are structured. There is for sure room to improve their organization.
Check the way the tests are structured. There is for sure room to improve their organization.
Check the way the tests are structured. There is for sure room to improve their organization.
Check the way the tests are structured. There is for sure room to improve their organization.
The `is_escaping_function()` and `is_auto_escaped_function()` methods now use `ltrim()` to strip the leading backslash from fully qualified function names, ensuring they are correctly recognized when tokenized as `T_NAME_FULLY_QUALIFIED` in PHPCS 4.0.
… 4.0

Use `ltrim()` to strip the leading backslash from fully qualified function names, ensuring they are correctly recognized when tokenized as `T_NAME_FULLY_QUALIFIED` in PHPCS 4.0.
Use `ltrim()` to strip the leading backslash from fully qualified function names, ensuring they are correctly recognized when tokenized as `T_NAME_FULLY_QUALIFIED` in PHPCS 4.0.
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.

2 participants