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(8mo ago)13861[1 PRs](https://github.com/DimionX/phpstan-rules/pulls)MITPHPPHP ^8.0CI passing

Since Nov 30Pushed 8mo 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 1w 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

34

—

LowBetter than 74% of packages

Maintenance59

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

260d 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.5k60.6M10.5k](/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)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67475.0M1.6k](/packages/phpstan-phpstan-doctrine)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79378.2M2.5k](/packages/phpstan-phpstan-symfony)[spaze/phpstan-disallowed-calls

PHPStan rules to detect disallowed method &amp; function calls, constant, namespace, attribute, property &amp; superglobal usages, with powerful rules to re-allow a call or a usage in places where it should be allowed.

33923.4M632](/packages/spaze-phpstan-disallowed-calls)[staabm/phpstan-dba

2962.6M2](/packages/staabm-phpstan-dba)

PHPackages © 2026

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