|
6 | 6 | use PHPStan\Analyser\Scope; |
7 | 7 | use PHPStan\Reflection\FunctionReflection; |
8 | 8 | use PHPStan\Type\BooleanType; |
9 | | -use PHPStan\Type\Constant\ConstantBooleanType; |
10 | 9 | use PHPStan\Type\Constant\ConstantIntegerType; |
11 | | -use PHPStan\Type\Constant\ConstantStringType; |
12 | 10 | use PHPStan\Type\DynamicFunctionReturnTypeExtension; |
13 | 11 | use PHPStan\Type\FloatType; |
14 | 12 | use PHPStan\Type\IntegerRangeType; |
@@ -44,25 +42,20 @@ public function getTypeFromFunctionCall( |
44 | 42 | } |
45 | 43 |
|
46 | 44 | $argType = $scope->getType($args[0]->value); |
47 | | - |
48 | 45 | if ($argType->isSuperTypeOf(new BooleanType())->yes()) { |
49 | | - $constantScalars = TypeCombinator::remove($argType, new BooleanType())->getConstantScalarTypes(); |
| 46 | + $constantScalars = TypeCombinator::remove($argType, new BooleanType())->getConstantScalarValues(); |
50 | 47 | if (count($constantScalars) > 0) { |
51 | | - $constantScalars[] = new ConstantBooleanType(true); |
52 | | - $constantScalars[] = new ConstantBooleanType(false); |
| 48 | + $constantScalars[] = true; |
| 49 | + $constantScalars[] = false; |
53 | 50 | } |
54 | 51 | } else { |
55 | | - $constantScalars = $argType->getConstantScalarTypes(); |
| 52 | + $constantScalars = $argType->getConstantScalarValues(); |
56 | 53 | } |
57 | 54 |
|
58 | 55 | $lengths = []; |
59 | 56 | foreach ($constantScalars as $constantScalar) { |
60 | | - $stringScalar = $constantScalar->toString(); |
61 | | - if (!($stringScalar instanceof ConstantStringType)) { |
62 | | - $lengths = []; |
63 | | - break; |
64 | | - } |
65 | | - $length = strlen($stringScalar->getValue()); |
| 57 | + $stringScalar = (string) $constantScalar; |
| 58 | + $length = strlen($stringScalar); |
66 | 59 | $lengths[] = $length; |
67 | 60 | } |
68 | 61 |
|
|
0 commit comments