Skip to content

Commit 3a30b78

Browse files
authored
Merge pull request #1669 from WordPress-Coding-Standards/feature/sniff-is-comparison-defensive-coding
Sniff::is_comparison(): minor defensive coding tweak
2 parents d3ac40a + 5cb689f commit 3a30b78

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

WordPress/Sniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ protected function is_comparison( $stackPtr ) {
19841984
);
19851985

19861986
// This might be an opening square bracket in the case of arrays ($var['a']).
1987-
while ( \T_OPEN_SQUARE_BRACKET === $this->tokens[ $next_token ]['code'] ) {
1987+
while ( false !== $next_token && \T_OPEN_SQUARE_BRACKET === $this->tokens[ $next_token ]['code'] ) {
19881988

19891989
$next_token = $this->phpcsFile->findNext(
19901990
Tokens::$emptyTokens,
@@ -1994,7 +1994,7 @@ protected function is_comparison( $stackPtr ) {
19941994
);
19951995
}
19961996

1997-
if ( isset( Tokens::$comparisonTokens[ $this->tokens[ $next_token ]['code'] ] ) ) {
1997+
if ( false !== $next_token && isset( Tokens::$comparisonTokens[ $this->tokens[ $next_token ]['code'] ] ) ) {
19981998
return true;
19991999
}
20002000

0 commit comments

Comments
 (0)