Skip to content

Commit b4f48c4

Browse files
committed
fix phpstan
1 parent af44a0c commit b4f48c4

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private function handleCoversDefaultClass(PhpDocInfo $phpDocInfo): array
219219
continue;
220220
}
221221

222-
$attributeGroups[] = $this->createAttributeGroup($desiredTagValueNode->value->value);
222+
$attributeGroups[] = $attributeGroup;
223223
$this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $desiredTagValueNode);
224224
}
225225

@@ -239,10 +239,15 @@ private function handleCovers(PhpDocInfo $phpDocInfo, bool $hasCoversDefault): a
239239
}
240240

241241
$covers = $desiredTagValueNode->value->value;
242-
if (str_starts_with($covers, '\\')) {
243-
$attributeGroups[$covers] = $this->createAttributeGroup($covers);
244-
} elseif (! $hasCoversDefault && str_starts_with($covers, '::')) {
245-
$attributeGroups[$covers] = $this->createAttributeGroup($covers);
242+
if (str_starts_with($covers, '\\') || (! $hasCoversDefault && str_starts_with($covers, '::'))) {
243+
$attributeGroup = $this->createAttributeGroup($covers);
244+
245+
// phpunit 10 may not fully support attribute
246+
if (! $attributeGroup instanceof AttributeGroup) {
247+
continue;
248+
}
249+
250+
$attributeGroups[$covers] = $attributeGroup;
246251
}
247252

248253
$this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $desiredTagValueNode);
@@ -269,10 +274,15 @@ private function resolveMethodAttributes(ClassMethod $classMethod, bool $hasCove
269274
}
270275

271276
$covers = $desiredTagValueNode->value->value;
272-
if (str_starts_with($covers, '\\')) {
273-
$attributeGroups[$covers] = $this->createAttributeGroup($covers);
274-
} elseif (! $hasCoversDefault && str_starts_with($covers, '::')) {
275-
$attributeGroups[$covers] = $this->createAttributeGroup($covers);
277+
if (str_starts_with($covers, '\\') || (! $hasCoversDefault && str_starts_with($covers, '::'))) {
278+
$attributeGroup = $this->createAttributeGroup($covers);
279+
280+
// phpunit 10 may not fully support attribute
281+
if (! $attributeGroup instanceof AttributeGroup) {
282+
continue;
283+
}
284+
285+
$attributeGroups[$covers] = $attributeGroup;
276286
}
277287
}
278288

0 commit comments

Comments
 (0)