PHPStan itself generates the baseline since 0.11.17. Use it instead.
Have you used PHPStan, Psalm or Easy Coding Standard on a very old project and got 10 000+ errors?
Do you wish to skip fixing these 10 000 errors and check new code only?
Yes and yes? You'll love SARB.
I found this package by random clicking on meetups on Friends of PHP and reading program of the meetup. One of them was Dave with his SARB - Static Analysis Results Baseliner tool. What an interesting name. In the Czech, I read SRAB, which means coward... what does such tool do?
"SARB is used to create a baseline of these results. As work on the project progresses SARB can take the latest static analysis results, removes those issues in the baseline and report the issues raised since the baseline. SARB does this, in conjunction with it, by tracking lines of code between commits."
Such a simple idea with huge application in practice - amazing! What does it mean? Let me show you on a project:
No stress with the legacy you didn't even write, but full focus on the present moment.
composer require dave-liddament/sarb --dev
# for psalm vendor/bin/psalm --report reports/psalm-result.json vendor/bin/sarb create-baseline reports/psalm-result.json reports/sarb_baseline.json psalm-json # for phpstan vendor/bin/phpstan analyse --error-format json > reports/phpstan-result.json vendor/bin/sarb create-baseline reports/phpstan-result.json reports/sarb_baseline.json phpstan-json
Commit the code
Rerun the static analysis on the latest code
# for psalm vendor/bin/psalm --report reports/psalm-result.json # for phpstan vendor/bin/phpstan analyse --error-format json > reports/phpstan-result.json
# psalm vendor/bin/sarb remove-baseline-results reports/psalm-result.json reports/sarb_baseline.json reports/issues_since_baseline.json # phpstan vendor/bin/sarb remove-baseline-results reports/phpstan-result.json reports/sarb_baseline.json reports/issues_since_baseline.json
You can use this also on EasyCodingStandard:
vendor/bin/easy-coding-standard check src --output-format reports/ecs-result.json vendor/bin/sarb remove-baseline-results reports/ecs-result.json reports/sarb_baseline.json reports/issues_since_baseline.json
The sky is the limit :)
Great job David!