PHPackages                             odan/phpstan-rules - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. odan/phpstan-rules

ActivePhpstan-extension[Validation &amp; Sanitization](/categories/validation)

odan/phpstan-rules
==================

PHPStan rules

0.2.0(11mo ago)56.7k↓32.7%1MITPHPPHP ~8.2 || ~8.3 || ~8.4

Since Jan 15Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/odan/phpstan-rules)[ Packagist](https://packagist.org/packages/odan/phpstan-rules)[ RSS](/packages/odan-phpstan-rules/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (1)

PHPStan Rules
=============

[](#phpstan-rules)

[![Latest Version on Packagist](https://camo.githubusercontent.com/69541af1e114a2f91442c0c64cfbe638cedbb9a1efdaaeb975cbbd1f1e2d508e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6f64616e2f7068707374616e2d72756c65732e737667)](https://packagist.org/packages/odan/phpstan-rules)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/b6b5da45dba90893d5827592bd3d59dcd4e6602a9bc4ad0b8e7a3e0e8042e2c0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f64616e2f7068707374616e2d72756c65732e737667)](https://packagist.org/packages/odan/phpstan-rules/stats)

A collection of PHPStan rules.

Requirements
------------

[](#requirements)

- PHP 8.2+

Installation
------------

[](#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
-------------------------------------------------

[](#register-cyclomaticcomplexityrule-in-phpstanneon)

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
-----

[](#rules)

- AssignmentInConditionRule
- YodaConditionRule
- CyclomaticComplexityRule

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance50

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~860 days

Total

2

Last Release

358d ago

PHP version history (2 changes)0.1.0PHP ~8.0 || ~8.1 || ~8.2

0.2.0PHP ~8.2 || ~8.3 || ~8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/89d408d7f6ed65cdbeba70a2da2d0a8a1135fc37ebc07c44989f509221cc91bd?d=identicon)[odan](/maintainers/odan)

---

Top Contributors

[![odan](https://avatars.githubusercontent.com/u/781074?v=4)](https://github.com/odan "odan (12 commits)")

---

Tags

PHPStanrules

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/odan-phpstan-rules/health.svg)

```
[![Health](https://phpackages.com/badges/odan-phpstan-rules/health.svg)](https://phpackages.com/packages/odan-phpstan-rules)
```

###  Alternatives

[ruler/ruler

A simple stateless production rules engine for modern PHP.

1.1k794.6k3](/packages/ruler-ruler)[mi-schi/phpmd-extension

Contains extra phpmd rules from clean code book and the best practices of my experiences.

40882.0k5](/packages/mi-schi-phpmd-extension)[suin/php-cs-fixer-rules

A Rule set for PHP-CS-Fixer mainly targeting PHP 7.1 or higher.

13116.7k3](/packages/suin-php-cs-fixer-rules)[hybridlogic/validation

A simple, extensible validation library for PHP with support for filtering and validating any input array along with generating client side validation code.

641.1k](/packages/hybridlogic-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
