PHPackages                             dimionx/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. [Testing &amp; Quality](/categories/testing)
4. /
5. dimionx/phpstan-rules

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

dimionx/phpstan-rules
=====================

Rule for PHPStan that detects when production code depends on classes from Composer dev-dependencies, with flexible configuration to selectively allow certain classes or namespaces where needed.

1.0.2(5mo ago)1131MITPHPPHP ^8.0CI passing

Since Nov 30Pushed 5mo agoCompare

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

READMEChangelog (3)Dependencies (10)Versions (4)Used By (0)

PHPStan Extension Rule
======================

[](#phpstan-extension-rule)

[PHPStan](https://github.com/phpstan/phpstan) rule to detect usage of Composer dev-dependency classes in production code, with powerful configuration to re-allow specific classes or namespaces in places where they should be allowed.

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

[](#installation)

Install the extension using [Composer](https://getcomposer.org/):

```
composer require --dev dimionx/phpstan-rules
```

Manual installation
-------------------

[](#manual-installation)

For manual installation, add this to your `phpstan.neon`:

```
includes:
    - vendor/dimionx/phpstan-rules/extension.neon
```

Ignoring Errors
---------------

[](#ignoring-errors)

Only ignore errors for code that is **never executed in production**. Typical examples include:

- **Test files** (`*Test.php`, `*/Tests/*`, `*/tests/*`)
- **Test helpers and utilities** used exclusively in tests
- **Development-only scripts and tools**
- **Fixture factories** used solely for testing
- **Code generation scripts** used during development

```
# phpstan.neon
parameters:
  ignoreErrors:
    # Ignore files that are allowed to use dev-packages
    -
      identifier: dev.packageUsedInProductionRule
      path: '*/Tests/*'
```

Features
--------

[](#features)

- **Detects accidental usage** of dev-dependency classes in production code
- **Configurable autoload types** (PSR-4, PSR-0, classmap, files)
- **Namespace-based detection** for comprehensive coverage
- **Flexible allowlists** for legitimate cross-environment usage
- **`composer.lock` analysis** for accurate dependency mapping

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance70

Regular maintenance activity

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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 ~0 days

Total

3

Last Release

169d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7352966?v=4)[Andrey](/maintainers/dimionx)[@DimionX](https://github.com/DimionX)

---

Top Contributors

[![DimionX](https://avatars.githubusercontent.com/u/7352966?v=4)](https://github.com/DimionX "DimionX (8 commits)")

---

Tags

composerPHPStanstatic analysisphpstan-ruledev-dependencies

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[larastan/larastan

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

6.4k43.5M5.2k](/packages/larastan-larastan)[ekino/phpstan-banned-code

Detected banned code using PHPStan

2925.6M92](/packages/ekino-phpstan-banned-code)[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.

3462.2M52](/packages/shipmonk-dead-code-detector)[szepeviktor/phpstan-wordpress

WordPress extensions for PHPStan

3287.8M898](/packages/szepeviktor-phpstan-wordpress)[staabm/phpstan-dba

2912.3M2](/packages/staabm-phpstan-dba)[staabm/phpstan-todo-by

1991.8M55](/packages/staabm-phpstan-todo-by)

PHPackages © 2026

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