odan / phpstan-rules
PHPStan rules
Installs: 2 487
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 0
Type:phpstan-extension
Requires
- php: ~8.2 || ~8.3 || ~8.4
- phpstan/phpstan: ^1 || ^2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- nikic/php-parser: ^4.13.0
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan-phpunit: ^1 || ^2
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3
This package is auto-updated.
Last update: 2025-05-27 18:21:22 UTC
README
A collection of PHPStan rules.
Requirements
- PHP 8.2+
Installation
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
Register CyclomaticComplexityRule in phpstan.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
Rules
- AssignmentInConditionRule
- YodaConditionRule
- CyclomaticComplexityRule
License
The MIT License (MIT). Please see License File for more information.