Skip to content

QueryBuilder::targetFunc() return type callable fails on PHP 8.3+ with strict type checking #561

@enlivenapp

Description

@enlivenapp

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

Affected version: v2.15.0 (and 2.x-dev)

File: src/Select/QueryBuilder.php, line 193-210

The problem:

private function targetFunc(string $call): callable           
{                                                  
    // ...
    return [$this->query, $call];
}                                

The method declares callable as its return type but returns [$this->query,
$call]. On PHP 8.3, this throws a TypeError because PHP's stricter type
enforcement no longer accepts all [$object, $method] arrays as callable
without validation at the return type check.


  Stack trace:                                                                  
  TypeError: Cycle\ORM\Select\QueryBuilder::targetFunc(): Return value must be
  of type callable, array returned                                              
  File: src/Select/QueryBuilder.php:209    
...                     

Triggered by any ->where() call through a Repository's select().

Correct Fix?: Change the return type from callable to array:
private function targetFunc(string $call): array

Version

ORM v2.15.0 & (2.x dev)
PHP v8.3.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions