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

Since Nov 30Pushed 7mo 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 today

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

35

—

LowBetter than 77% of packages

Maintenance65

Regular maintenance activity

Popularity18

Limited adoption so far

Community7

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

214d 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.5k55.4M8.4k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[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.

4853.5M91](/packages/shipmonk-dead-code-detector)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[ekino/phpstan-banned-code

Detected banned code using PHPStan

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

33422.6M549](/packages/spaze-phpstan-disallowed-calls)

PHPackages © 2026

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