Skip to content

Commit

Permalink
[DeadDocBlock] Skip RemoveUselessReturnTagRector on Generic Type (#5675)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Feb 25, 2021
1 parent 105e2e7 commit 9a30a74
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rules/dead-doc-block/src/DeadReturnTagValueNodeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpParser\Node\FunctionLike;
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareGenericTypeNode;
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;

final class DeadReturnTagValueNodeAnalyzer
Expand Down Expand Up @@ -33,6 +34,10 @@ public function isDead(ReturnTagValueNode $returnTagValueNode, FunctionLike $fun
return false;
}

if ($returnTagValueNode->type instanceof AttributeAwareGenericTypeNode) {
return false;
}

return $returnTagValueNode->description === '';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Rector\DeadDocBlock\Tests\Rector\ClassMethod\RemoveUselessReturnTagRector\Fixture;

use stdClass;

final class SkipGenericType
{
/**
* @return iterable<stdClass>
*/
public function run(): iterable
{
yield new stdClass;
}
}

0 comments on commit 9a30a74

Please sign in to comment.