Skip to main content

Adding PHPStan to a Drupal site

PHPStan is a static code analysis tool that you can add to your Drupal site. It will pick up issues as you code, so they don't get to production.

The basics covered in this video are:

  1. Follow the instructions to install it on Drupal.org
  2. Create your phpstan.neon
  3. Talk about some of the issues you might have

A sample settings file, roughly covered in the video, is:

parameters:
    level: 7
    paths:
        - web/modules/custom
        - web/themes/custom

    checkMissingIterableValueType: false
    reportUnmatchedIgnoredErrors: true