@@ -44,9 +44,6 @@ class PhpDocParser
4444 /** @var bool */
4545 private $ preserveTypeAliasesWithInvalidTypes ;
4646
47- /** @var bool */
48- private $ parseDoctrineAnnotations ;
49-
5047 /** @var bool */
5148 private $ useLinesAttributes ;
5249
@@ -65,7 +62,6 @@ public function __construct(
6562 bool $ requireWhitespaceBeforeDescription = false ,
6663 bool $ preserveTypeAliasesWithInvalidTypes = false ,
6764 array $ usedAttributes = [],
68- bool $ parseDoctrineAnnotations = false ,
6965 bool $ textBetweenTagsBelongsToDescription = false
7066 )
7167 {
@@ -74,7 +70,6 @@ public function __construct(
7470 $ this ->doctrineConstantExprParser = $ constantExprParser ->toDoctrine ();
7571 $ this ->requireWhitespaceBeforeDescription = $ requireWhitespaceBeforeDescription ;
7672 $ this ->preserveTypeAliasesWithInvalidTypes = $ preserveTypeAliasesWithInvalidTypes ;
77- $ this ->parseDoctrineAnnotations = $ parseDoctrineAnnotations ;
7873 $ this ->useLinesAttributes = $ usedAttributes ['lines ' ] ?? false ;
7974 $ this ->useIndexAttributes = $ usedAttributes ['indexes ' ] ?? false ;
8075 $ this ->textBetweenTagsBelongsToDescription = $ textBetweenTagsBelongsToDescription ;
@@ -88,44 +83,35 @@ public function parse(TokenIterator $tokens): Ast\PhpDoc\PhpDocNode
8883
8984 $ children = [];
9085
91- if ($ this ->parseDoctrineAnnotations ) {
92- if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
93- $ lastChild = $ this ->parseChild ($ tokens );
94- $ children [] = $ lastChild ;
95- while (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
96- if (
97- $ lastChild instanceof Ast \PhpDoc \PhpDocTagNode
98- && (
99- $ lastChild ->value instanceof Doctrine \DoctrineTagValueNode
100- || $ lastChild ->value instanceof Ast \PhpDoc \GenericTagValueNode
101- )
102- ) {
103- $ tokens ->tryConsumeTokenType (Lexer::TOKEN_PHPDOC_EOL );
104- if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
105- break ;
106- }
107- $ lastChild = $ this ->parseChild ($ tokens );
108- $ children [] = $ lastChild ;
109- continue ;
110- }
111-
112- if (!$ tokens ->tryConsumeTokenType (Lexer::TOKEN_PHPDOC_EOL )) {
113- break ;
114- }
86+ if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
87+ $ lastChild = $ this ->parseChild ($ tokens );
88+ $ children [] = $ lastChild ;
89+ while (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
90+ if (
91+ $ lastChild instanceof Ast \PhpDoc \PhpDocTagNode
92+ && (
93+ $ lastChild ->value instanceof Doctrine \DoctrineTagValueNode
94+ || $ lastChild ->value instanceof Ast \PhpDoc \GenericTagValueNode
95+ )
96+ ) {
97+ $ tokens ->tryConsumeTokenType (Lexer::TOKEN_PHPDOC_EOL );
11598 if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
11699 break ;
117100 }
118-
119101 $ lastChild = $ this ->parseChild ($ tokens );
120102 $ children [] = $ lastChild ;
103+ continue ;
121104 }
122- }
123- } else {
124- if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
125- $ children [] = $ this ->parseChild ($ tokens );
126- while ($ tokens ->tryConsumeTokenType (Lexer::TOKEN_PHPDOC_EOL ) && !$ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
127- $ children [] = $ this ->parseChild ($ tokens );
105+
106+ if (!$ tokens ->tryConsumeTokenType (Lexer::TOKEN_PHPDOC_EOL )) {
107+ break ;
128108 }
109+ if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_CLOSE_PHPDOC )) {
110+ break ;
111+ }
112+
113+ $ lastChild = $ this ->parseChild ($ tokens );
114+ $ children [] = $ lastChild ;
129115 }
130116 }
131117
@@ -539,17 +525,11 @@ function ($tokens) {
539525 break ;
540526
541527 default :
542- if ($ this ->parseDoctrineAnnotations ) {
543- if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_PARENTHESES )) {
544- $ tagValue = $ this ->parseDoctrineTagValue ($ tokens , $ tag );
545- } else {
546- $ tagValue = new Ast \PhpDoc \GenericTagValueNode ($ this ->parseOptionalDescriptionAfterDoctrineTag ($ tokens ));
547- }
548- break ;
528+ if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_PARENTHESES )) {
529+ $ tagValue = $ this ->parseDoctrineTagValue ($ tokens , $ tag );
530+ } else {
531+ $ tagValue = new Ast \PhpDoc \GenericTagValueNode ($ this ->parseOptionalDescriptionAfterDoctrineTag ($ tokens ));
549532 }
550-
551- $ tagValue = new Ast \PhpDoc \GenericTagValueNode ($ this ->parseOptionalDescription ($ tokens ));
552-
553533 break ;
554534 }
555535
0 commit comments