diff --git a/rules/dead-doc-block/src/DeadReturnTagValueNodeAnalyzer.php b/rules/dead-doc-block/src/DeadReturnTagValueNodeAnalyzer.php index 3887885fd4f5..5eee9fa80eeb 100644 --- a/rules/dead-doc-block/src/DeadReturnTagValueNodeAnalyzer.php +++ b/rules/dead-doc-block/src/DeadReturnTagValueNodeAnalyzer.php @@ -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 @@ -33,6 +34,10 @@ public function isDead(ReturnTagValueNode $returnTagValueNode, FunctionLike $fun return false; } + if ($returnTagValueNode->type instanceof AttributeAwareGenericTypeNode) { + return false; + } + return $returnTagValueNode->description === ''; } } diff --git a/rules/dead-doc-block/tests/Rector/ClassMethod/RemoveUselessReturnTagRector/Fixture/skip_generic_type.php.inc b/rules/dead-doc-block/tests/Rector/ClassMethod/RemoveUselessReturnTagRector/Fixture/skip_generic_type.php.inc new file mode 100644 index 000000000000..374ed7e65553 --- /dev/null +++ b/rules/dead-doc-block/tests/Rector/ClassMethod/RemoveUselessReturnTagRector/Fixture/skip_generic_type.php.inc @@ -0,0 +1,16 @@ + + */ + public function run(): iterable + { + yield new stdClass; + } +}