From 8a1b0c70903d974a375b00e8a5fc22db03d3e2b4 Mon Sep 17 00:00:00 2001 From: Max Loeb Date: Tue, 22 Oct 2019 08:10:41 -0700 Subject: [PATCH] commas on next line --- src/Parser/TypeParser.php | 2 ++ tests/PHPStan/Parser/TypeParserTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) 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,