Allows to generate phpstan config with ignores list based on phpstan report (some kind of baseline)
Steps to create baseline ignores list:
- Run phpstan to create errors list file:
vendor/bin/phpstan analyse --memory-limit=-1 -l3 --error-format=json > phpstan-l3.json
. You should note--error-format=json > phpstan-errors-list.json
here, that's used to produce JSON of errors and put them to filephpstan-errors-list.json
. - Run script to generate phpstan ignores config:
php phpstan-ignore.php phpstan-errors-list.json > phpstan-ignore-config.neon
. You should notephpstan-errors-list.json
— that's JSON you used on the previous step; and alsophpstan-ignore-config.neon
— that's where generated phpstan config will be written to. - Include newly generated config to your main config file — add
phpstan-ignore-config.neon
toincludes
section of your main config. If you don't have a config file, or there is noincludes
section currently, here is the example:phpstan.neon
:
includes:
- phpstan-ignore-config.neon
That's it!