diff --git a/src/Type/TypeCombinator.php b/src/Type/TypeCombinator.php index 6dd1fd1bf0..fb6eba781a 100644 --- a/src/Type/TypeCombinator.php +++ b/src/Type/TypeCombinator.php @@ -326,6 +326,14 @@ public static function union(Type ...$types): Type $scalarTypes[$classType] = $scalarTypeItems; } + if (count($types) > 16) { + $newTypes = []; + foreach ($types as $type) { + $newTypes[$type->describe(VerbosityLevel::cache())] = $type; + } + $types = array_values($newTypes); + } + // transform A | A to A // transform A | never to A $typesCount = count($types);