From 66f63d3dbed46ab27f7f87303fbbe3dc92caa195 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 31 Dec 2022 14:57:09 +0100 Subject: [PATCH] recurse into union-inner Intersections --- src/Type/TypeUtils.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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;