Open
Conversation
f04e071 to
c78b598
Compare
50244fd to
4d6533c
Compare
3e1ea76 to
9aeec04
Compare
f7ad57e to
9e2a835
Compare
8113034 to
cd42bc6
Compare
b2a138a to
bb822fe
Compare
a4c6ab1 to
b4d3fb3
Compare
d8fd190 to
d20de47
Compare
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.
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).
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.
PHPCS 4.0 introduced a change where empty string values in array properties are converted to `null`. This is documented in the Version 4.0 Developer Upgrade Guide (https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Version-4.0-Developer-Upgrade-Guide#property-type-casting-has-been-made-more-consistent): > Array elements can now no longer contain an empty string value > as that value will be cast to `null`. This affected the sniffs PrefixAllGlobals and NoSilencedErrors. Both pass array values to `strtolower()`, which triggers a PHP 8.5 deprecation warning when `null` is passed. The fix is different for each sniff: - PrefixAllGlobals: Convert `null` back to empty string at the start of the validation loop. This preserves the "prefix too short" error that alerts users about invalid configuration. - NoSilencedErrors: Filter out `null` values before processing. Unlike PrefixAllGlobals, this sniff has no validation that provides user feedback for invalid entries, so filtering is cleaner. A test case was added to safeguard against the deprecation.
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.
Creating this PR to test the GH action changes.