Project

General

Profile

Actions

Bug #96507

closed

PHPStan issue with QueryBuilder annotations

Added by Elias Häußler over 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2022-01-11
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
7.4
Tags:
Complexity:
no-brainer
Is Regression:
Yes
Sprint Focus:

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:

A possible solution would be to

  1. either move the |CompositeExpression to the existing array: https://phpstan.org/r/3f42d413-f44d-4b4e-b82a-57a231a7f69e or
  2. 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


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #96457: Some QueryBuilder methods have incomplete param annotationClosed2022-01-04

Actions
Actions #1

Updated by Elias Häußler over 2 years ago

  • Related to Bug #96457: Some QueryBuilder methods have incomplete param annotation added
Actions #2

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

Actions #3

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

Actions #4

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

Actions #5

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

Actions #6

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

Actions #7

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

Actions #8

Updated by Anonymous over 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #9

Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF