UserExperience/AdminBarRemoval: various improvements #866
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.
UserExperience/AdminBarRemoval: add additional tests
UserExperience/AdminBarRemoval: bug fix - disregard comments in parameter values
The PHPCSUtils
PassedParameters::getParameters()return value includes a'clean'array index, which contains the contents of the parameter stripped of surrounding whitespace and comments.The
AdminBarRemovalsniff uses the parameter contents in a couple of places to compare against a specific text string, but would break if the parameter value would contain a comment.Fixed now. Includes tests.
UserExperience/AdminBarRemoval: add support for handling PHP 8.0+ function calls using named parameters
Includes tests.
UserExperience/AdminBarRemoval: bug fix - recognize add_action() as alias
... for
add_filter().Includes test.
UserExperience/AdminBarRemoval: add support for recognizing PHP 8.1+ first class callables
... when used as the
$callbackparameter foradd_filter()/add_action().Includes tests.
UserExperience/AdminBarRemoval: bug fix - function names are case-insensitive
... even when passed as callbacks.
Includes test.
UserExperience/AdminBarRemoval: remove some redundant logic
No need for a
switchhere.UserExperience/AdminBarRemoval: bug fix - CSS file might be handled as PHP file
A number of IDEs will use STDIN to run PHPCS and will pass the
stdin_pathto PHPCS to set the file name, which often results in the filename being quoted.In that case, the original logic in this sniff would break as the
$file_extensionwould end up being'css"', which doesn't match the expected'css'.The new PHPCSUtils 1.1.0
FilePath::getName()method will strip quotes from the file name, as well as normalize the slashes to forward (*nix) slashes.Applying that method fixes the bug.
UserExperience/AdminBarRemoval: minor simplification
Let PHP sort out splitting the extension off the file name.