@@ -214,9 +214,11 @@ private function parseText(TokenIterator $tokens): Ast\PhpDoc\PhpDocTextNode
214214 {
215215 $ text = '' ;
216216
217+ $ endTokens = [Lexer::TOKEN_PHPDOC_EOL , Lexer::TOKEN_CLOSE_PHPDOC , Lexer::TOKEN_END ];
218+
217219 // if the next token is EOL, everything below is skipped and empty string is returned
218220 while (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_EOL )) {
219- $ text .= $ tokens ->getSkippedHorizontalWhiteSpaceIfAny () . $ tokens ->joinUntil (Lexer:: TOKEN_PHPDOC_EOL , Lexer:: TOKEN_CLOSE_PHPDOC , Lexer:: TOKEN_END );
221+ $ text .= $ tokens ->getSkippedHorizontalWhiteSpaceIfAny () . $ tokens ->joinUntil (... $ endTokens );
220222
221223 // stop if we're not at EOL - meaning it's the end of PHPDoc
222224 if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_EOL )) {
@@ -228,7 +230,7 @@ private function parseText(TokenIterator $tokens): Ast\PhpDoc\PhpDocTextNode
228230
229231 // if we're at EOL, check what's next
230232 // if next is a PHPDoc tag, EOL, or end of PHPDoc, stop
231- if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_TAG , Lexer::TOKEN_DOCTRINE_TAG , Lexer:: TOKEN_PHPDOC_EOL , Lexer:: TOKEN_CLOSE_PHPDOC , Lexer:: TOKEN_END )) {
233+ if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_TAG , Lexer::TOKEN_DOCTRINE_TAG , ... $ endTokens )) {
232234 $ tokens ->rollback ();
233235 break ;
234236 }
@@ -247,9 +249,11 @@ private function parseOptionalDescriptionAfterDoctrineTag(TokenIterator $tokens)
247249 {
248250 $ text = '' ;
249251
252+ $ endTokens = [Lexer::TOKEN_PHPDOC_EOL , Lexer::TOKEN_CLOSE_PHPDOC , Lexer::TOKEN_END ];
253+
250254 // if the next token is EOL, everything below is skipped and empty string is returned
251255 while (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_EOL )) {
252- $ text .= $ tokens ->getSkippedHorizontalWhiteSpaceIfAny () . $ tokens ->joinUntil (Lexer::TOKEN_PHPDOC_TAG , Lexer::TOKEN_DOCTRINE_TAG , Lexer:: TOKEN_PHPDOC_EOL , Lexer:: TOKEN_CLOSE_PHPDOC , Lexer:: TOKEN_END );
256+ $ text .= $ tokens ->getSkippedHorizontalWhiteSpaceIfAny () . $ tokens ->joinUntil (Lexer::TOKEN_PHPDOC_TAG , Lexer::TOKEN_DOCTRINE_TAG , ... $ endTokens );
253257
254258 // stop if we're not at EOL - meaning it's the end of PHPDoc
255259 if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_EOL )) {
@@ -291,7 +295,7 @@ private function parseOptionalDescriptionAfterDoctrineTag(TokenIterator $tokens)
291295
292296 // if we're at EOL, check what's next
293297 // if next is a PHPDoc tag, EOL, or end of PHPDoc, stop
294- if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_TAG , Lexer::TOKEN_DOCTRINE_TAG , Lexer:: TOKEN_PHPDOC_EOL , Lexer:: TOKEN_CLOSE_PHPDOC , Lexer:: TOKEN_END )) {
298+ if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_TAG , Lexer::TOKEN_DOCTRINE_TAG , ... $ endTokens )) {
295299 $ tokens ->rollback ();
296300 break ;
297301 }
0 commit comments