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
4040
4141 public static function addNull (Type $ type ): Type
4242 {
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 );
4547 }
4648
4749 return $ type ;
@@ -241,8 +243,12 @@ public static function union(Type ...$types): Type
241243
242244 // simplify string[] | int[] to (string|int)[]
243245 for ($ i = 0 ; $ i < $ typesCount ; $ i ++) {
246+ if (! $ types [$ i ] instanceof IterableType) {
247+ continue ;
248+ }
249+
244250 for ($ j = $ i + 1 ; $ j < $ typesCount ; $ j ++) {
245- if ($ types [$ i ] instanceof IterableType && $ types [ $ j ] instanceof IterableType) {
251+ if ($ types [$ j ] instanceof IterableType) {
246252 $ types [$ i ] = new IterableType (
247253 self ::union ($ types [$ i ]->getIterableKeyType (), $ types [$ j ]->getIterableKeyType ()),
248254 self ::union ($ types [$ i ]->getIterableValueType (), $ types [$ j ]->getIterableValueType ()),
You can’t perform that action at this time.
0 commit comments