A collection of PHPStan rules.
- PHP 8.2+
composer require odan/phpstan-rules --dev
To use the PHPStan rules, you need to include the classes
in your PHPStan configuration file phpstan.neon
.
Just pick the rule(s) you want:
rules:
- Odan\PHPStan\Rules\AssignmentInConditionRule
- Odan\PHPStan\Rules\YodaConditionRule
If you want to include all rules, you have to include rules.neon
in your project's PHPStan config:
includes:
- vendor/odan/phpstan-rules/rules.neon
Add a new service configuration and change the maxComplexity
as needed.
services:
-
class: Odan\PHPStan\Rules\CyclomaticComplexityRule
arguments:
maxComplexity: 3
tags:
- phpstan.rules.rule
Note: If exists, remove the rule Odan\PHPStan\Rules\CyclomaticComplexityRule
from the rules:
section in phpstan.neon
- AssignmentInConditionRule
- YodaConditionRule
- CyclomaticComplexityRule
The MIT License (MIT). Please see License File for more information.