Skip to content

Commit 08f4a7f

Browse files
committed
DiscouragedConstants: implement Sniff::is_token_namespaced()
1 parent 374691c commit 08f4a7f

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

WordPress/Sniffs/WP/DiscouragedConstantsSniff.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ public function process_arbitrary_tstring( $stackPtr ) {
124124
return;
125125
}
126126

127-
if ( false !== $prev
128-
&& \T_NS_SEPARATOR === $this->tokens[ $prev ]['code']
129-
&& \T_STRING === $this->tokens[ ( $prev - 1 ) ]['code']
130-
) {
127+
if ( $this->is_token_namespaced( $stackPtr ) === true ) {
131128
// Namespaced constant of the same name.
132129
return;
133130
}

WordPress/Tests/WP/DiscouragedConstantsUnitTest.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ define( 'My\STYLESHEETPATH', 'something' );
4242
if ( defined( 'STYLESHEETPATH' ) ) { // Ok.
4343
// Do something unrelated.
4444
}
45-
45+
echo namespace\STYLESHEETPATH; // "Magic" namespace operator.
4646

4747
/*
4848
* These are all bad.

0 commit comments

Comments
 (0)