ossobuffo / drupal-phpstan-check
Composer command to run Drupal-specific phpstan check on Drupal 11+, based on mglaman/drupal-check.
Package info
codeberg.org/ossobuffo/drupal-phpstan-check
Type:composer-plugin
pkg:composer/ossobuffo/drupal-phpstan-check
Requires
- composer-plugin-api: ^2.0
- composer/installers: ^2.3
- drupal/core-composer-scaffold: >=11.1.0
- mglaman/phpstan-drupal: ^2.1
- symfony/process: ^7.1 || ^8.0
Requires (Dev)
Suggests
- phpro/grumphp: Allow git integration with GrumPHP.
This package is not auto-updated.
Last update: 2026-08-28 17:23:06 UTC
README
This package provides a composer command to run PHPStan against your Drupal codebase, using Drupal-specific rulesets developed by Matt Glaman. This is intended to replace mglaman/drupal-check, which, at the time of this writing, has not had an update in over two years.
Installation
Just install this as you would any other composer package. You probably want to install this as a dev dependency, since it shouldn’t run in production.
composer install --dev ossobuffo/drupal-phpstan-check
Invocation
composer drupal-phpstan:check path/to/file.php
This will invoke PHPStan to run Drupal-specific checks on file.php. You can
specify a directory rather than a singular file, and PHPStan will run against
all PHP files it finds within that directory. You can also specify multiple
files and/or directories, and PHPStan will run against each one.
Options
--format=[raw|table|checkstyle|json|junit]
: Affects how output is displayed on the screen. If no --format option
is specified, it will default to ‘table’.
--no-progress
: Suppresses the progress bar.
GrumPHP Integration
This package has built-in integration for GrumPHP, which was forked from
johnatas-x/grumphp-drupal-check.
To configure for use with GrumPHP, you will need to edit your root
grumphp.yml file. Under the top grumphp key, add the following:
extensions:
- ossobuffo\DrupalPhpstanCheck\GrumPhp\ExtensionLoader
Then under the grumphp.tasks key:
drupal_phpstan_check:
triggered_by: ['php', 'module', 'inc', 'install', 'theme']
Then whenever you make a git commit, composer drupal-phpstan:check will be run
against all of the PHP files in the commit.