Use PHPCSUtils 1.1.0 features #2563
Merged
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.
Just a collection of some small commits to take advantage of things which PHPCSUtils 1.1.0 brings.
PHP/YodaConditions: use new Collections::ternaryOperators() token array
Files/FileName: start using the PHPCSUtils FilePath utility
The
FilePath::getName()method will strip quotes from the file name, as well as normalize the slashes to forward (*nix) slashes.This allows for a minor simplication in the code and improves code readability.
Utils/I18nTextDomainFixer: start using the PHPCSUtils FilePath utility
The
FilePath::getName()method will strip quotes from the file name, as well as normalize the slashes to forward (*nix) slashes.This allows for a minor simplication in the code and improves code readability.
PHP 8.4 | Security/EscapeOutput: handle exit/die using named parameters
As of PHP 8.4, the internals of
T_EXITare changing in PHP itself andexit/diewill internally be treated as a function call.The net effect of this is that named parameters can now be used with
exit()/die().For the
WordPress.Security.EscapeOutputsniff this would lead to false positives as the parameter name would be seen as "not escaped".As of PHPCSUtils 1.1.0, the methods within the
PassedParametersclass will allow for passing aT_EXITtoken. This, in turn, allows for handlingexit/diewith named parameters correctly in the context of theEscapeOutputsniff.This commit implements using the
PassedParametersclass for parsing calls toexit/die, which fixes the issue.Includes tests.
Ref: https://wiki.php.net/rfc/exit-as-function
PHPCSUtils 1.1.0: only catch what should be caught
PHPCSUtils 1.1.0 introduces much more modular exceptions for a variety of errors the utility methods can throw.
This commit changes the exceptions being caught in various
catchstatements to more specific ones.This means that exceptions which shouldn't be able to occur are no longer caught (passing incorrect data type and such) and only the potentially expected (and acceptable) exceptions will now be caught.