Split your PHPStan baseline into multiple files, one per error identifier:
baselines/
├─ loader.neon
├─ empty.notAllowed.neon
├─ foreach.nonIterable.neon
├─ identical.alwaysFalse.neon
└─ if.condNotBoolean.neon
Each file looks like this:
# total 1 error
parameters:
ignoreErrors:
-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
path: ../app/index.php
count: 1
composer require --dev shipmonk/phpstan-baseline-per-identifier
Use official extension-installer or just load the extension:
includes:
- vendor/shipmonk/phpstan-baseline-per-identifier/extension.neon
Setup where your baseline files should be stored and include its loader:
# phpstan.neon.dist
includes:
- baselines/loader.neon
parameters:
shipmonkBaselinePerIdentifier:
directory: %currentWorkingDirectory%/baselines
indent: ' '
Prepare composer script to simplify generation:
{
"scripts": {
"generate:baseline:phpstan": [
"rm baselines/*.neon",
"touch baselines/loader.neon",
"@phpstan analyse --error-format baselinePerIdentifier"
]
}
}
Regenerate the baselines:
composer generate:baseline:phpstan
rm phpstan-baseline.neon
(and remove its include fromphpstan.neon.dist
)mkdir baselines
composer generate:baseline:phpstan