diff --git a/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php b/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php index cba8516e8..aa1cd15f5 100644 --- a/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php +++ b/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php @@ -108,7 +108,13 @@ public function refactor(Node $node): ?Node return null; } - if (! $this->reflectionProvider->hasClass(self::COVERS_FUNCTION_ATTRIBUTE)) { + // avoid partial apply that may cause error + if ( + ! $this->reflectionProvider->hasClass(self::COVERS_FUNCTION_ATTRIBUTE) + || ! $this->reflectionProvider->hasClass(self::COVERTS_CLASS_ATTRIBUTE) + || ! $this->reflectionProvider->hasClass(self::COVERTS_TRAIT_ATTRIBUTE) + || ! $this->reflectionProvider->hasClass(self::COVERS_METHOD_ATTRIBUTE) + ) { return null; } @@ -140,10 +146,6 @@ private function createAttributeGroup(string $annotationValue): ?AttributeGroup $attributeValue = [trim($annotationValue, ':()')]; } elseif (str_contains($annotationValue, '::')) { $attributeClass = self::COVERS_METHOD_ATTRIBUTE; - if (! $this->reflectionProvider->hasClass($attributeClass)) { - return null; - } - $attributeValue = [$this->getClass($annotationValue) . '::class', $this->getMethod($annotationValue)]; } else { $attributeClass = self::COVERTS_CLASS_ATTRIBUTE; @@ -302,12 +304,6 @@ 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; }