File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -40,8 +40,10 @@ class TypeCombinator
40
40
41
41
public static function addNull (Type $ type ): Type
42
42
{
43
- if ((new NullType ())->isSuperTypeOf ($ type )->no ()) {
44
- return self ::union ($ type , new NullType ());
43
+ $ nullType = new NullType ();
44
+
45
+ if ($ nullType ->isSuperTypeOf ($ type )->no ()) {
46
+ return self ::union ($ type , $ nullType );
45
47
}
46
48
47
49
return $ type ;
@@ -241,8 +243,12 @@ public static function union(Type ...$types): Type
241
243
242
244
// simplify string[] | int[] to (string|int)[]
243
245
for ($ i = 0 ; $ i < $ typesCount ; $ i ++) {
246
+ if (! $ types [$ i ] instanceof IterableType) {
247
+ continue ;
248
+ }
249
+
244
250
for ($ j = $ i + 1 ; $ j < $ typesCount ; $ j ++) {
245
- if ($ types [$ i ] instanceof IterableType && $ types [ $ j ] instanceof IterableType) {
251
+ if ($ types [$ j ] instanceof IterableType) {
246
252
$ types [$ i ] = new IterableType (
247
253
self ::union ($ types [$ i ]->getIterableKeyType (), $ types [$ j ]->getIterableKeyType ()),
248
254
self ::union ($ types [$ i ]->getIterableValueType (), $ types [$ j ]->getIterableValueType ()),
You can’t perform that action at this time.
0 commit comments