File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -403,16 +403,16 @@ private function parseTypeAliasImportTagValue(TokenIterator $tokens): Ast\PhpDoc
403403 );
404404 }
405405
406- $ importedFrom = $ this -> typeParser -> parse ( $ tokens );
407- assert ( $ importedFrom instanceof IdentifierTypeNode );
406+ $ importedFrom = $ tokens -> currentTokenValue ( );
407+ $ tokens -> consumeTokenType (Lexer:: TOKEN_IDENTIFIER );
408408
409409 $ importedAs = null ;
410410 if ($ tokens ->tryConsumeTokenValue ('as ' )) {
411411 $ importedAs = $ tokens ->currentTokenValue ();
412412 $ tokens ->consumeTokenType (Lexer::TOKEN_IDENTIFIER );
413413 }
414414
415- return new Ast \PhpDoc \TypeAliasImportTagValueNode ($ importedAlias , $ importedFrom , $ importedAs );
415+ return new Ast \PhpDoc \TypeAliasImportTagValueNode ($ importedAlias , new IdentifierTypeNode ( $ importedFrom) , $ importedAs );
416416 }
417417
418418 private function parseOptionalVariableName (TokenIterator $ tokens ): string
Original file line number Diff line number Diff line change @@ -2988,6 +2988,44 @@ public function provideTypeAliasImportTagsData(): \Iterator
29882988 ]),
29892989 ];
29902990
2991+ yield [
2992+ 'invalid non-identifier from ' ,
2993+ '/** @phpstan-import-type TypeAlias from 42 */ ' ,
2994+ new PhpDocNode ([
2995+ new PhpDocTagNode (
2996+ '@phpstan-import-type ' ,
2997+ new InvalidTagValueNode (
2998+ 'TypeAlias from 42 ' ,
2999+ new \PHPStan \PhpDocParser \Parser \ParserException (
3000+ '42 ' ,
3001+ Lexer::TOKEN_INTEGER ,
3002+ 40 ,
3003+ Lexer::TOKEN_IDENTIFIER
3004+ )
3005+ )
3006+ ),
3007+ ]),
3008+ ];
3009+
3010+ yield [
3011+ 'invalid non-simple-identifier from ' ,
3012+ '/** @phpstan-import-type TypeAlias from AnotherClass[] */ ' ,
3013+ new PhpDocNode ([
3014+ new PhpDocTagNode (
3015+ '@phpstan-import-type ' ,
3016+ new InvalidTagValueNode (
3017+ 'Unexpected token "[", expected \'*/ \' at offset 52 ' ,
3018+ new \PHPStan \PhpDocParser \Parser \ParserException (
3019+ '[ ' ,
3020+ Lexer::TOKEN_OPEN_SQUARE_BRACKET ,
3021+ 52 ,
3022+ Lexer::TOKEN_CLOSE_PHPDOC
3023+ )
3024+ )
3025+ ),
3026+ ]),
3027+ ];
3028+
29913029 yield [
29923030 'invalid missing from ' ,
29933031 '/** @phpstan-import-type TypeAlias */ ' ,
You can’t perform that action at this time.
0 commit comments