Menu

Extension Library

Unique feature of PHPStan is the ability to define and statically check “magic” behaviour of classes - accessing properties that are not defined in the class but are created in __get and __set and invoking methods using __call.

PHPStan also allows writing custom rules for situations that aren’t objective bugs or other problems in the code, but allow people avoid tricky situations or enforce the way they want to write their code. These custom rules take advantage of the abstract syntax tree, advanced type inference engine, PHPDoc parser, and class reflection data.

Learn more about writing custom extensions »

Installing extensions #

Users can install various PHPStan extensions to enhance the capabilities of the static analyser. Many extensions already support phpstan/extension-installer Composer plugin, so in order to enable an extension, it’s sufficient to require it in your composer.json:

composer require --dev phpstan/extension-installer && \
composer require --dev phpstan/phpstan-beberlei-assert

If you can’t or don’t want to use phpstan/extension-installer, include the extension’s configuration file manually in the includes section:

includes:
- vendor/phpstan/phpstan-beberlei-assert/extension.neon

Official extensions #

Check out phpstan-strict-rules repository for extra strict and opinionated rules for PHPStan.

Check out as well phpstan-deprecation-rules for rules that detect usage of deprecated classes, methods, properties, constants and traits!

Framework-specific extensions #

Unofficial extensions #

3rd party rules #

Find more on Packagist!

Edit this page on GitHub

© 2016–2020 Ondřej Mirtes