Skip to content

Conversation

@jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Jul 27, 2025

The RestrictedFunctions::is_targetted_token() method was basically a duplicate of the upstream/parent method with some additional code to handle one specific situation (method calls on a specific variable).

However, the parent method has been updated significantly since the code was copied and this sniff wasn't benefitting from that.

This commit rewrites the RestrictedFunctions::is_targetted_token() method to defer to the parent method in all cases, except for the one specific situation we want to account for.

Additionally, it stabilizes and improves the token walking done for that specific situation, as well as takes the PHP 8.0+ nullsafe object operator into account.

Includes a number of tests, some to cover the improvements inherited from the parent method, some to cover the improved code in the overloaded method.

Includes documenting how PHP 8.1+ first class callables are handled by the sniff.

Closes #518

The `RestrictedFunctions::is_targetted_token()` method was basically a duplicate of the upstream/parent method with some additional code to handle one specific situation (method calls on a specific variable).

However, the parent method has been updated significantly since the code was copied and this sniff wasn't benefitting from that.

This commit rewrites the `RestrictedFunctions::is_targetted_token()` method to defer to the parent method in all cases, except for the one specific situation we want to account for.

Additionally, it stabilizes and improves the token walking done for that specific situation, as well as takes the PHP 8.0+ nullsafe object operator into account.

Includes a number of tests, some to cover the improvements inherited from the parent method, some to cover the improved code in the overloaded method.

Includes documenting how PHP 8.1+ first class callables are handled by the sniff.
@jrfnl jrfnl added this to the 3.1.0 milestone Jul 27, 2025
@jrfnl jrfnl requested a review from a team as a code owner July 27, 2025 05:45
@jrfnl jrfnl added Type: Bug Type: Enhancement Type: Maintenance PHPCSUtils The addition and utilisation of PHPCSUtils package labels Jul 27, 2025
@GaryJones GaryJones merged commit e9d9698 into develop Jul 28, 2025
42 checks passed
@GaryJones GaryJones deleted the feature/functions-restrictedfunctions-sniff-review branch July 28, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PHPCSUtils The addition and utilisation of PHPCSUtils package Type: Bug Type: Enhancement Type: Maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review the WordPressVIPMinimum.Functions.RestrictedFunctions sniff

3 participants