Skip to content

Commit 25ddf93

Browse files
jiripudilondrejmirtes
authored andcommitted
Simplify parsing of type alias import
1 parent 4a07085 commit 25ddf93

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/Parser/PhpDocParser.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,7 @@ private function parseTypeAliasImportTagValue(TokenIterator $tokens): Ast\PhpDoc
429429
$importedAlias = $tokens->currentTokenValue();
430430
$tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);
431431

432-
if (!$tokens->tryConsumeTokenValue('from')) {
433-
throw new ParserException(
434-
$tokens->currentTokenValue(),
435-
$tokens->currentTokenType(),
436-
$tokens->currentTokenOffset(),
437-
Lexer::TOKEN_IDENTIFIER
438-
);
439-
}
432+
$tokens->consumeTokenValue(Lexer::TOKEN_IDENTIFIER, 'from');
440433

441434
$importedFrom = $tokens->currentTokenValue();
442435
$tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);

tests/PHPStan/Parser/PhpDocParserTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -3679,7 +3679,8 @@ public function provideTypeAliasImportTagsData(): Iterator
36793679
'*/',
36803680
Lexer::TOKEN_CLOSE_PHPDOC,
36813681
35,
3682-
Lexer::TOKEN_IDENTIFIER
3682+
Lexer::TOKEN_IDENTIFIER,
3683+
'from'
36833684
)
36843685
)
36853686
),
@@ -3698,7 +3699,8 @@ public function provideTypeAliasImportTagsData(): Iterator
36983699
'as',
36993700
Lexer::TOKEN_IDENTIFIER,
37003701
35,
3701-
Lexer::TOKEN_IDENTIFIER
3702+
Lexer::TOKEN_IDENTIFIER,
3703+
'from'
37023704
)
37033705
)
37043706
),

0 commit comments

Comments
 (0)