Skip to content

Commit

Permalink
Support more array types (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored Oct 3, 2024
1 parent 31a21b6 commit dffa34b
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/QueryReflection/QuerySimulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -36,8 +34,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 (
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit dffa34b

Please sign in to comment.