mirror of
https://github.com/danog/phpdoc-parser.git
synced 2024-11-30 04:29:20 +01:00
parent
7093385390
commit
b205ccdf21
@ -164,14 +164,19 @@ class TypeParser
|
||||
|
||||
public function parseGeneric(TokenIterator $tokens, Ast\Type\IdentifierTypeNode $baseType): Ast\Type\GenericTypeNode
|
||||
{
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET);
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET);
|
||||
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
$genericTypes = [$this->parse($tokens)];
|
||||
|
||||
while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) {
|
||||
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
$genericTypes[] = $this->parse($tokens);
|
||||
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
}
|
||||
|
||||
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET);
|
||||
|
||||
return new Ast\Type\GenericTypeNode($baseType, $genericTypes);
|
||||
}
|
||||
|
||||
|
@ -899,6 +899,62 @@ class TypeParserTest extends \PHPUnit\Framework\TestCase
|
||||
new ConstTypeNode(new ConstFetchNode('QueueAttributeName', '*')),
|
||||
]),
|
||||
],
|
||||
[
|
||||
'array<' . PHP_EOL .
|
||||
' Foo' . PHP_EOL .
|
||||
'>',
|
||||
new GenericTypeNode(
|
||||
new IdentifierTypeNode('array'),
|
||||
[
|
||||
new IdentifierTypeNode('Foo')
|
||||
]
|
||||
)
|
||||
],
|
||||
[
|
||||
'array<' . PHP_EOL .
|
||||
' Foo,' . PHP_EOL .
|
||||
' Bar' . PHP_EOL .
|
||||
'>',
|
||||
new GenericTypeNode(
|
||||
new IdentifierTypeNode('array'),
|
||||
[
|
||||
new IdentifierTypeNode('Foo'),
|
||||
new IdentifierTypeNode('Bar'),
|
||||
]
|
||||
)
|
||||
],
|
||||
[
|
||||
'array<' . PHP_EOL .
|
||||
' Foo, Bar' . PHP_EOL .
|
||||
'>',
|
||||
new GenericTypeNode(
|
||||
new IdentifierTypeNode('array'),
|
||||
[
|
||||
new IdentifierTypeNode('Foo'),
|
||||
new IdentifierTypeNode('Bar'),
|
||||
]
|
||||
)
|
||||
],
|
||||
[
|
||||
'array<' . PHP_EOL .
|
||||
' Foo,' . PHP_EOL .
|
||||
' array<' . PHP_EOL .
|
||||
' Bar' . PHP_EOL .
|
||||
' >' . PHP_EOL .
|
||||
'>',
|
||||
new GenericTypeNode(
|
||||
new IdentifierTypeNode('array'),
|
||||
[
|
||||
new IdentifierTypeNode('Foo'),
|
||||
new GenericTypeNode(
|
||||
new IdentifierTypeNode('array'),
|
||||
[
|
||||
new IdentifierTypeNode('Bar')
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user