|
15 | 15 | use PHPStan\Type\Constant\ConstantStringType; |
16 | 16 | use PHPStan\Type\Generic\GenericClassStringType; |
17 | 17 | use PHPStan\Type\Generic\GenericObjectType; |
| 18 | +use PHPStan\Type\Generic\TemplateBenevolentUnionType; |
18 | 19 | use PHPStan\Type\Generic\TemplateObjectType; |
19 | 20 | use PHPStan\Type\Generic\TemplateObjectWithoutClassType; |
20 | 21 | use PHPStan\Type\Generic\TemplateType; |
21 | 22 | use PHPStan\Type\Generic\TemplateTypeFactory; |
22 | 23 | use PHPStan\Type\Generic\TemplateTypeScope; |
23 | 24 | use PHPStan\Type\Generic\TemplateTypeVariance; |
| 25 | +use PHPStan\Type\Generic\TemplateUnionType; |
24 | 26 |
|
25 | 27 | class TypeCombinatorTest extends \PHPStan\Testing\TestCase |
26 | 28 | { |
@@ -2945,6 +2947,45 @@ public function dataIntersect(): array |
2945 | 2947 | NeverType::class, |
2946 | 2948 | '*NEVER*', |
2947 | 2949 | ], |
| 2950 | + [ |
| 2951 | + [ |
| 2952 | + TemplateTypeFactory::create( |
| 2953 | + TemplateTypeScope::createWithFunction('my_array_keys'), |
| 2954 | + 'T', |
| 2955 | + new BenevolentUnionType([new IntegerType(), new StringType()]), |
| 2956 | + TemplateTypeVariance::createInvariant(), |
| 2957 | + ), |
| 2958 | + new UnionType([new IntegerType(), new StringType()]), |
| 2959 | + ], |
| 2960 | + TemplateBenevolentUnionType::class, |
| 2961 | + 'T of (int|string) (function my_array_keys(), parameter)', |
| 2962 | + ], |
| 2963 | + [ |
| 2964 | + [ |
| 2965 | + TemplateTypeFactory::create( |
| 2966 | + TemplateTypeScope::createWithFunction('my_array_keys'), |
| 2967 | + 'T', |
| 2968 | + new BenevolentUnionType([new IntegerType(), new StringType()]), |
| 2969 | + TemplateTypeVariance::createInvariant(), |
| 2970 | + ), |
| 2971 | + new BenevolentUnionType([new IntegerType(), new StringType()]), |
| 2972 | + ], |
| 2973 | + TemplateBenevolentUnionType::class, |
| 2974 | + 'T of (int|string) (function my_array_keys(), parameter)', |
| 2975 | + ], |
| 2976 | + [ |
| 2977 | + [ |
| 2978 | + TemplateTypeFactory::create( |
| 2979 | + TemplateTypeScope::createWithFunction('my_array_keys'), |
| 2980 | + 'T', |
| 2981 | + new UnionType([new IntegerType(), new StringType()]), |
| 2982 | + TemplateTypeVariance::createInvariant(), |
| 2983 | + ), |
| 2984 | + new UnionType([new IntegerType(), new StringType()]), |
| 2985 | + ], |
| 2986 | + UnionType::class, |
| 2987 | + 'T of int|string (function my_array_keys(), parameter)', |
| 2988 | + ], |
2948 | 2989 | ]; |
2949 | 2990 | } |
2950 | 2991 |
|
|
0 commit comments