diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 8040aad1958..ccfd230c807 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -1030,9 +1030,11 @@ private function getTimestampKey(): TimestampCacheKey|null protected function getHydrationCacheId(): array { $parameters = []; + $types = []; foreach ($this->getParameters() as $parameter) { $parameters[$parameter->getName()] = $this->processParameterValue($parameter->getValue()); + $types[$parameter->getName()] = $parameter->getType(); } $sql = $this->getSQL(); @@ -1044,7 +1046,7 @@ protected function getHydrationCacheId(): array ksort($hints); assert($queryCacheProfile !== null); - return $queryCacheProfile->generateCacheKeys($sql, $parameters, $hints); + return $queryCacheProfile->generateCacheKeys($sql, $parameters, $types, $hints); } /** diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 039696f1fd9..c2d6a98c4ae 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -332,7 +332,7 @@ protected function fetchVersionAndNotUpsertableValues(ClassMetadata $versionedCl * @param mixed[] $id * * @return list - * @psalm-return list + * @psalm-return list */ private function extractIdentifierTypes(array $id, ClassMetadata $versionedClass): array { @@ -1812,7 +1812,7 @@ public function expandParameters(array $criteria): array * - class to which the field belongs to * * @return mixed[][] - * @psalm-return array{0: array, 1: list} + * @psalm-return array{0: array, 1: list} */ private function expandToManyParameters(array $criteria): array { @@ -1834,8 +1834,8 @@ private function expandToManyParameters(array $criteria): array /** * Infers field types to be used by parameter type casting. * - * @return list - * @psalm-return list + * @return list + * @psalm-return list * * @throws QueryException */ @@ -1879,7 +1879,8 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar return $types; } - private function getArrayBindingType(ParameterType|int|string $type): int + /** @psalm-return ArrayParameterType::* */ + private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int { if (! $type instanceof ParameterType) { $type = Type::getType((string) $type)->getBindingType(); diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index cdda39119cd..4967c876e71 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Persisters\Entity; use Doctrine\Common\Collections\Criteria; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\ParameterType; use Doctrine\ORM\Mapping\ClassMetadata; @@ -69,14 +70,14 @@ public function getCountSQL(array|Criteria $criteria = []): string; * * @param string[] $criteria * - * @psalm-return array{list, list} + * @psalm-return array{list, list} */ public function expandParameters(array $criteria): array; /** * Expands Criteria Parameters by walking the expressions and grabbing all parameters and types from it. * - * @psalm-return array{list, list} + * @psalm-return array{list, list} */ public function expandCriteriaParameters(Criteria $criteria): array; diff --git a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php index 51bcee79b06..dae28faee18 100644 --- a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php +++ b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php @@ -29,7 +29,7 @@ final class ParameterTypeInferer * - Type (\Doctrine\DBAL\Types\Type::*) * - Connection (\Doctrine\DBAL\Connection::PARAM_*) */ - public static function inferType(mixed $value): ParameterType|int|string + public static function inferType(mixed $value): ParameterType|ArrayParameterType|int|string { if (is_int($value)) { return Types::INTEGER; diff --git a/phpstan.neon b/phpstan.neon index 3a599ca6fc9..fd318f3530a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -16,3 +16,6 @@ parameters: - message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' path: lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php + - + message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' + path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index 397cac522cd..8e9c531ae74 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -18,7 +18,7 @@ class ParameterTypeInfererTest extends OrmTestCase { - /** @psalm-return Generator */ + /** @psalm-return Generator */ public function providerParameterTypeInferer(): Generator { yield 'integer' => [1, Types::INTEGER]; @@ -39,7 +39,7 @@ public function providerParameterTypeInferer(): Generator } /** @dataProvider providerParameterTypeInferer */ - public function testParameterTypeInferer(mixed $value, ParameterType|int|string $expected): void + public function testParameterTypeInferer(mixed $value, ParameterType|ArrayParameterType|int|string $expected): void { self::assertEquals($expected, ParameterTypeInferer::inferType($value)); }