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.  
CommentFileSizeAuthor
#4 3219198-4.patch742 bytesguilhermevp

Issue fork drupal-3219198

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hideaway created an issue. See original summary.

mohit.bansal623 made their first commit to this issue’s fork.

longwave’s picture

Issue tags: +Novice
guilhermevp’s picture

Version: 9.2.x-dev » 9.3.x-dev
Status: Active » Needs review
FileSize
742 bytes

Sending patch, please review. This seems to be case for 9.3.x as well.

bradjones1’s picture

Status: Needs review » Reviewed & tested by the community

I 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.

  • catch committed e2cbb45 on 9.3.x
    Issue #3219198 by guilhermevp, hideaway, bradjones1: PHPdoc parameter...

  • catch committed 9e0fcc4 on 9.2.x
    Issue #3219198 by guilhermevp, hideaway, bradjones1: PHPdoc parameter...
catch’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 9.3.x and cherry-picked to 9.2.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.