https://github.com/odan/phpstan-rules
A collection of PHPStan rules
https://github.com/odan/phpstan-rules
Last synced: 8 months ago
JSON representation
A collection of PHPStan rules
- Host: GitHub
- URL: https://github.com/odan/phpstan-rules
- Owner: odan
- License: mit
- Created: 2023-01-15T18:54:12.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-11-06T14:33:18.000Z (over 2 years ago)
- Last Synced: 2025-03-23T22:14:27.870Z (about 1 year ago)
- Language: PHP
- Size: 8.79 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHPStan Rules
[](https://packagist.org/packages/odan/phpstan-rules)
[](LICENSE)
[](https://packagist.org/packages/odan/phpstan-rules/stats)
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:
```neon
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:
```neon
includes:
- vendor/odan/phpstan-rules/rules.neon
```
## Register CyclomaticComplexityRule in phpstan.neon
Add a new service configuration and change the `maxComplexity` as needed.
```neon
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](LICENSE) for more information.