|
8 | 8 | use PHPStan\Type\BenevolentUnionType; |
9 | 9 | use PHPStan\Type\BooleanType; |
10 | 10 | use PHPStan\Type\Constant\ConstantArrayType; |
| 11 | +use PHPStan\Type\Constant\ConstantFloatType; |
11 | 12 | use PHPStan\Type\Constant\ConstantIntegerType; |
12 | 13 | use PHPStan\Type\Constant\ConstantStringType; |
| 14 | +use PHPStan\Type\FloatRangeType; |
13 | 15 | use PHPStan\Type\FloatType; |
14 | 16 | use PHPStan\Type\IntegerRangeType; |
15 | 17 | use PHPStan\Type\IntegerType; |
@@ -77,18 +79,27 @@ public static function create(TemplateTypeScope $scope, string $name, ?Type $bou |
77 | 79 | return new TemplateConstantStringType($scope, $strategy, $variance, $name, $bound, $default); |
78 | 80 | } |
79 | 81 |
|
80 | | - if ($bound instanceof IntegerType && ($boundClass === IntegerType::class || $bound instanceof IntegerRangeType || $bound instanceof TemplateType)) { |
| 82 | + if ($bound instanceof IntegerRangeType && ($boundClass === IntegerRangeType::class || $bound instanceof TemplateType)) { |
| 83 | + return new TemplateIntegerRangeType($scope, $strategy, $variance, $name, $bound, $default); |
| 84 | + } |
| 85 | + |
| 86 | + if ($bound instanceof IntegerType && ($boundClass === IntegerType::class || $bound instanceof TemplateType)) { |
81 | 87 | return new TemplateIntegerType($scope, $strategy, $variance, $name, $bound, $default); |
82 | 88 | } |
83 | 89 |
|
84 | 90 | if ($bound instanceof ConstantIntegerType && ($boundClass === ConstantIntegerType::class || $bound instanceof TemplateType)) { |
85 | 91 | return new TemplateConstantIntegerType($scope, $strategy, $variance, $name, $bound, $default); |
86 | 92 | } |
87 | 93 |
|
88 | | - // Catches plain FloatType and the float subtypes that narrowing a bound |
89 | | - // produces, a FloatRangeType or a ConstantFloatType, neither of which has a |
90 | | - // dedicated Template* class to fall into. |
91 | | - if ($bound instanceof FloatType) { |
| 94 | + if ($bound instanceof FloatRangeType && ($boundClass === FloatRangeType::class || $bound instanceof TemplateType)) { |
| 95 | + return new TemplateFloatRangeType($scope, $strategy, $variance, $name, $bound, $default); |
| 96 | + } |
| 97 | + |
| 98 | + if ($bound instanceof ConstantFloatType && ($boundClass === ConstantFloatType::class || $bound instanceof TemplateType)) { |
| 99 | + return new TemplateConstantFloatType($scope, $strategy, $variance, $name, $bound, $default); |
| 100 | + } |
| 101 | + |
| 102 | + if ($bound instanceof FloatType && ($boundClass === FloatType::class || $bound instanceof TemplateType)) { |
92 | 103 | return new TemplateFloatType($scope, $strategy, $variance, $name, $bound, $default); |
93 | 104 | } |
94 | 105 |
|
|
0 commit comments