diff --git a/rules/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector.php b/rules/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector.php index de967aa7..d2e9a5b1 100644 --- a/rules/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector.php +++ b/rules/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector.php @@ -4,6 +4,7 @@ namespace Rector\Doctrine\CodeQuality\Rector\Class_; +use PhpParser\Node\Attribute; use PhpParser\Node; use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Stmt\Class_; @@ -102,13 +103,13 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node $property = $this->methodUniqueReturnedPropertyResolver->resolve($node, $classMethod); - if ($property === null) { + if (!$property instanceof Property) { continue; } $collectionObjectType = $this->getCollectionObjectTypeFromToManyAttribute($property); - if ($collectionObjectType === null) { + if (!$collectionObjectType instanceof FullyQualifiedObjectType) { return null; } @@ -153,6 +154,6 @@ private function isDoctrineEntityClass(Class_ $class): bool ['Doctrine\ORM\Mapping\Entity', 'Doctrine\ORM\Mapping\Embeddable'], ); - return $entityAttribute !== null; + return $entityAttribute instanceof Attribute; } }