PHPStan is a static analysis tool for PHP that identifies errors without executing an application’s code. It examines source files to find type mismatches, undefined methods, invalid function calls and other problems that might otherwise escape detection until runtime.
PHPStan is particularly useful for gradually introducing stricter checks into an existing application. Developers can begin with relatively permissive analysis and progressively enable more demanding checks. A baseline mechanism allows previously identified errors to be recorded separately, so newly introduced problems remain visible without requiring every historical issue to be corrected immediately.
This is free and open source software.
Key Features
- Provides eleven cumulative analysis levels, ranging from basic checks to strict type verification.
- Detects undefined classes, functions, methods, properties and variables.
- Checks function arguments, return types, property assignments and type compatibility.
- Understands PHPDoc annotations, generics, templates, array shapes and conditional return types.
- Performs control-flow analysis to identify unreachable code and impossible conditions.
- Checks for incorrect assumptions about nullable values and mixed types.
- Supports baseline files for suppressing existing errors while identifying new violations.
- Allows individual errors to be ignored using configurable identifiers and suppression rules.
- Supports custom analysis rules and extensions for frameworks, libraries and application-specific behaviour.
- Provides structured output formats, including JSON and JUnit, for continuous integration systems.
- Uses result caching to avoid repeating unnecessary analysis.
- Supports configuration through NEON files, including separate settings for analysed paths and rule levels.
- Offers experimental checks through its bleeding-edge configuration.
- Can validate declared exceptions using checked-exception analysis.
Website: github.com/phpstan/phpstan
Support:
Developer: PHPStan s.r.o.
License: MIT License
PHPStan is written in PHP. Learn PHP with our recommended free books and free tutorials.
Related Software
| PHP Linters | |
|---|---|
| PHPStan | PHP static analysis tool |
| PHP Coding Standards Fixer | Fixes your code to follow the standards |
| Mago | Extremely fast PHP linter, formatter, and static analyzer |
| Psalm | Static analysis tool |
| Phan | Static analyzer for PHP |
| PHP_CodeSniffer | Tokenizes PHP files and detects violations |
| Deptrac | Static code analysis tool for PHP projects |
| PHP Parallel Lint | Checks the syntax of PHP files in parallel |
| PHPLint | Speed up linting PHP files |
| PHPCompatibility | Coding standard for PHP_CodeSniffer |
| PHPArkitect | Define architectural rules as executable PHP code |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.