NamingConventions/PrefixAllGlobals: allow non-prefixed declarations for pluggable functions and classes #2286
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.
While the
PrefixAllGlobals
sniff already allowed for WP native constants which can be user declared, it did not allow for explicitly pluggable functions and classes being declared in plugins/themes.I'm quite surprised actually that this was not reported as a bug so far.
Either way, fixed now.
In both cases, a case-insensitive name comparison is done as PHP natively treats function names and class names case-insensitively.
The lists added are based on some prelim sniffs created for issue #1803 and WP Core 6.3-beta2.
Notes:
wp-includes/compat.php
file (which contains the polyfills for PHP native functionality).// Deprecated
comment based on manual verification (and the declaration being in thewp-includes/pluggable-deprecated.php
file). While it would, of course, be better if those would not be "plugged", it is not for this sniff to have an opinion on that and declaring these without a prefix should be allowed.$pluggable_functions
list, I've intentionally commented two functions out as those are declared nested within another function and do not look intentionally pluggable. This may need further verification, but at least this way it is documented why these are not included in the list.Includes tests.