commas on next line

This commit is contained in:
Max Loeb 2019-10-22 08:10:41 -07:00 committed by Ondřej Mirtes
parent e81bfd8679
commit 8a1b0c7090
2 changed files with 26 additions and 0 deletions

View File

@ -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);

View File

@ -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,