diff --git a/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php b/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php index 1569cc15..25d79096 100644 --- a/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php +++ b/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php @@ -248,9 +248,10 @@ private function handleCovers(PhpDocInfo $phpDocInfo, bool $hasCoversDefault): a } $attributeGroups[$covers] = $attributeGroup; + $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $desiredTagValueNode); + } elseif ($hasCoversDefault && str_starts_with($covers, '::')) { + $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $desiredTagValueNode); } - - $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $desiredTagValueNode); } return $attributeGroups; @@ -304,6 +305,12 @@ private function removeMethodCoversAnnotations(ClassMethod $classMethod): bool continue; } + if (str_contains($desiredTagValueNode->value->value, '::') && ! $this->reflectionProvider->hasClass( + self::COVERS_METHOD_ATTRIBUTE + )) { + continue; + } + $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $desiredTagValueNode); $hasChanged = true; }