Quantcast
Viewing all articles
Browse latest Browse all 291721

Start running PHPStan on Drupal core (level 0)

Problem/Motivation

I'm finding more and more incomplete or wrong type hints with PHPStan. We are running PHPStan on our private code base, but it complains about type mismatches due to Drupal core not being documented correctly.

Example:
Parameter #1 $label of method Drupal\Core\TypedData\DataDefinition::setLabel() expects string, Drupal\Core\StringTranslation\TranslatableMarkup given.

Steps to reproduce

Run PHPStan with at least level 5 on a code base that makes use of a lot of core APIs.

Proposed resolution

Start a PHPStan initiative to run a phpstan.neon config on Drupal core itself to figure out problems. We can enable PHPStan runs on the testbot by modifying drupalci.yml and adding a step. That way we prevent regressions for any Drupal core changes in the future.

I propose to start with PHPStan level 0 checks on a fixed list of Drupal core folders. Once level 0 is fully passing on Drupal core we can continue with level 1 in a follow-up issue.

Remaining tasks

Review the merge request and merge the first batch of PHPStan fixes.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

@todo


Viewing all articles
Browse latest Browse all 291721

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>