diff --git a/src/Type/TypeUtils.php b/src/Type/TypeUtils.php index a51e2fb51bf..bc000d8a2e7 100644 --- a/src/Type/TypeUtils.php +++ b/src/Type/TypeUtils.php @@ -218,7 +218,9 @@ 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 []; } @@ -226,7 +228,9 @@ private static function map( continue; } - $matchingTypes[] = $innerType; + foreach ($mappedInner as $innerMapped) { + $matchingTypes[] = $innerMapped; + } } return $matchingTypes;