Skip to content

Commit abe4ae1

Browse files
committed
fixup! add native property type support to NarrowPropertyUnionToCollectionRector
1 parent a3480f3 commit abe4ae1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

rules/TypedCollections/Rector/Property/NarrowPropertyUnionToCollectionRector.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace Rector\Doctrine\TypedCollections\Rector\Property;
66

7+
use PhpParser\Node\UnionType;
8+
use PhpParser\Node\Name\FullyQualified;
9+
use PhpParser\Node\Expr;
710
use Doctrine\Common\Collections\Collection;
811
use PhpParser\Node;
912
use PhpParser\Node\Name;
@@ -94,15 +97,15 @@ public function refactor(Node $node): ?Class_
9497
}
9598

9699
// 2. handle native type
97-
if ($property->type instanceof Node\UnionType) {
100+
if ($property->type instanceof UnionType) {
98101
foreach ($property->type->types as $uniontedType) {
99102
if ($this->isCollectionName($uniontedType)) {
100103
// narrow to pure collection
101-
$property->type = new Name\FullyQualified(DoctrineClass::COLLECTION);
104+
$property->type = new FullyQualified(DoctrineClass::COLLECTION);
102105
$hasChanged = true;
103106

104107
// remove default, as will be defined in constructor by another rule
105-
if ($property->props[0]->default instanceof Node\Expr) {
108+
if ($property->props[0]->default instanceof Expr) {
106109
$property->props[0]->default = null;
107110
}
108111

0 commit comments

Comments
 (0)