diff --git a/src/Parser/TypeParser.php b/src/Parser/TypeParser.php index 322fc8f..772816f 100644 --- a/src/Parser/TypeParser.php +++ b/src/Parser/TypeParser.php @@ -224,6 +224,7 @@ class TypeParser $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $items = [$this->parseArrayShapeItem($tokens)]; + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); if($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { @@ -232,6 +233,7 @@ class TypeParser } $items[] = $this->parseArrayShapeItem($tokens); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); } $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); diff --git a/tests/PHPStan/Parser/TypeParserTest.php b/tests/PHPStan/Parser/TypeParserTest.php index 7557c77..38bbf5f 100644 --- a/tests/PHPStan/Parser/TypeParserTest.php +++ b/tests/PHPStan/Parser/TypeParserTest.php @@ -507,6 +507,30 @@ class TypeParserTest extends \PHPUnit\Framework\TestCase ), ]), ], + [ + 'array{ + a: int + , b: string + , c: string + }', + new ArrayShapeNode([ + new ArrayShapeItemNode( + new IdentifierTypeNode('a'), + false, + new IdentifierTypeNode('int') + ), + new ArrayShapeItemNode( + new IdentifierTypeNode('b'), + false, + new IdentifierTypeNode('string') + ), + new ArrayShapeItemNode( + new IdentifierTypeNode('c'), + false, + new IdentifierTypeNode('string') + ), + ]), + ], [ 'array{ a: int,