mirror of
https://github.com/danog/phpdoc-parser.git
synced 2024-11-27 04:24:52 +01:00
TypeParser: ignore unclosed array notation
This commit is contained in:
parent
3dda8122e1
commit
afabfdfe9d
@ -35,7 +35,7 @@ class TypeParser
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES);
|
||||
|
||||
if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) {
|
||||
$type = $this->parseArray($tokens, $type);
|
||||
$type = $this->tryParseArray($tokens, $type);
|
||||
}
|
||||
|
||||
} elseif ($tokens->tryConsumeTokenType(Lexer::TOKEN_THIS_VARIABLE)) {
|
||||
@ -49,7 +49,7 @@ class TypeParser
|
||||
$type = $this->parseGeneric($tokens, $type);
|
||||
|
||||
} elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) {
|
||||
$type = $this->parseArray($tokens, $type);
|
||||
$type = $this->tryParseArray($tokens, $type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,13 +110,21 @@ class TypeParser
|
||||
}
|
||||
|
||||
|
||||
private function parseArray(TokenIterator $tokens, Ast\Type\TypeNode $type): Ast\Type\TypeNode
|
||||
private function tryParseArray(TokenIterator $tokens, Ast\Type\TypeNode $type): Ast\Type\TypeNode
|
||||
{
|
||||
while ($tokens->tryConsumeTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) {
|
||||
try {
|
||||
while ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) {
|
||||
$tokens->pushSavePoint();
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET);
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_CLOSE_SQUARE_BRACKET);
|
||||
$tokens->dropSavePoint();
|
||||
$type = new Ast\Type\ArrayTypeNode($type);
|
||||
}
|
||||
|
||||
} catch (ParserException $e) {
|
||||
$tokens->rollback();
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user