Skip to content

Commit 58a50a7

Browse files
committed
StrlenFunctionReturnTypeExtension: Cleanup instanceof ConstantStringType
1 parent 76740fd commit 58a50a7

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/Type/Php/StrlenFunctionReturnTypeExtension.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Reflection\FunctionReflection;
88
use PHPStan\Type\Constant\ConstantIntegerType;
9-
use PHPStan\Type\Constant\ConstantStringType;
109
use PHPStan\Type\DynamicFunctionReturnTypeExtension;
1110
use PHPStan\Type\FloatType;
1211
use PHPStan\Type\IntegerRangeType;
@@ -42,16 +41,12 @@ public function getTypeFromFunctionCall(
4241
}
4342

4443
$argType = $scope->getType($args[0]->value);
45-
$constantScalars = $argType->getConstantScalarTypes();
44+
$constantScalars = $argType->getConstantScalarValues();
4645

4746
$lengths = [];
4847
foreach ($constantScalars as $constantScalar) {
49-
$stringScalar = $constantScalar->toString();
50-
if (!($stringScalar instanceof ConstantStringType)) {
51-
$lengths = [];
52-
break;
53-
}
54-
$length = strlen($stringScalar->getValue());
48+
$stringScalar = (string) $constantScalar;
49+
$length = strlen($stringScalar);
5550
$lengths[] = $length;
5651
}
5752

0 commit comments

Comments
 (0)