Skip to content

Commit e27e92d

Browse files
zonuexeondrejmirtes
authored andcommitted
Fix list{} parsing
1 parent 57090cf commit e27e92d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Parser/TypeParser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ private function parseArrayShape(TokenIterator $tokens, Ast\Type\TypeNode $type,
515515
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
516516

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

521521
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_VARIADIC)) {

tests/PHPStan/Ast/ToString/TypeToStringTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ public static function provideArrayCases(): Generator
7575
new ArrayShapeItemNode(new ConstExprIntegerNode('1'), false, new IdentifierTypeNode('Baz')),
7676
]),
7777
],
78+
['list{}', new ArrayShapeNode([], true, 'list')],
79+
['list{...}', new ArrayShapeNode([], false, 'list')],
80+
[
81+
'list{string, int, ...}',
82+
new ArrayShapeNode([
83+
new ArrayShapeItemNode(null, false, new IdentifierTypeNode('string')),
84+
new ArrayShapeItemNode(null, false, new IdentifierTypeNode('int')),
85+
], false, 'list'),
86+
],
7887
];
7988
}
8089

0 commit comments

Comments
 (0)