Skip to content

Commit

Permalink
Fix multiline deprecation messges
Browse files Browse the repository at this point in the history
  • Loading branch information
mglaman committed Apr 24, 2019
1 parent ea69061 commit a4b5f35
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/PhpDoc/PhpDocNodeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNullNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode;
use PHPStan\Reflection\PassedByReference;
Expand Down Expand Up @@ -218,15 +219,22 @@ private function resolveThrowsTags(PhpDocNode $phpDocNode, NameScope $nameScope)

private function resolveDeprecatedTag(PhpDocNode $phpDocNode, NameScope $nameScope): ?\PHPStan\PhpDoc\Tag\DeprecatedTag
{
foreach ($phpDocNode->getDeprecatedTagValues() as $key => $deprecatedTagValue) {
foreach ($phpDocNode->getDeprecatedTagValues() as $deprecatedTagValue) {
$totalChildren = count($phpDocNode->children);
// Find the original key in the child array so we can join together
// multiple line deprecation messages.
$deprecatedTagKey = key(array_filter($phpDocNode->children, static function (PhpDocChildNode $child) use ($deprecatedTagValue): bool {
return $child instanceof PhpDocTagNode && $child->value === $deprecatedTagValue;
}));

$deprecatedMessage = $deprecatedTagValue->description;

/** @var \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode[] $textNodes */
$textNodes = array_filter($phpDocNode->children, static function (PhpDocChildNode $child): bool {
return $child instanceof PhpDocTextNode;
});
$deprecatedMessage = $deprecatedTagValue->description;
if (count($textNodes) > 0) {
for ($i = $key; $i < $totalChildren; $i++) {
for ($i = $deprecatedTagKey; $i < $totalChildren; $i++) {
// Skip invalid children.
if (!isset($textNodes[$i])) {
continue;
Expand Down

0 comments on commit a4b5f35

Please sign in to comment.