Please note that this website section is under development as of June 2020. The plan is to write about development of custom extensions in much more detail. Thanks for understanding.
PHPStan’s behavior can be customized in various ways.
Custom rules #
PHPStan allows writing custom rules to check for specific situations in your own codebase.
Error formatters #
PHPStan outputs errors via so-called error formatters. You can implement your own format.
Class reflection extensions #
Classes in PHP can expose “magic” properties and methods decided in run-time using class methods like
__call. Because PHPStan is all about static analysis (testing code for errors without running it), it has to know about those properties and methods beforehand.
Dynamic return type extensions #
If the return type of a method is not always the same, but depends on an argument passed to the method, you can specify the return type by writing and registering an extension.
Type-specifying extensions #
These extensions allow you to specify types of expressions based on certain type-checking function and method calls, like