Fix PHPStan issue on ConditionInterface of \Drupal\Core\Database

Created on 28 February 2023, over 1 year ago
Updated 2 March 2023, over 1 year ago

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

📌 Task
Status

Fixed

Version

10.1

Component
Database 

Last updated less than a minute ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇮🇳India mohit_aghera Rajkot

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024