@@ -214,9 +214,11 @@ private function parseText(TokenIterator $tokens): Ast\PhpDoc\PhpDocTextNode
214
214
{
215
215
$ text = '' ;
216
216
217
+ $ endTokens = [Lexer::TOKEN_PHPDOC_EOL , Lexer::TOKEN_CLOSE_PHPDOC , Lexer::TOKEN_END ];
218
+
217
219
// if the next token is EOL, everything below is skipped and empty string is returned
218
220
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 );
220
222
221
223
// stop if we're not at EOL - meaning it's the end of PHPDoc
222
224
if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_EOL )) {
@@ -228,7 +230,7 @@ private function parseText(TokenIterator $tokens): Ast\PhpDoc\PhpDocTextNode
228
230
229
231
// if we're at EOL, check what's next
230
232
// 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 )) {
232
234
$ tokens ->rollback ();
233
235
break ;
234
236
}
@@ -247,9 +249,11 @@ private function parseOptionalDescriptionAfterDoctrineTag(TokenIterator $tokens)
247
249
{
248
250
$ text = '' ;
249
251
252
+ $ endTokens = [Lexer::TOKEN_PHPDOC_EOL , Lexer::TOKEN_CLOSE_PHPDOC , Lexer::TOKEN_END ];
253
+
250
254
// if the next token is EOL, everything below is skipped and empty string is returned
251
255
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 );
253
257
254
258
// stop if we're not at EOL - meaning it's the end of PHPDoc
255
259
if (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_PHPDOC_EOL )) {
@@ -291,7 +295,7 @@ private function parseOptionalDescriptionAfterDoctrineTag(TokenIterator $tokens)
291
295
292
296
// if we're at EOL, check what's next
293
297
// 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 )) {
295
299
$ tokens ->rollback ();
296
300
break ;
297
301
}
0 commit comments