Problem/Motivation

Currently PHPStan throws following error when following condition is given in select query

$items = $this->database->select($this->queueTable, 'q');
$items->condition('created', $this->requestTime - 86400, '<');

Error is given below:
parameter #2 $value of method Drupal\Core\Database\Query\ConditionInterface::condition() expects array|Drupal\Core\Database\Query\SelectInterface|string|null, int given.

Docblock of Drupal\Core\Database\Query\ConditionInterface's condition() method suggests that argument can be either string, null, array etc.
However, we can also pass integer etc. in the condition value.

Steps to reproduce

Add a database condition statement given in problem/motivation step.
Run phpstan check.

Proposed resolution

- Update proper docblock to allow integer value as well.

Remaining tasks

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Issue fork drupal-3344903

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

mohit_aghera created an issue. See original summary.

mohit_aghera’s picture

Status: Active » Needs review
Issue tags: +Novice, +docblock
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Seems like a simple change.

smustgrave’s picture

Not sure if it will need a follow up for IF that should be allowed but documentation should match what's allowed.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Adding int here seems good, the line below even says scalar which implies both string and int.

Committed dc6c95f and pushed to 10.1.x. Thanks!

  • catch committed dc6c95f6 on 10.1.x
    Issue #3344903 by mohit_aghera: Fix PHPStan issue on ConditionInterface...
catch’s picture

Status: Fixed » Closed (fixed)

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