Skip to content

Commit

Permalink
Use a copy of the sub-array to get the last parenthesis opener as well
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoprimo committed Dec 5, 2024
1 parent ac43668 commit d8bc393
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public function process(File $phpcsFile, $stackPtr)
) {
$nestedParens = $tokens[$stackPtr]['nested_parenthesis'];
$lastParenthesisCloser = end($nestedParens);
$lastParenthesisOpener = key($tokens[$stackPtr]['nested_parenthesis']);
reset($tokens[$stackPtr]['nested_parenthesis']);
$lastParenthesisOpener = key($nestedParens);

if (isset($tokens[$lastParenthesisCloser]['parenthesis_owner']) === true
&& $tokens[$tokens[$lastParenthesisCloser]['parenthesis_owner']]['code'] === T_FOREACH
Expand Down

0 comments on commit d8bc393

Please sign in to comment.