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(1y ago)58.3k↓56.7%1MITPHPPHP ~8.2 || ~8.3 || ~8.4

Since Jan 15Pushed 1y 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 2w 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

38

—

LowBetter than 83% of packages

Maintenance43

Moderate activity, may be stable

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity55

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

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

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k60.6M10.4k](/packages/larastan-larastan)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

5014.2M111](/packages/shipmonk-dead-code-detector)[orrison/meliorstan

Provides PHPStan rules for improved code quality by detecting code smells and possible issues. In addition to enforcing particular naming and code style conventions to reduce bike-shedding.

1920.1k6](/packages/orrison-meliorstan)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

16132.2k4](/packages/calebdw-larastan)

PHPackages © 2026

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