|
8 | 8 | use Iterator; |
9 | 9 | use PHPStan\Reflection\Native\NativeParameterReflection; |
10 | 10 | use PHPStan\Reflection\PassedByReference; |
| 11 | +use PHPStan\ShouldNotHappenException; |
11 | 12 | use PHPStan\Testing\PHPStanTestCase; |
12 | 13 | use PHPStan\TrinaryLogic; |
13 | 14 | use PHPStan\Type\Accessory\AccessoryLiteralStringType; |
|
33 | 34 | use function array_merge; |
34 | 35 | use function array_reverse; |
35 | 36 | use function get_class; |
| 37 | +use function PHPStan\dumpType; |
36 | 38 | use function sprintf; |
37 | 39 | use const PHP_VERSION_ID; |
38 | 40 |
|
@@ -180,6 +182,12 @@ public static function dataIsSuperTypeOf(): Iterator |
180 | 182 | new IntegerType(), |
181 | 183 | new StringType(), |
182 | 184 | ]); |
| 185 | + if ( |
| 186 | + !isset($unionTypeA->getTypes()[0]) |
| 187 | + || !isset($unionTypeA->getTypes()[1]) |
| 188 | + ) { |
| 189 | + throw new ShouldNotHappenException(); |
| 190 | + } |
183 | 191 |
|
184 | 192 | yield [ |
185 | 193 | $unionTypeA, |
@@ -266,6 +274,12 @@ public static function dataIsSuperTypeOf(): Iterator |
266 | 274 | ]), |
267 | 275 | new ArrayType(new MixedType(), new ObjectType('DatePeriod')), |
268 | 276 | ]); |
| 277 | + if ( |
| 278 | + !isset($unionTypeB->getTypes()[0]) |
| 279 | + || !isset($unionTypeB->getTypes()[1]) |
| 280 | + ) { |
| 281 | + throw new ShouldNotHappenException(); |
| 282 | + } |
269 | 283 |
|
270 | 284 | yield [ |
271 | 285 | $unionTypeB, |
@@ -477,6 +491,12 @@ public static function dataIsSubTypeOf(): Iterator |
477 | 491 | new IntegerType(), |
478 | 492 | new StringType(), |
479 | 493 | ]); |
| 494 | + if ( |
| 495 | + !isset($unionTypeA->getTypes()[0]) |
| 496 | + || !isset($unionTypeA->getTypes()[1]) |
| 497 | + ) { |
| 498 | + throw new ShouldNotHappenException(); |
| 499 | + } |
480 | 500 |
|
481 | 501 | yield [ |
482 | 502 | $unionTypeA, |
@@ -570,6 +590,12 @@ public static function dataIsSubTypeOf(): Iterator |
570 | 590 | ]), |
571 | 591 | new ArrayType(new MixedType(), new ObjectType('Item')), |
572 | 592 | ]); |
| 593 | + if ( |
| 594 | + !isset($unionTypeB->getTypes()[0]) |
| 595 | + || !isset($unionTypeB->getTypes()[1]) |
| 596 | + ) { |
| 597 | + throw new ShouldNotHappenException(); |
| 598 | + } |
573 | 599 |
|
574 | 600 | yield [ |
575 | 601 | $unionTypeB, |
|
0 commit comments