diff --git a/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php b/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php index 00e1e8efa8..6539b49cc5 100644 --- a/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php +++ b/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php @@ -124,10 +124,7 @@ public function process_arbitrary_tstring( $stackPtr ) { return; } - if ( false !== $prev - && \T_NS_SEPARATOR === $this->tokens[ $prev ]['code'] - && \T_STRING === $this->tokens[ ( $prev - 1 ) ]['code'] - ) { + if ( $this->is_token_namespaced( $stackPtr ) === true ) { // Namespaced constant of the same name. return; } diff --git a/WordPress/Tests/WP/DiscouragedConstantsUnitTest.inc b/WordPress/Tests/WP/DiscouragedConstantsUnitTest.inc index d5e5f3a689..4949a9557a 100644 --- a/WordPress/Tests/WP/DiscouragedConstantsUnitTest.inc +++ b/WordPress/Tests/WP/DiscouragedConstantsUnitTest.inc @@ -42,7 +42,7 @@ define( 'My\STYLESHEETPATH', 'something' ); if ( defined( 'STYLESHEETPATH' ) ) { // Ok. // Do something unrelated. } - +echo namespace\STYLESHEETPATH; // "Magic" namespace operator. /* * These are all bad.