@@ -38,9 +38,6 @@ class PhpDocParser
38
38
/** @var ConstExprParser */
39
39
private $ doctrineConstantExprParser ;
40
40
41
- /** @var bool */
42
- private $ preserveTypeAliasesWithInvalidTypes ;
43
-
44
41
/** @var bool */
45
42
private $ useLinesAttributes ;
46
43
@@ -56,15 +53,13 @@ class PhpDocParser
56
53
public function __construct (
57
54
TypeParser $ typeParser ,
58
55
ConstExprParser $ constantExprParser ,
59
- bool $ preserveTypeAliasesWithInvalidTypes = false ,
60
56
array $ usedAttributes = [],
61
57
bool $ textBetweenTagsBelongsToDescription = false
62
58
)
63
59
{
64
60
$ this ->typeParser = $ typeParser ;
65
61
$ this ->constantExprParser = $ constantExprParser ;
66
62
$ this ->doctrineConstantExprParser = $ constantExprParser ->toDoctrine ();
67
- $ this ->preserveTypeAliasesWithInvalidTypes = $ preserveTypeAliasesWithInvalidTypes ;
68
63
$ this ->useLinesAttributes = $ usedAttributes ['lines ' ] ?? false ;
69
64
$ this ->useIndexAttributes = $ usedAttributes ['indexes ' ] ?? false ;
70
65
$ this ->textBetweenTagsBelongsToDescription = $ textBetweenTagsBelongsToDescription ;
@@ -1085,37 +1080,31 @@ private function parseTypeAliasTagValue(TokenIterator $tokens): Ast\PhpDoc\TypeA
1085
1080
// support phan-type/psalm-type syntax
1086
1081
$ tokens ->tryConsumeTokenType (Lexer::TOKEN_EQUAL );
1087
1082
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
+ );
1104
1097
}
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
- );
1113
1098
}
1114
- }
1115
1099
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
+ }
1119
1108
}
1120
1109
1121
1110
private function parseTypeAliasImportTagValue (TokenIterator $ tokens ): Ast \PhpDoc \TypeAliasImportTagValueNode
0 commit comments