diff --git a/src/Parser/PhpDocParser.php b/src/Parser/PhpDocParser.php index a0efa34..7d991c2 100644 --- a/src/Parser/PhpDocParser.php +++ b/src/Parser/PhpDocParser.php @@ -170,7 +170,18 @@ class PhpDocParser private function parseDeprecatedTagValue(TokenIterator $tokens): Ast\PhpDoc\DeprecatedTagValueNode { - $description = $this->parseOptionalDescription($tokens); + $description = ''; + while ($tokens->currentTokenType() !== Lexer::TOKEN_CLOSE_PHPDOC) { + $description .= $tokens->joinUntil(Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END); + $description = rtrim($description, " \t"); + if ($tokens->currentTokenType() !== Lexer::TOKEN_PHPDOC_EOL) { + break; + } + // There's more text on a new line, ensure spacing. + $description .= ' '; + $tokens->next(); + } + $description = rtrim($description, " \t"); return new Ast\PhpDoc\DeprecatedTagValueNode($description); } diff --git a/tests/PHPStan/Parser/PhpDocParserTest.php b/tests/PHPStan/Parser/PhpDocParserTest.php index dd9f3af..af688fc 100644 --- a/tests/PHPStan/Parser/PhpDocParserTest.php +++ b/tests/PHPStan/Parser/PhpDocParserTest.php @@ -1004,11 +1004,34 @@ class PhpDocParserTest extends \PHPUnit\Framework\TestCase new PhpDocNode([ new PhpDocTagNode( '@deprecated', - new DeprecatedTagValueNode('in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In') + 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 [ + 'OK with multiple and long descriptions', + '/** + * Sample class + * + * @author Foo Baz + * + * @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 PhpDocTextNode('Sample class'), + new PhpDocTextNode(''), + new PhpDocTagNode( + '@author', + new GenericTagValueNode('Foo Baz ') + ), + new PhpDocTextNode(''), + 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.') ), - new PhpDocTextNode('Drupal 9 there will be no way to set the status and in Drupal 8 this'), - new PhpDocTextNode('ability has been removed because mb_*() functions are supplied using'), - new PhpDocTextNode('Symfony\'s polyfill.'), ]), ]; }