PHPackages                             nish/phpstan-namespace-dependency - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. nish/phpstan-namespace-dependency

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nish/phpstan-namespace-dependency
=================================

Extension of PHPStan: Namespace Dependency Rules

v0.2.0(1y ago)31402MITPHPPHP ~7.1 || ~8.0

Since Aug 15Pushed 1y ago2 watchersCompare

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

READMEChangelogDependencies (8)Versions (7)Used By (0)

PHPStan Namespace Dependency Rule Extension
===========================================

[](#phpstan-namespace-dependency-rule-extension)

This package is a PHPStan extension for checking namespace dependencies.

Install
-------

[](#install)

```
composer require --dev nish/phpstan-namespace-dependency

```

How to use
----------

[](#how-to-use)

Add to `phpstan.neon`

```
includes:
  - vendor/nish/phpstan-namespace-dependency/rules.neon

services:
  -
    factory: Nish\PHPStan\NsDepends\DependencyChecker([
      'callee class name prefix': ['caller class name prefix'],
    ], [
      'caller class name prefix': ['callee class name prefix'],
    ])
```

Examples
--------

[](#examples)

### Layered

[](#layered)

```
includes:
  - vendor/nish/phpstan-namespace-dependency/rules.neon

services:
  -
    factory: Nish\PHPStan\NsDepends\DependencyChecker([
      'PDO': ['App\Dao'],
      'App\Dao': ['App\Model'],
      'App\Model': ['App\Page'],
    ], [])
```

### MVC

[](#mvc)

```
includes:
  - vendor/nish/phpstan-namespace-dependency/rules.neon

services:
  -
    factory: Nish\PHPStan\NsDepends\DependencyChecker([
      'App\Model': ['App\Controller'],
      'App\View': ['App\Controller'],
    ], [
      'App\Model': ['App\Util', 'App\ValueObject'],
    ])
```

### DDD

[](#ddd)

```
includes:
  - vendor/nish/phpstan-namespace-dependency/rules.neon

services:
  -
    factory: Nish\PHPStan\NsDepends\DependencyChecker([
      'App\DomainService': ['App\ApplicationService'],
      'App\Domain': ['App\DomainService', 'App\ApplicationService', 'App\Infrastructure'],
      'App\ApplicationService': ['App\Presentation', 'App\Tests'],
    ], [
      'App\Domain\DomainException': ['Exception'],
      'App\Domain': ['DateTimeInterface', 'DateTimeImmutable'],
      'App\DomainService': [],
      'App\ApplicationService': [],
    ])
```

see

### Friend, Package Private

[](#friend-package-private)

```
includes:
  - vendor/nish/phpstan-namespace-dependency/rules.neon

services:
  -
    factory: Nish\PHPStan\NsDepends\DependencyChecker([
      'App\Model\MyModel\InternalClassImpl': ['App\Model\MyModel\InternalClassFactory'],
      'App\Model': ['App\Controller'],
      'App\View': ['App\Controller'],
    ], [])
```

The settings are searched in order from the top, and when the key is hit, the search is stopped there.

`App\Model\MyModel\InternalClassImpl` allows dependencies from `App\Model\MyModel\InternalClassFactory`, not from `App\Controller`.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance42

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community9

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

Recently: every ~359 days

Total

6

Last Release

468d ago

PHP version history (2 changes)v0.1.0PHP ~7.1

v0.1.4PHP ~7.1 || ~8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d24d51f0161c08e350b46433c98c21ff80d2cc5f22f5648f83a1aafd86bc3f76?d=identicon)[nishimura](/maintainers/nishimura)

---

Top Contributors

[![nishimura](https://avatars.githubusercontent.com/u/146196?v=4)](https://github.com/nishimura "nishimura (25 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/nish-phpstan-namespace-dependency/health.svg)

```
[![Health](https://phpackages.com/badges/nish-phpstan-namespace-dependency/health.svg)](https://phpackages.com/packages/nish-phpstan-namespace-dependency)
```

###  Alternatives

[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87578.8k35](/packages/ticketswap-phpstan-error-formatter)[slam/phpstan-extensions

Slam extension of phpstan

702.5M74](/packages/slam-phpstan-extensions)[ramsey/devtools

A Composer plugin to aid PHP library and application development.

7134.7k26](/packages/ramsey-devtools)[johnbillion/wp-compat

PHPStan extension to help verify that your PHP code is compatible with a given version of WordPress

24115.0k10](/packages/johnbillion-wp-compat)

PHPackages © 2026

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