Custom Rules

PHPStan allows writing custom rules to check for specific situations in your own codebase.

Your rule class needs to implement the PHPStan\Rules\Rule interface and registered as a service in the configuration file:

class: MyApp\PHPStan\Rules\DefaultValueTypesAssignedToPropertiesRule
- phpstan.rules.rule

For inspiration on how to implement a rule turn to src/Rules to see a lot of built-in rules.

Edit this page on GitHub

© 2016–2020 Petra Mirtesová