We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c9273e commit 91c7507Copy full SHA for 91c7507
src/Type/TypeCombinator.php
@@ -95,6 +95,9 @@ public static function containsNull(Type $type): bool
95
public static function union(Type ...$types): Type
96
{
97
$typesCount = count($types);
98
+ if ($typesCount === 0) {
99
+ return new NeverType();
100
+ }
101
102
$benevolentTypes = [];
103
$benevolentUnionObject = null;
@@ -126,6 +129,10 @@ public static function union(Type ...$types): Type
126
129
$typesCount += count($typesInner) - 1;
127
130
}
128
131
132
+ if ($typesCount === 1) {
133
+ return $types[0];
134
135
+
136
$arrayTypes = [];
137
$arrayAccessoryTypes = [];
138
$scalarTypes = [];
0 commit comments