VIP-Coding-Standards
VIP-Coding-Standards copied to clipboard
File inclusion - check for constant defined in the current file
trafficstars
What problem would the enhancement address for VIP?
The frequency with which "Warning: File inclusion using custom constant (PREFIX_PATH). Probably needs manual inspection (WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant)." shows up just below a line that matches the pattern is high.
Perhaps we can reduce this noise.
Describe the solution you'd like
See if we can improve the sniff, to see if the constant has been defined in the current file, and if so, skip the violation.
What code should be reported as a violation?
require PREFIX_PATH_UNDEFINED_IN_THIS_FILE . '/...';
What code should not be reported as a violation?
define( 'PREFIX_PATH_DEFINED_IN_THIS_FILE', '...' );
...other code...
require PREFIX_PATH_DEFINED_IN_THIS_FILE . '/...';
Noted in JIRA as [GH-3349]