Skip to content

Commit 1b3cdfc

Browse files
committed
Sniff::is_assignment(): minor defensive coding tweak
There "bracket_closer" index may not be set during live coding/in case of parse errors. This prevents the method from throwing "_Undefined index: bracket_closer_" notices in that case.
1 parent d3ac40a commit 1b3cdfc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

WordPress/Sniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,9 @@ protected function is_assignment( $stackPtr ) {
13211321
}
13221322

13231323
// Check if this is an array assignment, e.g., `$var['key'] = 'val';` .
1324-
if ( \T_OPEN_SQUARE_BRACKET === $this->tokens[ $next_non_empty ]['code'] ) {
1324+
if ( \T_OPEN_SQUARE_BRACKET === $this->tokens[ $next_non_empty ]['code']
1325+
&& isset( $this->tokens[ $next_non_empty ]['bracket_closer'] )
1326+
) {
13251327
return $this->is_assignment( $this->tokens[ $next_non_empty ]['bracket_closer'] );
13261328
}
13271329

0 commit comments

Comments
 (0)