Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a7c3d4f

Browse files
Simplify parsing of type alias import
1 parent 4a07085 commit a7c3d4f

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

‎src/Parser/PhpDocParser.php

Lines changed: 1 addition & 8 deletions
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

Lines changed: 4 additions & 2 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /