Loading coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php +3 −1 Original line number Diff line number Diff line Loading @@ -1785,7 +1785,9 @@ class VariableAnalysisSniff implements Sniff } // Is there an 'as' token between us and the opening bracket? if ($phpcsFile->findPrevious(T_AS, ($stackPtr - 1), $openPtr) === false) { if (($asPtr = $phpcsFile->findPrevious(T_AS, ($stackPtr - 1), $openPtr)) === false || $this->findContainingBrackets($phpcsFile, $asPtr) !== $openPtr ) { return false; } Loading coder_sniffer/DrupalPractice/Test/CodeAnalysis/VariableAnalysisUnitTest.inc +10 −0 Original line number Diff line number Diff line Loading @@ -21,3 +21,13 @@ function test3() { } return $x; } function test4() { return new Foo(function () { $metatags = []; foreach ([1, 2] as $u) { $metatags[] = $u; } return $metatags; }); } Loading
coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php +3 −1 Original line number Diff line number Diff line Loading @@ -1785,7 +1785,9 @@ class VariableAnalysisSniff implements Sniff } // Is there an 'as' token between us and the opening bracket? if ($phpcsFile->findPrevious(T_AS, ($stackPtr - 1), $openPtr) === false) { if (($asPtr = $phpcsFile->findPrevious(T_AS, ($stackPtr - 1), $openPtr)) === false || $this->findContainingBrackets($phpcsFile, $asPtr) !== $openPtr ) { return false; } Loading
coder_sniffer/DrupalPractice/Test/CodeAnalysis/VariableAnalysisUnitTest.inc +10 −0 Original line number Diff line number Diff line Loading @@ -21,3 +21,13 @@ function test3() { } return $x; } function test4() { return new Foo(function () { $metatags = []; foreach ([1, 2] as $u) { $metatags[] = $u; } return $metatags; }); }