@@ -177,26 +177,22 @@ public function testSelfCompare(Type $type): void
177177 */
178178 public static function dataIsSuperTypeOf (): Iterator
179179 {
180+ $ int = new IntegerType ();
181+ $ string = new StringType ();
180182 $ unionTypeA = new UnionType ([
181- new IntegerType () ,
182- new StringType (),
183+ $ int ,
184+ $ string
183185 ]);
184- if (
185- !isset ($ unionTypeA ->getTypes ()[0 ])
186- || !isset ($ unionTypeA ->getTypes ()[1 ])
187- ) {
188- throw new ShouldNotHappenException ();
189- }
190186
191187 yield [
192188 $ unionTypeA ,
193- $ unionTypeA -> getTypes ()[ 0 ] ,
189+ $ int ,
194190 TrinaryLogic::createYes (),
195191 ];
196192
197193 yield [
198194 $ unionTypeA ,
199- $ unionTypeA -> getTypes ()[ 1 ] ,
195+ $ string ,
200196 TrinaryLogic::createYes (),
201197 ];
202198
@@ -266,29 +262,25 @@ public static function dataIsSuperTypeOf(): Iterator
266262 TrinaryLogic::createNo (),
267263 ];
268264
265+ $ intersectionTypeB = new IntersectionType ([
266+ new ObjectType ('ArrayObject ' ),
267+ new IterableType (new MixedType (), new ObjectType ('DatePeriod ' )),
268+ ]);
269+ $ arrayTypeB = new ArrayType (new MixedType (), new ObjectType ('DatePeriod ' ));
269270 $ unionTypeB = new UnionType ([
270- new IntersectionType ([
271- new ObjectType ('ArrayObject ' ),
272- new IterableType (new MixedType (), new ObjectType ('DatePeriod ' )),
273- ]),
274- new ArrayType (new MixedType (), new ObjectType ('DatePeriod ' )),
271+ $ intersectionTypeB ,
272+ $ arrayTypeB
275273 ]);
276- if (
277- !isset ($ unionTypeB ->getTypes ()[0 ])
278- || !isset ($ unionTypeB ->getTypes ()[1 ])
279- ) {
280- throw new ShouldNotHappenException ();
281- }
282274
283275 yield [
284276 $ unionTypeB ,
285- $ unionTypeB -> getTypes ()[ 0 ] ,
277+ $ intersectionTypeB ,
286278 TrinaryLogic::createYes (),
287279 ];
288280
289281 yield [
290282 $ unionTypeB ,
291- $ unionTypeB -> getTypes ()[ 1 ] ,
283+ $ arrayTypeB ,
292284 TrinaryLogic::createYes (),
293285 ];
294286
@@ -486,16 +478,12 @@ public function testIsSuperTypeOf(UnionType $type, Type $otherType, TrinaryLogic
486478 */
487479 public static function dataIsSubTypeOf (): Iterator
488480 {
481+ $ int = new IntegerType ();
482+ $ string = new StringType ();
489483 $ unionTypeA = new UnionType ([
490- new IntegerType () ,
491- new StringType (),
484+ $ int ,
485+ $ string
492486 ]);
493- if (
494- !isset ($ unionTypeA ->getTypes ()[0 ])
495- || !isset ($ unionTypeA ->getTypes ()[1 ])
496- ) {
497- throw new ShouldNotHappenException ();
498- }
499487
500488 yield [
501489 $ unionTypeA ,
@@ -517,13 +505,13 @@ public static function dataIsSubTypeOf(): Iterator
517505
518506 yield [
519507 $ unionTypeA ,
520- $ unionTypeA -> getTypes ()[ 0 ] ,
508+ $ int ,
521509 TrinaryLogic::createMaybe (),
522510 ];
523511
524512 yield [
525513 $ unionTypeA ,
526- $ unionTypeA -> getTypes ()[ 1 ] ,
514+ $ string ,
527515 TrinaryLogic::createMaybe (),
528516 ];
529517
@@ -581,20 +569,16 @@ public static function dataIsSubTypeOf(): Iterator
581569 TrinaryLogic::createNo (),
582570 ];
583571
572+ $ intersectionTypeB = new IntersectionType ([
573+ new ObjectType ('ArrayObject ' ),
574+ new IterableType (new MixedType (), new ObjectType ('Item ' )),
575+ new CallableType (),
576+ ]);
577+ $ arrayTypeB = new ArrayType (new MixedType (), new ObjectType ('Item ' ));
584578 $ unionTypeB = new UnionType ([
585- new IntersectionType ([
586- new ObjectType ('ArrayObject ' ),
587- new IterableType (new MixedType (), new ObjectType ('Item ' )),
588- new CallableType (),
589- ]),
590- new ArrayType (new MixedType (), new ObjectType ('Item ' )),
579+ $ intersectionTypeB ,
580+ $ arrayTypeB
591581 ]);
592- if (
593- !isset ($ unionTypeB ->getTypes ()[0 ])
594- || !isset ($ unionTypeB ->getTypes ()[1 ])
595- ) {
596- throw new ShouldNotHappenException ();
597- }
598582
599583 yield [
600584 $ unionTypeB ,
@@ -616,13 +600,13 @@ public static function dataIsSubTypeOf(): Iterator
616600
617601 yield [
618602 $ unionTypeB ,
619- $ unionTypeB -> getTypes ()[ 0 ] ,
603+ $ intersectionTypeB ,
620604 TrinaryLogic::createMaybe (),
621605 ];
622606
623607 yield [
624608 $ unionTypeB ,
625- $ unionTypeB -> getTypes ()[ 1 ] ,
609+ $ arrayTypeB ,
626610 TrinaryLogic::createMaybe (),
627611 ];
628612
0 commit comments