Skip to content

Commit 5efffc6

Browse files
authored
Lazier return in UnionType->isSuperTypeOfWithReason()
1 parent 8d67d7a commit 5efffc6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Type/UnionType.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,15 @@ 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));
249-
if ($result->yes()) {
250-
return $result;
248+
$results = [];
249+
foreach ($this->types as $innerType) {
250+
$result = $innerType->isSuperTypeOfWithReason($otherType);
251+
if ($result->yes()) {
252+
return $result;
253+
}
254+
$results[] = $result;
251255
}
256+
$result = IsSuperTypeOfResult::createNo()->or(...$results);
252257

253258
if ($otherType instanceof TemplateUnionType) {
254259
return $result->or($otherType->isSubTypeOfWithReason($this));

0 commit comments

Comments
 (0)