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

0.2.0 2025-05-25 13:27 UTC

This package is auto-updated.

Last update: 2025-05-27 18:21:22 UTC


README

Latest Version on Packagist Software License Total Downloads

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.