Project

General

Profile

Actions

Bug #96507

closed

PHPStan issue with QueryBuilder annotations

Added by Elias Häußler over 2 years ago. Updated almost 2 years 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

Also available in: Atom PDF