mirror of
https://github.com/danog/phpdoc-parser.git
synced 2025-01-22 13:51:20 +01:00
support trailing commas
This commit is contained in:
parent
f9e4a3b8cb
commit
e81bfd8679
@ -226,6 +226,11 @@ class TypeParser
|
||||
|
||||
while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) {
|
||||
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
if($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
|
||||
// trailing comma case
|
||||
return new Ast\Type\ArrayShapeNode($items);
|
||||
}
|
||||
|
||||
$items[] = $this->parseArrayShapeItem($tokens);
|
||||
}
|
||||
|
||||
|
@ -477,6 +477,36 @@ class TypeParserTest extends \PHPUnit\Framework\TestCase
|
||||
),
|
||||
]),
|
||||
],
|
||||
[
|
||||
'array{
|
||||
a: int,
|
||||
}',
|
||||
new ArrayShapeNode([
|
||||
new ArrayShapeItemNode(
|
||||
new IdentifierTypeNode('a'),
|
||||
false,
|
||||
new IdentifierTypeNode('int')
|
||||
),
|
||||
]),
|
||||
],
|
||||
[
|
||||
'array{
|
||||
a: int,
|
||||
b: string,
|
||||
}',
|
||||
new ArrayShapeNode([
|
||||
new ArrayShapeItemNode(
|
||||
new IdentifierTypeNode('a'),
|
||||
false,
|
||||
new IdentifierTypeNode('int')
|
||||
),
|
||||
new ArrayShapeItemNode(
|
||||
new IdentifierTypeNode('b'),
|
||||
false,
|
||||
new IdentifierTypeNode('string')
|
||||
),
|
||||
]),
|
||||
],
|
||||
[
|
||||
'array{
|
||||
a: int,
|
||||
|
Loading…
x
Reference in New Issue
Block a user