Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The PHPDoc input parameter for \Drupal\Core\Entity\Query\QueryInterface::condition()
is currently:
@param string|\Drupal\Core\Condition\ConditionInterface $field
However this is an incorrect type, it should be:
@param string|\Drupal\Core\Entity\Query\ConditionInterface
This gets reported by PHPstan version 0.12.58 for the following snippet:
$query = \Drupal::entityQuery('user');
$or_condition = $query->orConditionGroup();
$or_condition->condition('name', 'something%', 'LIKE');
$or_condition->condition('mail', 'something%', 'LIKE');
$query->condition($or_condition);
Resulting in PHPStan violation:
Parameter #1 $field of method Drupal\Core\Entity\Query\QueryInterface::condition() expects Drupal\Core\Condition\ConditionInterface|string, Drupal\Core\Entity\Query\ConditionInterface given.
Comment | File | Size | Author |
---|---|---|---|
#4 | 3219198-4.patch | 742 bytes | guilhermevp |
Issue fork drupal-3219198
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
longwaveComment #4
guilhermevp CreditAttribution: guilhermevp at CI&T commentedSending patch, please review. This seems to be case for 9.3.x as well.
Comment #5
bradjones1I just ran into this with phpstan, with the same message as the IS.
At first I thought the one interface might need to extend the other, but they are indeed different interfaces.
Comment #8
catchCommitted/pushed to 9.3.x and cherry-picked to 9.2.x, thanks!