PHPStan scans PHP codebases for errors and suspicious patterns before tests run. It runs locally or in continuous integration.
Overview
PHPStan is a static analysis tool for PHP that looks for bugs by reasoning about code without executing it. The goal is to catch whole classes of mistakes early, including in branches that tests may not exercise.
You can run it on your machine or in CI so problems are found before they reach production. Rule levels let you adopt stricter checks gradually instead of drowning in errors on the first run. A baseline feature lets older codebases start improving without fixing everything at once.
Extensions cover popular frameworks such as Symfony, Laravel, and Doctrine, including code that relies on magic methods and properties. PHPDoc types can express generics, array shapes, and similar ideas ahead of native PHP support.
PHPStan Pro is a paid add-on with a web UI for browsing errors, continuous background analysis, and editor integration. The core analyzer remains free to run from the command line.
Key features
- Whole-project static scanning
- Gradual rule levels
- Baseline for legacy code
- Framework extensions
- PHPDoc-driven type checks
- Online playground
- Optional PHPStan Pro UI
Use cases
- CI gates before deploy
- Finding bugs in rarely run branches
- Gradual cleanup of legacy PHP
- Framework-specific type checking