phpstan-doctrine icon indicating copy to clipboard operation
phpstan-doctrine copied to clipboard

Idea: Check if QueryBuilder `->where()->setParameter()` is set to `Types::SIMPLE_ARRAY` for array columns

Open ThomasLandauer opened this issue 1 year ago • 0 comments

When a field is defined as simple_array:

#[ORM\Column(type: Types::SIMPLE_ARRAY, length: 255, nullable: true)]
private array $foo = [];

... then using it in a Query Builder like this

$queryBuilder->where('a.foo = :array')->setParameter('array', $array, Types::SIMPLE_ARRAY);

... only works, if the third argument to setParameter() ($type) is given. If not, I'm getting this Doctrine\DBAL\Exception\ SyntaxErrorException:

An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1 near ",": syntax error

Would it possible for PHPStan to check for this?

ThomasLandauer avatar Mar 09 '23 21:03 ThomasLandauer