Skip to content

Commit

Permalink
Simplify parsing of type alias import
Browse files Browse the repository at this point in the history
  • Loading branch information
jiripudil authored and ondrejmirtes committed Jun 20, 2022
1 parent 4a07085 commit 25ddf93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 1 addition & 8 deletions src/Parser/PhpDocParser.php
Expand Up @@ -429,14 +429,7 @@ private function parseTypeAliasImportTagValue(TokenIterator $tokens): Ast\PhpDoc
$importedAlias = $tokens->currentTokenValue();
$tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);

if (!$tokens->tryConsumeTokenValue('from')) {
throw new ParserException(
$tokens->currentTokenValue(),
$tokens->currentTokenType(),
$tokens->currentTokenOffset(),
Lexer::TOKEN_IDENTIFIER
);
}
$tokens->consumeTokenValue(Lexer::TOKEN_IDENTIFIER, 'from');

$importedFrom = $tokens->currentTokenValue();
$tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);
Expand Down
6 changes: 4 additions & 2 deletions tests/PHPStan/Parser/PhpDocParserTest.php
Expand Up @@ -3679,7 +3679,8 @@ public function provideTypeAliasImportTagsData(): Iterator
'*/',
Lexer::TOKEN_CLOSE_PHPDOC,
35,
Lexer::TOKEN_IDENTIFIER
Lexer::TOKEN_IDENTIFIER,
'from'
)
)
),
Expand All @@ -3698,7 +3699,8 @@ public function provideTypeAliasImportTagsData(): Iterator
'as',
Lexer::TOKEN_IDENTIFIER,
35,
Lexer::TOKEN_IDENTIFIER
Lexer::TOKEN_IDENTIFIER,
'from'
)
)
),
Expand Down

0 comments on commit 25ddf93

Please sign in to comment.