Description
Is your feature request related to a problem?
This is related WordPress/plugin-check#523. In the Plugin Check plugin we need to find a way to flag the lack of prefixes for global functions.
Related:
Describe the solution you'd like
PrefixAllGlobalsSniff
has a hardcoded blocklist of disallowed prefixes:
In our use case, it would be helpful if we could customize the blocklist.
The counter argument was:
Making it customizable would allow for people to clear out the list, resulting in the opposite effect.
So what we could do instead is only allow extending the list, not removing items from it.
This way, in our project we can easily prevent functions starting with some words known not be unique, like e.g. admin
or plugin
.
So something like phpcs -ps . --standard=WordPress --sniffs=WordPress.NamingConventions.PrefixAllGobals --report=full,source,info --runtime-set prefix_blocklist admin,plugin
would flag the following functions:
wordpress_myfunc()
wp_myfunc()
admin_myfunc()
plugin_myfunc()
Additional context (optional)
- I intend to create a pull request to implement this feature.