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

Security/PluginMenuSlug: implement PHPCSUtils and support modern PHP #2168

Merged
merged 3 commits into from
Dec 21, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Dec 20, 2022

Security/PluginMenuSlug: add support for PHP 8.0+ named parameters

  1. Adjusted the way the correct parameters are retrieved to use the new PHPCSUtils 1.0.0-alpha4 PassedParameters::getParameterFromStack() method.
  2. Verified the parameter names used are in line with the name as per the WP 6.1 release.
    WP has been renaming parameters and is probably not done yet, but it doesn't look like those changes (so far) made it into changelog entries....
    For the purposes of this exercise, I've taken the current parameter name as the "truth" as support for named parameters hasn't officially been announced yet, so any renames after this moment are the only ones relevant.

Includes additional unit tests.

Security/PluginMenuSlug: minor test tweak

Adjust one test to use lowercase __file__ to safeguard that the sniff correctly recognizes that these magic constants are case insensitive.

Security/PluginMenuSlug: improve error position precision

Throw the error on the token containing the __FILE__ magic constant instead of on the function call token.

1. Adjusted the way the correct parameters are retrieved to use the new PHPCSUtils 1.0.0-alpha4 `PassedParameters::getParameterFromStack()` method.
2. Verified the parameter names used are in line with the name as per the WP 6.1 release.
    WP has been renaming parameters and is probably not done yet, but it doesn't look like those changes (so far) made it into changelog entries....
    For the purposes of this exercise, I've taken the _current_ parameter name as the "truth" as support for named parameters hasn't officially been announced yet, so any renames _after_ this moment are the only ones relevant.

Includes additional unit tests.
Adjust one test to use lowercase `__file__` to safeguard that the sniff correctly recognizes that these magic constants are case insensitive.
Throw the error on the token containing the `__FILE__` magic constant instead of on the function call token.
Copy link
Member

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dingo-d dingo-d merged commit e2337c6 into develop Dec 21, 2022
@dingo-d dingo-d deleted the feature/pluginmenuslug-phpcsutils-and-modern-php branch December 21, 2022 09:39
@jrfnl jrfnl mentioned this pull request Jan 7, 2023
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants