PHP › Static Analysis (PHPStan & Psalm)
What is a baseline file in PHPStan, and how does it help a team adopt static analysis on an existing project without needing to fix every single issue immediately?
IntermediateAnswer
A baseline file records every currently existing issue that static analysis finds in a codebase at a specific point in time, effectively telling the tool to ignore those specific already known issues going forward, while still reporting any brand new issue introduced afterward, which lets a team immediately start enforcing static analysis on all new code being written without first needing to pause everything and fix potentially hundreds of preexisting issues throughout an older, large codebase all at once.
vendor/bin/phpstan analyse --generate-baselineReal-world example A team adopting PHPStan on a five year old codebase generates a baseline capturing the several hundred existing issues, then configures their continuous integration pipeline to fail only on any brand new issue introduced in future pull requests, letting them adopt the tool immediately without a massive one time cleanup effort.