From 2f363239357b849bc150295b554100c106b6c26b Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Wed, 8 Mar 2023 17:31:10 +0100 Subject: [PATCH] Fix build --- src/Type/Symfony/ParameterDynamicReturnTypeExtension.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php b/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php index b160ddc8..82d3599e 100644 --- a/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php @@ -14,7 +14,6 @@ use PHPStan\Type\BooleanType; use PHPStan\Type\Constant\ConstantArrayType; use PHPStan\Type\Constant\ConstantBooleanType; -use PHPStan\Type\Constant\ConstantStringType; use PHPStan\Type\ConstantType; use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\FloatType; @@ -160,9 +159,12 @@ private function generalizeTypeFromValue(Scope $scope, $value): Type $keyTypes = []; $valueTypes = []; foreach ($value as $key => $element) { - /** @var ConstantStringType $keyType */ $keyType = $scope->getTypeFromValue($key); - $keyTypes[] = $keyType; + $keyStringTypes = $keyType->getConstantStrings(); + if (count($keyStringTypes) !== 1) { + throw new ShouldNotHappenException(); + } + $keyTypes[] = $keyStringTypes[0]; $valueTypes[] = $this->generalizeTypeFromValue($scope, $element); }