-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Is your feature request related to a problem?
There are PHP constants (i.e., define('SOMETHING')) in WordPress that should not typically be accessed directly. Instead, there are various WordPress API functions that allow accessing the constant values, usually also filtered. It would be good if there was a custom PHP_CodeSniffer sniff that flagged direct access to these constants, and also highlighted the recommended way to retrieve the respective value.
Describe the desired solution
Let's add a custom sniff, Syde.WordPress.DiscourageConstantAccess, that flags direct access to WordPress constants that are exposed via one or more API functions.
A good initial list can be found in the phpstan-wordpress extension.
Describe the alternatives that you have considered
The phpstan-wordpress extension flags direct access to constants that are exposed via WordPress API functions. However, we are not using it (deliberately, due to its functionality specific to WordPress hook callback argument types that we do not want).
Additional context
No response
Code of Conduct
- I agree to follow this project's Code of Conduct