Skip to content

Commit

Permalink
Fixed bug #3502 : A match statement within an array produces Squiz.Ar…
Browse files Browse the repository at this point in the history
…rays.ArrayDeclaration.NoKeySpecified
  • Loading branch information
gsherwood committed Dec 20, 2021
1 parent f653fd2 commit 67c82d9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Squiz.Commenting.DocCommentAlignment
-- Squiz.Commenting.VariableComment
-- Thanks to Juliette Reinders Folmer for the patches
- Fixed bug #3502 : A match statement within an array produces Squiz.Arrays.ArrayDeclaration.NoKeySpecified
- Fixed bug #3503 : Squiz.Commenting.FunctionComment.ThrowsNoFullStop false positive when one line @throw
</notes>
<contents>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
|| $tokens[$nextToken]['code'] === T_OPEN_SHORT_ARRAY
|| $tokens[$nextToken]['code'] === T_CLOSURE
|| $tokens[$nextToken]['code'] === T_FN
|| $tokens[$nextToken]['code'] === T_MATCH
) {
// Let subsequent calls of this test handle nested arrays.
if ($tokens[$lastToken]['code'] !== T_DOUBLE_ARROW) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,13 @@ yield array(
static fn () : string => '',
);

$foo = [
'foo' => match ($anything) {
'foo' => 'bar',
default => null,
},
];

// Intentional syntax error.
$a = array(
'a' =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,13 @@ yield array(
static fn () : string => '',
);

$foo = [
'foo' => match ($anything) {
'foo' => 'bar',
default => null,
},
];

// Intentional syntax error.
$a = array(
'a' =>
Expand Down

0 comments on commit 67c82d9

Please sign in to comment.