Skip to content

Commit ed00c9a

Browse files
rodrigoprimojrfnl
andcommitted
Implement code review suggestion
Co-authored-by: Juliette <[email protected]>
1 parent 87ab640 commit ed00c9a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ public function process(File $phpcsFile, $stackPtr)
4545
// Ignore default value assignments in function definitions.
4646
$function = $phpcsFile->findPrevious([T_FUNCTION, T_CLOSURE, T_FN], ($stackPtr - 1), null, false, null, true);
4747
if ($function !== false) {
48+
if (isset($tokens[$function]['parenthesis_closer']) === false) {
49+
// Live coding/parse error. Bow out.
50+
return;
51+
}
52+
4853
$opener = $tokens[$function]['parenthesis_opener'];
4954
$closer = $tokens[$function]['parenthesis_closer'];
50-
if ($closer === null || ($opener < $stackPtr && $closer > $stackPtr)) {
55+
if ($opener < $stackPtr && $closer > $stackPtr) {
5156
return;
5257
}
5358
}

0 commit comments

Comments
 (0)