Problem/Motivation

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.

Steps to reproduce

To activate the FunctionCallParametersCheck rule we can add the following parameter to phpstan.neon.dist:

parameters:
  checkFunctionArgumentTypes: true

Proposed resolution

Review detected errors and fix them in child issues.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3404246

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:

Comments

mstrelan created an issue. See original summary.

mstrelan’s picture

mstrelan changed the visibility of the branch 11.x to hidden.

mstrelan’s picture

Status: Active » Needs work

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

mstrelan’s picture

Issue summary: View changes

I don't think we need checkArgumentsPassedByReference here as that isn't affected by strict types (AFAIK).

mstrelan’s picture

Issue summary: View changes

Removed the bit about excluding tests. Tests call out to non-test code, and there can exist errors.

mstrelan’s picture

Title: Fix strict type errors detected by phpstan » [META] Fix strict type errors detected by phpstan
Issue summary: View changes
mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

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

spokje’s picture

@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?

mstrelan’s picture

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

mstrelan’s picture

Issue summary: View changes

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

mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes

Updated remaining tasks and split fixed issues to its own list

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

mstrelan’s picture

Issue summary: View changes

Updated remaining tasks