Skip to content

Commit

Permalink
Fix bug of repeating last line in AST for textBetweenTagsBelongsToDes…
Browse files Browse the repository at this point in the history
…cription=true
  • Loading branch information
ondrejmirtes committed Sep 7, 2024
1 parent 9d053a8 commit 0e689c5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Parser/PhpDocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private function parseText(TokenIterator $tokens): Ast\PhpDoc\PhpDocTextNode
$text .= $tmpText;

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

Expand Down Expand Up @@ -293,7 +293,7 @@ private function parseOptionalDescriptionAfterDoctrineTag(TokenIterator $tokens)
$text .= $tmpText;

// stop if we're not at EOL - meaning it's the end of PHPDoc
if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) {
if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC)) {
if (!$tokens->isPrecededByHorizontalWhitespace()) {
return trim($text . $this->parseText($tokens)->text, " \t");
}
Expand Down
35 changes: 35 additions & 0 deletions tests/PHPStan/Parser/PhpDocParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7547,6 +7547,41 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable
new PhpDocTagNode('@package', new GenericTagValueNode('foo')),
]),
];

yield [
'/** @deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
* Drupal 9 there will be no way to set the status and in Drupal 8 this
* ability has been removed because mb_*() functions are supplied using
* Symfony\'s polyfill. */',
new PhpDocNode([
new PhpDocTagNode(
'@deprecated',
new DeprecatedTagValueNode('in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
Drupal 9 there will be no way to set the status and in Drupal 8 this
ability has been removed because mb_*() functions are supplied using
Symfony\'s polyfill.')
),
]),
];

yield [
'/** @\ORM\Column() in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
* Drupal 9 there will be no way to set the status and in Drupal 8 this
* ability has been removed because mb_*() functions are supplied using
* Symfony\'s polyfill. */',
new PhpDocNode([
new PhpDocTagNode(
'@\ORM\Column',
new DoctrineTagValueNode(
new DoctrineAnnotation('@\ORM\Column', []),
'in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
Drupal 9 there will be no way to set the status and in Drupal 8 this
ability has been removed because mb_*() functions are supplied using
Symfony\'s polyfill.'
)
),
]),
];
}

/**
Expand Down

0 comments on commit 0e689c5

Please sign in to comment.