Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more array types #687

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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