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
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
mohit_aghera CreditAttribution: mohit_aghera at PreviousNext commentedComment #4
smustgrave CreditAttribution: smustgrave at Mobomo commentedSeems like a simple change.
Comment #5
smustgrave CreditAttribution: smustgrave at Mobomo commentedNot sure if it will need a follow up for IF that should be allowed but documentation should match what's allowed.
Comment #6
catchAdding 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!
Comment #8
catch