Skip to content

Commit 783d946

Browse files
committed
Generic/ScopeIndent: minor bug fix (undefined array index)
While looking at issue 3362 in an attempt to debug it, binarykitten and me came across a `An error occurred during processing; checking has been aborted. The error message was: Undefined array key "" in /src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php on line 646 (Internal.Exception)` error notice. While this will probably only occur in exceptional circumstances, it was caused by an operator precedence issue in the scope closer check condition. Adding the extra parentheses fixes the operator precedence snafu and prevents the above error notice. Note: this does not fix 3362, but still, is one less bug to worry about ;-)
1 parent 3d6ae7f commit 783d946

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,11 @@ public function process(File $phpcsFile, $stackPtr)
616616

617617
// Scope closers reset the required indent to the same level as the opening condition.
618618
if (($checkToken !== null
619-
&& isset($openScopes[$checkToken]) === true
619+
&& (isset($openScopes[$checkToken]) === true
620620
|| (isset($tokens[$checkToken]['scope_condition']) === true
621621
&& isset($tokens[$checkToken]['scope_closer']) === true
622622
&& $tokens[$checkToken]['scope_closer'] === $checkToken
623-
&& $tokens[$checkToken]['line'] !== $tokens[$tokens[$checkToken]['scope_opener']]['line']))
623+
&& $tokens[$checkToken]['line'] !== $tokens[$tokens[$checkToken]['scope_opener']]['line'])))
624624
|| ($checkToken === null
625625
&& isset($openScopes[$i]) === true)
626626
) {

0 commit comments

Comments
 (0)