#96507PHPStan issue with QueryBuilder annotations
Description
The change in #96457 causes problems with PHPStan after updating to 11.5.5.
Given this code:
$qb = $this->connection->createQueryBuilder();
$result = $qb
// ...
->where(
// returns string
$qb->expr()->eq('CType', $qb->createNamedParameter($someVariable)
)
->execute()
;
we now get an error
> Parameter #1 …$predicates of method TYPO3\CMS\Core\Database\Query\QueryBuilder::where() expects array<int mixed>|Doctrine\DBAL\Query\Expression\CompositeExpression, string given.</int>
because |CompositeExpression was added. I made a short comparison:
- Before (11.5.4): https://phpstan.org/r/d29e3b2b-d642-4792-9d4b-62d225ad911e (works)
- After (11.5.5): https://phpstan.org/r/2334fbfc-75ae-4956-94af-b583555c61d3 (fails)
A possible solution would be to
- either move the
|CompositeExpressionto the existing array: https://phpstan.org/r/3f42d413-f44d-4b4e-b82a-57a231a7f69e or - resolve the array: https://phpstan.org/r/915d50c1-6bb8-48be-88f7-21b147049acd
PHPStan documents the usage of variadic arguments in https://phpstan.org/writing-php-code/phpdocs-basics#variadic-functions