PHPStan is a static analyzer for PHP that finds bugs in your code without running it. Created by OndΕej Mirtes, PHPStan scales from level 0 (basic) to level 9 (strictest), letting teams adopt static typing gradually.
The tool understands generics, conditional types, and PHPDoc annotations beyond what the PHP language itself supports, catching impossible nulls, dead code, mismatched array shapes, and unsafe casts long before they reach production.
Static analysis tool for PHP. Finds bugs without running code. Type inference at level 9.
β¨ Features
Start permissive, ratchet up strictness. Each level adds new categories of checks.
Supports template parameters in PHPDoc. Collection<T>, Result<T,E>, function signatures with generics.
Tracks narrowed types through conditionals. Knows that after instanceof, the variable is the asserted type.
Framework-aware extensions for Laravel, Symfony, Doctrine, WordPress. Understands magic methods.
Suppress legacy errors in a baseline file. New code starts strict; old code stays unblocked.