Bug #96507
closedPHPStan issue with QueryBuilder annotations
100%
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.
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
|CompositeExpression
to 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
Updated by Elias Häußler over 2 years ago
- Related to Bug #96457: Some QueryBuilder methods have incomplete param annotation added
Updated by Gerrit Code Review over 2 years ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72964
Updated by Gerrit Code Review over 2 years ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72964
Updated by Gerrit Code Review over 2 years ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72964
Updated by Gerrit Code Review over 2 years ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/72964
Updated by Gerrit Code Review over 2 years ago
Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73009
Updated by Gerrit Code Review over 2 years ago
Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73010
Updated by Anonymous over 2 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 73e8bed8a83c26f555722c703264f0ad8a7f54f8.