Skip to content

Commit

Permalink
StrlenFunctionReturnTypeExtension: Cleanup `instanceof ConstantString…
Browse files Browse the repository at this point in the history
…Type`
  • Loading branch information
staabm committed Jan 11, 2025
1 parent 76740fd commit 58a50a7
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/Type/Php/StrlenFunctionReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\DynamicFunctionReturnTypeExtension;
use PHPStan\Type\FloatType;
use PHPStan\Type\IntegerRangeType;
Expand Down Expand Up @@ -42,16 +41,12 @@ public function getTypeFromFunctionCall(
}

$argType = $scope->getType($args[0]->value);
$constantScalars = $argType->getConstantScalarTypes();
$constantScalars = $argType->getConstantScalarValues();

$lengths = [];
foreach ($constantScalars as $constantScalar) {
$stringScalar = $constantScalar->toString();
if (!($stringScalar instanceof ConstantStringType)) {
$lengths = [];
break;
}
$length = strlen($stringScalar->getValue());
$stringScalar = (string) $constantScalar;
$length = strlen($stringScalar);
$lengths[] = $length;
}

Expand Down

0 comments on commit 58a50a7

Please sign in to comment.