Skip to content

Commit 1c4a091

Browse files
committed
fixup! Add native return type declaration support to NarrowReturnUnionToCollectionRector
1 parent 7ffc869 commit 1c4a091

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

rules/TypedCollections/Rector/ClassMethod/NarrowReturnUnionToCollectionRector.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private function refactorReturnDocblockTag(ClassMethod $classMethod): bool
119119

120120
private function hasNativeCollectionType(ClassMethod $classMethod): bool
121121
{
122-
if (! $classMethod->returnType) {
122+
if (!$classMethod->returnType instanceof Node) {
123123
return false;
124124
}
125125

@@ -128,7 +128,7 @@ private function hasNativeCollectionType(ClassMethod $classMethod): bool
128128

129129
private function refactorNativeReturn(ClassMethod $classMethod): bool
130130
{
131-
if ($classMethod->returnType === null) {
131+
if (!$classMethod->returnType instanceof Node) {
132132
return false;
133133
}
134134

@@ -157,11 +157,7 @@ private function refactorNativeReturn(ClassMethod $classMethod): bool
157157
}
158158
}
159159

160-
if (count($unionType->types) === 1) {
161-
$classMethod->returnType = array_pop($unionType->types);
162-
} else {
163-
$classMethod->returnType = $unionType->types;
164-
}
160+
$classMethod->returnType = count($unionType->types) === 1 ? array_pop($unionType->types) : $unionType->types;
165161

166162
return true;
167163
}

0 commit comments

Comments
 (0)