PHP static analysis that finds bugs without running your code
open sourceMITfree
PHPStan is a static analysis tool for PHP: it scans a whole codebase and reports bugs such as calls to undefined methods, wrong argument types and dead branches, even in code no test covers, without running it. Rule levels let a team start loose and tighten over time, and a baseline file records existing errors so new code can be held to a higher standard at once. PHPDoc types add generics, array shapes and other types PHP itself lacks. Extensions cover Symfony, Laravel, Doctrine, PHPUnit and other frameworks' magic, and teams run it on their machines and in CI. It installs with Composer as phpstan/phpstan. PHPStan Pro, a paid subscription, adds a web UI for browsing errors and continuous analysis in the background.
Problems it solves
- find bugs in a legacy PHP codebase that has almost no tests
- fail CI when a PHP change calls a method that doesn't exist
- add stricter type checking to a Laravel app gradually without fixing thousands of errors first
- catch type errors in PHP before deploying
Features
- whole-codebase static analysis
- rule levels 0 to 10
- baseline for existing errors
- generics and array shapes in PHPDoc
- framework extensions for Symfony, Laravel and Doctrine
- result cache and parallel analysis
- PHPStan Pro web UI
Capabilities
| Has a command line tool | plan not known |
|---|---|
| Takes plugins | plan not known |
Alternatives
The same job
These do what PHPStan does.
- PHP_CodeSniffer Detect and fix coding standard violations in PHP
