shipmonk / phpstan-baseline-per-identifier
Error formatter for PHPStan that generates baseline files per each error identifier
Installs: 778
Dependents: 0
Suggesters: 0
Security: 0
Stars: 33
Watchers: 2
Forks: 0
Open Issues: 2
Type:phpstan-extension
Requires
- php: ^8.0
- nette/neon: ^3.3.3 || ^4.0
- phpstan/phpstan: ^1.11.5
Requires (Dev)
- editorconfig-checker/editorconfig-checker: 10.6.0
- ergebnis/composer-normalize: 2.43.0
- phpstan/phpstan-phpunit: 1.4.0
- phpstan/phpstan-strict-rules: 1.6.0
- phpunit/phpunit: 9.6.20
- shipmonk/composer-dependency-analyser: 1.7
- shipmonk/name-collision-detector: 2.1.1
- shipmonk/phpstan-rules: 3.1.0
- slevomat/coding-standard: 8.15.0
This package is auto-updated.
Last update: 2024-11-21 17:34:24 UTC
README
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
Installation:
composer require --dev shipmonk/phpstan-baseline-per-identifier
Usage
Setup baselines loader, other files will be placed beside that file:
# phpstan.neon.dist includes: - baselines/loader.neon # instead of traditional phpstan-baseline.neon
Run native baseline generation and split it into multiple files via our script:
vendor/bin/phpstan --generate-baseline=baselines/loader.neon && vendor/bin/split-phpstan-baseline baselines/loader.neon
(optional) You can simplify generation with e.g. composer script:
{ "scripts": { "generate:baseline:phpstan": [ "@phpstan --generate-baseline=baselines/loader.neon", "@split-phpstan-baseline baselines/loader.neon" ] } }
Legacy usage
Setup where your baseline files should be stored and include its loader:
# phpstan.neon.dist includes: - vendor/shipmonk/phpstan-baseline-per-identifier/extension.neon # or use extension-installer - 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" ] } }
Cli options
--tabs
to use tabs as indents in generated neon files
Migrating from single baseline
rm phpstan-baseline.neon
(and remove its include fromphpstan.neon.dist
)mkdir baselines
touch baselines/loader.neon
(and include it inphpstan.neon.dist
)- Run the split script from above