PHPStan Static Analysis Tool
github.com
3
Leaving SiteNav
External Link Disclaimer
You are about to visit github.com. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
PHPStan is a free and open-source static analysis tool for PHP that finds bugs and improves code quality by analyzing code without running it. Created by Ondrej Mirtes in 2016, PHPStan is one of the most popular PHP quality tools, used by major PHP projects including Symfony, Doctrine, PHPUnit, Laravel, and Composer. Key features: type checking: PHPStan performs deep type analysis far beyond what PHP's runtime type system provides. It tracks types of variables, return values, and expressions through control flow (if/else, loops, try/catch), catching type mismatches that PHP would only detect at runtime. Rule levels: PHPStan uses 10 progressive levels (0-9), where each level adds stricter checks. Level 0 checks basic code (e.g., calling a method that does not exist), while Level 9 performs the most thorough analysis including generic types and complex type narrowing. This allows teams to adopt PHPStan incrementally. PHPDoc types: fully supports PHPDoc type annotations (param, return, var, property) including union types, intersection types, nullable types, callable types, and generics (introduced in PHP 7.1 era before native support). Generic types: supports PHPDoc generic types for classes and methods, enabling type-safe collections and repositories. Conditional return types: supports conditional and type-narrowed return types for more precise analysis. Extensions: PHPStan can be extended with custom rules, and the Pro version (paid) adds features like focusing on bleeding-edge issues, generic inheritance checking, and tracking count of elements in arrays. Baseline: generates a baseline of current errors so new code can be checked without fixing all legacy issues at once. Integration: CI/CD pipelines, Git hooks, IDE plugins. Cross-platform. MIT.
Statistics
3
Views
0
Clicks
0
Like
0
Dislike