From 52432e1ef5ef7dc583864c736e293fd630b3036c Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 3 Oct 2024 09:36:35 +0200 Subject: [PATCH 1/2] Support more array types --- src/QueryReflection/QuerySimulation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/QueryReflection/QuerySimulation.php b/src/QueryReflection/QuerySimulation.php index c5e2107b..c0bc24ad 100644 --- a/src/QueryReflection/QuerySimulation.php +++ b/src/QueryReflection/QuerySimulation.php @@ -36,8 +36,8 @@ public static function simulateParamValueType(Type $paramType, bool $preparedPar return (string) $paramType->getValue(); } - if ($paramType instanceof ArrayType) { - return self::simulateParamValueType($paramType->getItemType(), $preparedParam); + if ($paramType->isArray()->yes()) { + return self::simulateParamValueType($paramType->getIterableValueType(), $preparedParam); } if ( From 1c8e817aa2c1951d336251ef7dffe44c649badec Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 3 Oct 2024 09:39:16 +0200 Subject: [PATCH 2/2] Update QuerySimulation.php --- src/QueryReflection/QuerySimulation.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/QueryReflection/QuerySimulation.php b/src/QueryReflection/QuerySimulation.php index c0bc24ad..05a9997a 100644 --- a/src/QueryReflection/QuerySimulation.php +++ b/src/QueryReflection/QuerySimulation.php @@ -5,8 +5,6 @@ namespace staabm\PHPStanDba\QueryReflection; use PHPStan\ShouldNotHappenException; -use PHPStan\Type\Accessory\AccessoryType; -use PHPStan\Type\ArrayType; use PHPStan\Type\ConstantScalarType; use PHPStan\Type\ErrorType; use PHPStan\Type\IntersectionType; @@ -92,19 +90,6 @@ public static function simulateParamValueType(Type $paramType, bool $preparedPar return null; } - if ($paramType instanceof IntersectionType) { - foreach ($paramType->getTypes() as $type) { - if ($type instanceof AccessoryType) { - continue; - } - - $simulated = self::simulateParamValueType($type, $preparedParam); - if (null !== $simulated) { - return $simulated; - } - } - } - // all types which we can't simulate and render a query unresolvable at analysis time if ($paramType instanceof MixedType || $paramType instanceof IntersectionType) { if (QueryReflection::getRuntimeConfiguration()->isDebugEnabled()) {