PHPStan is a static analysis tool for PHP, created by Ondřej Mirtes, designed to identify errors in code without executing it. By analyzing code, PHPStan can detect issues like calling a method on a possibly null variable or type mismatches, leading to improved code quality and fewer runtime errors. It supports various PHP features, including generics, array shapes, and checked exceptions, using PHPDocs to understand advanced code patterns.
PHPStan offers different levels of analysis (0-9, with an experimental level 10), allowing gradual adoption based on project needs; lower levels are less strict, while higher levels enforce more rigorous checks. It can be integrated into CI/CD pipelines to automate code quality checks and is compatible with various frameworks like Symfony and Laravel (using Larastan). PHPStan is open-source, but a professional version, PHPStan Pro, is available with added features such as a web UI for error inspection and continuous background analysis.
PHPStan Pro is a paid add-on with a 30-day free trial; after that, it costs €7/month for individual developers or €70/month for teams of up to 25 members. Paying annually provides a discount. PHPStan Pro enhances the open-source version with features like a web UI for browsing errors and continuous analysis, scanning changed files in the background.
PHPStan is readily available and can be installed via Composer. It supports integration with IDEs like PhpStorm, providing real-time feedback during development. It is used by different users such as Mid Size Businesses, Enterprises, and Freelancers.