Skip to content

Commit

Permalink
Fix list{} parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
zonuexe authored and ondrejmirtes committed Feb 7, 2023
1 parent 57090cf commit e27e92d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Parser/TypeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ private function parseArrayShape(TokenIterator $tokens, Ast\Type\TypeNode $type,
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);

if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
return new Ast\Type\ArrayShapeNode($items);
return new Ast\Type\ArrayShapeNode($items, true, $kind);
}

if ($tokens->tryConsumeTokenType(Lexer::TOKEN_VARIADIC)) {
Expand Down
9 changes: 9 additions & 0 deletions tests/PHPStan/Ast/ToString/TypeToStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ public static function provideArrayCases(): Generator
new ArrayShapeItemNode(new ConstExprIntegerNode('1'), false, new IdentifierTypeNode('Baz')),
]),
],
['list{}', new ArrayShapeNode([], true, 'list')],
['list{...}', new ArrayShapeNode([], false, 'list')],
[
'list{string, int, ...}',
new ArrayShapeNode([
new ArrayShapeItemNode(null, false, new IdentifierTypeNode('string')),
new ArrayShapeItemNode(null, false, new IdentifierTypeNode('int')),
], false, 'list'),
],
];
}

Expand Down

0 comments on commit e27e92d

Please sign in to comment.