@@ -145,13 +145,17 @@ public function refactor(Node $node): ?Node
145145 return $ node ;
146146 }
147147
148- private function createAttributeGroup (string $ annotationValue ): AttributeGroup
148+ private function createAttributeGroup (string $ annotationValue ): ? AttributeGroup
149149 {
150150 if (str_starts_with ($ annotationValue , ':: ' )) {
151151 $ attributeClass = self ::COVERS_FUNCTION_ATTRIBUTE ;
152152 $ attributeValue = [trim ($ annotationValue , ':() ' )];
153153 } elseif (str_contains ($ annotationValue , ':: ' )) {
154154 $ attributeClass = self ::COVERS_METHOD_ATTRIBUTE ;
155+ if (! $ this ->reflectionProvider ->hasClass ($ attributeClass )) {
156+ return null ;
157+ }
158+
155159 $ attributeValue = [$ this ->getClass ($ annotationValue ) . '::class ' , $ this ->getMethod ($ annotationValue )];
156160 } else {
157161 $ attributeClass = self ::COVERTS_CLASS_ATTRIBUTE ;
@@ -161,6 +165,9 @@ private function createAttributeGroup(string $annotationValue): AttributeGroup
161165
162166 if ($ classReflection ->isTrait ()) {
163167 $ attributeClass = self ::COVERTS_TRAIT_ATTRIBUTE ;
168+ if (! $ this ->reflectionProvider ->hasClass ($ attributeClass )) {
169+ return null ;
170+ }
164171 }
165172 }
166173
@@ -206,6 +213,12 @@ private function handleCoversDefaultClass(PhpDocInfo $phpDocInfo): array
206213 continue ;
207214 }
208215
216+ $ attributeGroup = $ this ->createAttributeGroup ($ desiredTagValueNode ->value ->value );
217+ // phpunit 10 may not fully support attribute
218+ if (! $ attributeGroup instanceof AttributeGroup) {
219+ continue ;
220+ }
221+
209222 $ attributeGroups [] = $ this ->createAttributeGroup ($ desiredTagValueNode ->value ->value );
210223 $ this ->phpDocTagRemover ->removeTagValueFromNode ($ phpDocInfo , $ desiredTagValueNode );
211224 }
0 commit comments