Problem/Motivation

Both when PHPStan analysis was introduced for Drupal, #3178534: Start running PHPStan on Drupal core (level 0), and when the rule level was upped to 1, #3190406: Update PHPStan to level 1, we added a baseline of errors that helped us to get the tool in, delegating to follow-ups the clean up of the baseline itself.

In those cases, the baseline consisted of approximately 1k errors.

Now, PHPStan level 2 rule reports (Nov 2022) more than 9k additional errors. Adding these to the baseline would make it hard to manage, so it ws suggested to start addressing PHPStan L2 fixes BEFORE actually bumpling the rule level in PHPStan configuration.

Proposed resolution

Use this meta to report the status of L2 PHPStan errors, open child issues to fix them until a reasonable (tbd) number is reached that could be added to the baseline.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

mondrake created an issue. See original summary.

mondrake’s picture

StatusFileSize
new243 bytes

A one-line patch to report the current status wrt PHPstan L2 errors. Please note that due to the large report, it is not fully displayed on the test results page. You need to go to the Jenkins job to get all of the details.

mondrake’s picture

StatusFileSize
new1.12 KB
mondrake’s picture

StatusFileSize
new1.12 KB
mondrake’s picture

StatusFileSize
new4.73 KB
mondrake’s picture

It looks like adding phpstan/phpstan-phpunit we would reduce approx 1k errors caused by unrecognized mocks

kingdutch’s picture

Added issue for L1 as related since I had a hard time figuring out the history of things and this aids in discovery.

andypost’s picture

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bbrala’s picture

Not sure about this web of issues, but think this is relevant here:

How to change signatures in interfaces has been documented: #3354524: Document how to add additional parameters to interface methods

mstrelan’s picture

Providing an update on the current stats:

HEAD (Level 1): 9606
HEAD (Level 2): 15067 (+5461)
HEAD + 3325057 (Level 2) 14636 (+5030)

When this issue was opened there were 9000+ additional errors, now we're down to around 5000.

EDIT: And another 906 errors fixed by adding jangregor/phpstan-prophecy

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.