Skip to content

Commit beec4e2

Browse files
committed
Lazier return in UnionType->isSuperTypeOf()
1 parent 8d67d7a commit beec4e2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Type/UnionType.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,16 @@ public function isSuperTypeOfWithReason(Type $otherType): IsSuperTypeOfResult
245245
return $otherType->isSubTypeOfWithReason($this);
246246
}
247247

248-
$result = IsSuperTypeOfResult::createNo()->or(...array_map(static fn (Type $innerType) => $innerType->isSuperTypeOfWithReason($otherType), $this->types));
248+
$results = [];
249+
foreach ($this->types as $innerType) {
250+
$result = $innerType->isSuperTypeOfWithReason($otherType);
251+
if ($result->yes()) {
252+
return $result;
253+
}
254+
$results[] = $result;
255+
}
256+
257+
$result = IsSuperTypeOfResult::createNo()->or(...$results);
249258
if ($result->yes()) {
250259
return $result;
251260
}

0 commit comments

Comments
 (0)