Skip to content

Commit 0e689c5

Browse files
committed
Fix bug of repeating last line in AST for textBetweenTagsBelongsToDescription=true
1 parent 9d053a8 commit 0e689c5

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/Parser/PhpDocParser.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private function parseText(TokenIterator $tokens): Ast\PhpDoc\PhpDocTextNode
237237
$text .= $tmpText;
238238

239239
// stop if we're not at EOL - meaning it's the end of PHPDoc
240-
if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) {
240+
if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC)) {
241241
break;
242242
}
243243

@@ -293,7 +293,7 @@ private function parseOptionalDescriptionAfterDoctrineTag(TokenIterator $tokens)
293293
$text .= $tmpText;
294294

295295
// stop if we're not at EOL - meaning it's the end of PHPDoc
296-
if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) {
296+
if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC)) {
297297
if (!$tokens->isPrecededByHorizontalWhitespace()) {
298298
return trim($text . $this->parseText($tokens)->text, " \t");
299299
}

tests/PHPStan/Parser/PhpDocParserTest.php

+35
Original file line numberDiff line numberDiff line change
@@ -7547,6 +7547,41 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
75477547
new PhpDocTagNode('@package', new GenericTagValueNode('foo')),
75487548
]),
75497549
];
7550+
7551+
yield [
7552+
'/** @deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
7553+
* Drupal 9 there will be no way to set the status and in Drupal 8 this
7554+
* ability has been removed because mb_*() functions are supplied using
7555+
* Symfony\'s polyfill. */',
7556+
new PhpDocNode([
7557+
new PhpDocTagNode(
7558+
'@deprecated',
7559+
new DeprecatedTagValueNode('in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
7560+
Drupal 9 there will be no way to set the status and in Drupal 8 this
7561+
ability has been removed because mb_*() functions are supplied using
7562+
Symfony\'s polyfill.')
7563+
),
7564+
]),
7565+
];
7566+
7567+
yield [
7568+
'/** @\ORM\Column() in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
7569+
* Drupal 9 there will be no way to set the status and in Drupal 8 this
7570+
* ability has been removed because mb_*() functions are supplied using
7571+
* Symfony\'s polyfill. */',
7572+
new PhpDocNode([
7573+
new PhpDocTagNode(
7574+
'@\ORM\Column',
7575+
new DoctrineTagValueNode(
7576+
new DoctrineAnnotation('@\ORM\Column', []),
7577+
'in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
7578+
Drupal 9 there will be no way to set the status and in Drupal 8 this
7579+
ability has been removed because mb_*() functions are supplied using
7580+
Symfony\'s polyfill.'
7581+
)
7582+
),
7583+
]),
7584+
];
75507585
}
75517586

75527587
/**

0 commit comments

Comments
 (0)