Issue #3615912: Fix phpstan errors when running phpstan from the command line interface

Two separate things stopped phpstan from running outside CI, both in phpstan.neon.

1. The baseline file was never committed. phpstan.neon opens with includes: - phpstan-baseline.neon, but that file exists on no branch, so every command-line run dies during config loading:

File '/[...]/modules/contrib/domain/phpstan-baseline.neon' is missing or is not readable.

CI has been hiding it: the template's .phpstan-base job runs touch $_PHPSTAN_BASELINE_FILENAME before analysing, with the comment "Create an empty baseline if the file does not exist, as this is referenced in the default config file". The include line came from the template's assets/phpstan.neon, which pairs it with that touch; we took the line without the file.

This ships the file, byte-for-byte the content the phpstan job generates for an empty baseline (pulled from the job artifact):

parameters:
	ignoreErrors: []

Shipping the file rather than deleting the include keeps the intended workflow working: the phpstan job publishes phpstan-baseline.neon as a downloadable artifact so a maintainer can adopt existing errors by dropping it into the repo. With the include gone that artifact would be inert.

2. scanDirectories hardcoded the docroot depth. ../../../../vendor/drush/drush/src-symfony-compatibility assumes the module sits exactly four levels below the project root. That holds for <root>/web/modules/contrib/domain, but the steps to reproduce say modules/contrib/domain, and where the docroot is the project root that path resolves one level above the root:

Scanned directory /[...]/vendor/drush/drush/src-symfony-compatibility does not exist.

So fixing only the baseline would have moved the error rather than cleared it for that layout. The entry is dropped rather than made conditional (neon has no conditional paths): the directory holds only three Drush Symfony compatibility classes -- BufferedConsoleOutput, LessStrictArgvInput, IndiscriminateInputDefinition -- and this module references none of them. Its Drush commands use Drush\Commands\DrushCommands and Drush\Commands\AutowireTrait, both under drush's PSR-4 src/, plus Symfony Console classes from vendor. The entry looks like it was copied from core's own phpstan config.

Verified by reconstructing both layouts against this branch:

  • <root>/web/modules/contrib/domain — before: fails on the missing baseline. After: config loads, analysis completes.
  • <root>/modules/contrib/domain — before: fails on the missing baseline, and with a baseline supplied by hand it then fails on scanDirectories. After: config loads, analysis completes.
  • Identical error set with and without scanDirectories, so dropping it changes no result.
  • The CI sequence still works end to end: touch becomes a no-op, then rm, then --generate-baseline regenerates the artifact.
  • phpcs with the templates' drupal-contrib-project ruleset: 441 files, no errors or warnings.

3.x and 3.0.x carry the identical include with no file and the same scanDirectories entry, so the same fix applies there whenever a backport is wanted.

Edited by Frank Mably

Merge request reports

Loading