From d8bc393f4fcd5e584221669496d501856b4063f0 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 5 Dec 2024 14:56:29 -0300 Subject: [PATCH] Use a copy of the sub-array to get the last parenthesis opener as well --- src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php index 765473676c..efad97e4b3 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -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