Loading coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php +1 −1 Original line number Diff line number Diff line Loading @@ -1694,7 +1694,7 @@ class VariableAnalysisSniff implements Sniff } // Are we within a short list [...] construct? $closePtr = $phpcsFile->findNext([T_WHITESPACE, T_VARIABLE, T_COMMA], ($stackPtr + 1), null, true); $closePtr = $phpcsFile->findNext([T_WHITESPACE, T_VARIABLE, T_COMMA, T_CONSTANT_ENCAPSED_STRING, T_DOUBLE_ARROW], ($stackPtr + 1), null, true); if ($tokens[$closePtr]['code'] === T_CLOSE_SHORT_ARRAY) { // OK, we're a short list [...] construct... are we being assigned to? if (($assignPtr = $this->isNextThingAnAssign($phpcsFile, $closePtr)) !== false) { Loading coder_sniffer/DrupalPractice/Test/CodeAnalysis/VariableAnalysisUnitTest.inc +10 −0 Original line number Diff line number Diff line Loading @@ -41,3 +41,13 @@ function test5() { return [$a, $b, $x, $y]; } function test6() { $foo = ['a' => 1, 'b' => 2]; ['a' => $a, 'b' => $b] = $foo; $bar = ['x' => 3, 'y' => 4]; list('x' => $x, 'y' => $y) = $bar; return [$a, $b, $x, $y]; } Loading
coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php +1 −1 Original line number Diff line number Diff line Loading @@ -1694,7 +1694,7 @@ class VariableAnalysisSniff implements Sniff } // Are we within a short list [...] construct? $closePtr = $phpcsFile->findNext([T_WHITESPACE, T_VARIABLE, T_COMMA], ($stackPtr + 1), null, true); $closePtr = $phpcsFile->findNext([T_WHITESPACE, T_VARIABLE, T_COMMA, T_CONSTANT_ENCAPSED_STRING, T_DOUBLE_ARROW], ($stackPtr + 1), null, true); if ($tokens[$closePtr]['code'] === T_CLOSE_SHORT_ARRAY) { // OK, we're a short list [...] construct... are we being assigned to? if (($assignPtr = $this->isNextThingAnAssign($phpcsFile, $closePtr)) !== false) { Loading
coder_sniffer/DrupalPractice/Test/CodeAnalysis/VariableAnalysisUnitTest.inc +10 −0 Original line number Diff line number Diff line Loading @@ -41,3 +41,13 @@ function test5() { return [$a, $b, $x, $y]; } function test6() { $foo = ['a' => 1, 'b' => 2]; ['a' => $a, 'b' => $b] = $foo; $bar = ['x' => 3, 'y' => 4]; list('x' => $x, 'y' => $y) = $bar; return [$a, $b, $x, $y]; }