Skip to content

Commit

Permalink
recurse into union-inner Intersections
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Dec 31, 2022
1 parent 7d779e9 commit 66f63d3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Type/TypeUtils.php
Expand Up @@ -218,15 +218,19 @@ private static function map(
if ($type instanceof UnionType) {
$matchingTypes = [];
foreach ($type->getTypes() as $innerType) {
if (!$innerType instanceof $typeClass) {
$mappedInner = self::map($typeClass, $innerType, $inspectIntersections, $stopOnUnmatched);

if ($mappedInner === []) {
if ($stopOnUnmatched) {
return [];
}

continue;
}

$matchingTypes[] = $innerType;
foreach ($mappedInner as $innerMapped) {
$matchingTypes[] = $innerMapped;
}
}

return $matchingTypes;
Expand Down

0 comments on commit 66f63d3

Please sign in to comment.