Skip to content

Commit

Permalink
DiscouragedConstants: implement Sniff::is_token_namespaced()
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Mar 28, 2019
1 parent 374691c commit 08f4a7f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions WordPress/Sniffs/WP/DiscouragedConstantsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Tests/WP/DiscouragedConstantsUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 08f4a7f

Please sign in to comment.