Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit deaac7c

Browse files
mglamanondrejmirtes
authored andcommitted
Combine multiple line deprecation messages
1 parent 847540a commit deaac7c

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

‎src/Parser/PhpDocParser.php‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,18 @@ private function parseThrowsTagValue(TokenIterator $tokens): Ast\PhpDoc\ThrowsTa
170170

171171
private function parseDeprecatedTagValue(TokenIterator $tokens): Ast\PhpDoc\DeprecatedTagValueNode
172172
{
173-
$description = $this->parseOptionalDescription($tokens);
173+
$description = '';
174+
while ($tokens->currentTokenType() !== Lexer::TOKEN_CLOSE_PHPDOC) {
175+
$description .= $tokens->joinUntil(Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END);
176+
$description = rtrim($description, "\t");
177+
if ($tokens->currentTokenType() !== Lexer::TOKEN_PHPDOC_EOL) {
178+
break;
179+
}
180+
// There's more text on a new line, ensure spacing.
181+
$description .= '';
182+
$tokens->next();
183+
}
184+
$description = rtrim($description, "\t");
174185
return new Ast\PhpDoc\DeprecatedTagValueNode($description);
175186
}
176187

‎tests/PHPStan/Parser/PhpDocParserTest.php‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,11 +1004,34 @@ public function provideDeprecatedTagsData(): \Iterator
10041004
new PhpDocNode([
10051005
new PhpDocTagNode(
10061006
'@deprecated',
1007-
new DeprecatedTagValueNode('in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In')
1007+
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.')
1008+
),
1009+
]),
1010+
];
1011+
yield [
1012+
'OK with multiple and long descriptions',
1013+
'/**
1014+
* Sample class
1015+
*
1016+
* @author Foo Baz <foo@baz.com>
1017+
*
1018+
* @deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
1019+
* Drupal 9 there will be no way to set the status and in Drupal 8 this
1020+
* ability has been removed because mb_*() functions are supplied using
1021+
* Symfony\'s polyfill.
1022+
*/',
1023+
new PhpDocNode([
1024+
new PhpDocTextNode('Sample class'),
1025+
new PhpDocTextNode(''),
1026+
new PhpDocTagNode(
1027+
'@author',
1028+
new GenericTagValueNode('Foo Baz <foo@baz.com>')
1029+
),
1030+
new PhpDocTextNode(''),
1031+
new PhpDocTagNode(
1032+
'@deprecated',
1033+
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.')
10081034
),
1009-
new PhpDocTextNode('Drupal 9 there will be no way to set the status and in Drupal 8 this'),
1010-
new PhpDocTextNode('ability has been removed because mb_*() functions are supplied using'),
1011-
new PhpDocTextNode('Symfony\'s polyfill.'),
10121035
]),
10131036
];
10141037
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /