@@ -38,9 +38,6 @@ class PhpDocParser
3838 /** @var ConstExprParser */
3939 private $ doctrineConstantExprParser ;
4040
41- /** @var bool */
42- private $ preserveTypeAliasesWithInvalidTypes ;
43-
4441 /** @var bool */
4542 private $ useLinesAttributes ;
4643
@@ -56,15 +53,13 @@ class PhpDocParser
5653 public function __construct (
5754 TypeParser $ typeParser ,
5855 ConstExprParser $ constantExprParser ,
59- bool $ preserveTypeAliasesWithInvalidTypes = false ,
6056 array $ usedAttributes = [],
6157 bool $ textBetweenTagsBelongsToDescription = false
6258 )
6359 {
6460 $ this ->typeParser = $ typeParser ;
6561 $ this ->constantExprParser = $ constantExprParser ;
6662 $ this ->doctrineConstantExprParser = $ constantExprParser ->toDoctrine ();
67- $ this ->preserveTypeAliasesWithInvalidTypes = $ preserveTypeAliasesWithInvalidTypes ;
6863 $ this ->useLinesAttributes = $ usedAttributes ['lines ' ] ?? false ;
6964 $ this ->useIndexAttributes = $ usedAttributes ['indexes ' ] ?? false ;
7065 $ this ->textBetweenTagsBelongsToDescription = $ textBetweenTagsBelongsToDescription ;
@@ -1085,37 +1080,31 @@ private function parseTypeAliasTagValue(TokenIterator $tokens): Ast\PhpDoc\TypeA
10851080 // support phan-type/psalm-type syntax
10861081 $ tokens ->tryConsumeTokenType (Lexer::TOKEN_EQUAL );
10871082
1088- if ($ this ->preserveTypeAliasesWithInvalidTypes ) {
1089- $ startLine = $ tokens ->currentTokenLine ();
1090- $ startIndex = $ tokens ->currentTokenIndex ();
1091- try {
1092- $ type = $ this ->typeParser ->parse ($ tokens );
1093- if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
1094- if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_EOL )) {
1095- throw new ParserException (
1096- $ tokens ->currentTokenValue (),
1097- $ tokens ->currentTokenType (),
1098- $ tokens ->currentTokenOffset (),
1099- Lexer::TOKEN_PHPDOC_EOL ,
1100- null ,
1101- $ tokens ->currentTokenLine ()
1102- );
1103- }
1083+ $ startLine = $ tokens ->currentTokenLine ();
1084+ $ startIndex = $ tokens ->currentTokenIndex ();
1085+ try {
1086+ $ type = $ this ->typeParser ->parse ($ tokens );
1087+ if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
1088+ if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_EOL )) {
1089+ throw new ParserException (
1090+ $ tokens ->currentTokenValue (),
1091+ $ tokens ->currentTokenType (),
1092+ $ tokens ->currentTokenOffset (),
1093+ Lexer::TOKEN_PHPDOC_EOL ,
1094+ null ,
1095+ $ tokens ->currentTokenLine ()
1096+ );
11041097 }
1105-
1106- return new Ast \PhpDoc \TypeAliasTagValueNode ($ alias , $ type );
1107- } catch (ParserException $ e ) {
1108- $ this ->parseOptionalDescription ($ tokens );
1109- return new Ast \PhpDoc \TypeAliasTagValueNode (
1110- $ alias ,
1111- $ this ->enrichWithAttributes ($ tokens , new Ast \Type \InvalidTypeNode ($ e ), $ startLine , $ startIndex )
1112- );
11131098 }
1114- }
11151099
1116- $ type = $ this ->typeParser ->parse ($ tokens );
1117-
1118- return new Ast \PhpDoc \TypeAliasTagValueNode ($ alias , $ type );
1100+ return new Ast \PhpDoc \TypeAliasTagValueNode ($ alias , $ type );
1101+ } catch (ParserException $ e ) {
1102+ $ this ->parseOptionalDescription ($ tokens );
1103+ return new Ast \PhpDoc \TypeAliasTagValueNode (
1104+ $ alias ,
1105+ $ this ->enrichWithAttributes ($ tokens , new Ast \Type \InvalidTypeNode ($ e ), $ startLine , $ startIndex )
1106+ );
1107+ }
11191108 }
11201109
11211110 private function parseTypeAliasImportTagValue (TokenIterator $ tokens ): Ast \PhpDoc \TypeAliasImportTagValueNode
0 commit comments