Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/QueryReflection/QuerySimulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function simulateParamValueType(Type $paramType, bool $preparedPar
return (string) $paramType->getValue();
}

if ($paramType->isArray()->yes()) {
if ($paramType->isIterable()->yes()) {
return self::simulateParamValueType($paramType->getIterableValueType(), $preparedParam);
}

Expand Down
14 changes: 14 additions & 0 deletions tests/default/data/pdo-prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ public function specifiedArray(PDO $pdo, array $idsToUpdate, string $time)
assertType('PDOStatement<array{adaid: int<-32768, 32767>, 0: int<-32768, 32767>}>', $stmt);
}

/**
* @param iterable<int> $idsToUpdate
*/
public function specifiedIterable(PDO $pdo, iterable $idsToUpdate, string $time)
{
$query = 'SELECT adaid FROM ada WHERE adaid IN (:ids) AND email LIKE :time';
$stmt = $pdo->prepare($query);
$stmt->execute([
'ids' => $idsToUpdate,
'time' => $time,
]);
assertType('PDOStatement<array{adaid: int<-32768, 32767>, 0: int<-32768, 32767>}>', $stmt);
}

public function noInferenceOnBug196(PDO $pdo, array $minorPhpVersions, \DateTimeImmutable $updateDate)
{
$sumQueries = [];
Expand Down
5 changes: 5 additions & 0 deletions tests/rules/UnresolvableQueryMethodRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ public function testBug547(): void
{
$this->analyse([__DIR__ . '/data/bug-547.php'], []);
}

public function testBug676(): void
{
$this->analyse([__DIR__ . '/data/bug-676.php'], []);
}
}
22 changes: 22 additions & 0 deletions tests/rules/data/bug-676.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Test;

use Doctrine\DBAL\Connection;

class Test
{
private Connection $connection;

public function getIds(iterable $ids): array
{
return $this
->connection
->executeQuery(
'SELECT id FROM table WHERE id IN (:list)',
['list' => $ids],
['list' => DBAL\Connection::PARAM_INT_ARRAY],
)
->fetchFirstColumn();
}
}