Combine multiple line deprecation messages

This commit is contained in:
Matt Glaman 2019-04-24 11:29:53 -05:00 committed by Ondřej Mirtes
parent 847540a54b
commit deaac7cd4b
2 changed files with 39 additions and 5 deletions

View File

@ -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);
}

View File

@ -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 <foo@baz.com>
*
* @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 <foo@baz.com>')
),
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.'),
]),
];
}