Skip to content

Commit 43e02ff

Browse files
committed
Constants/RestrictedConstants: fix nonsensical comparison
The only token this sniff needs to check for (at this time) is the `T_STRING` token, which is used for both constant names as well as function names. Any other token in the `Tokens::$functionNameTokens` token array will never match the subsequent contents comparison anyhow.
1 parent d5e5c27 commit 43e02ff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

WordPressVIPMinimum/Sniffs/Constants/RestrictedConstantsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function process_token( $stackPtr ) {
126126
return;
127127
}
128128

129-
if ( in_array( $this->tokens[ $previous ]['code'], Tokens::$functionNameTokens, true ) === true ) {
129+
if ( $this->tokens[ $previous ]['code'] === T_STRING ) {
130130
$data = [ $constantName ];
131131
if ( $this->tokens[ $previous ]['content'] === 'define' ) {
132132
$message = 'The definition of `%s` constant is prohibited. Please use a different name.';

0 commit comments

Comments
 (0)