Needs work
Project:
Drupal core
Version:
main
Component:
other
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
26 Nov 2023 at 22:28 UTC
Updated:
16 Feb 2026 at 06:04 UTC
Jump to comment: Most recent
Before we can add declare(strict_types=1) to existing code we need to fix strict type errors. We can detect some of these with phpstan, via the FunctionCallParametersCheck rule.
To activate the FunctionCallParametersCheck rule we can add the following parameter to phpstan.neon.dist:
parameters:
checkFunctionArgumentTypes: true
Review detected errors and fix them in child issues.
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
mstrelan commentedThere are 271 errors identified in the code quality report, or 266 in the test report.
Comment #5
mstrelan commentedNot sure the best way to split this, so just started working on it. We can cherry-pick each fix to separate issues if we need to split it.
Comment #6
mstrelan commentedI don't think we need
checkArgumentsPassedByReferencehere as that isn't affected by strict types (AFAIK).Comment #7
mstrelan commentedRemoved the bit about excluding tests. Tests call out to non-test code, and there can exist errors.
Comment #8
mstrelan commentedComment #9
mstrelan commentedComment #10
mstrelan commentedComment #11
mstrelan commentedComment #12
mstrelan commentedComment #13
mstrelan commentedComment #14
mstrelan commentedComment #15
mstrelan commentedI rebased the MR hoping to see the number of errors go down since #3473228: Fix more var and param docs identified by phpstan, but it's actually gone up from 381 to 436.
Comment #16
spokje@mstrelan: Meh! Are the new additions all in the var/param docs region? Or were there a lot of additions to the baseline during that period?
Comment #17
mstrelan commented@spokje I didn't look at what they were. It wouldn't have been baseline additions, because these issues are only reported once the config is changed as per the MR here.
Comment #18
mstrelan commentedphpstan-drupal v2.0.6 fixed some issues with entity reference formatters, removing that from remaining tasks.
There are still 657 errors so we need some more child issues. Opened #3542137: Fix strict type issues in SchemaCheckTrait to resolve 112 of them.
Comment #19
mstrelan commentedComment #20
mstrelan commentedComment #21
mstrelan commentedUpdated remaining tasks and split fixed issues to its own list
Comment #23
mstrelan commentedUpdated remaining tasks