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)32632MITPHPPHP ~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 2w 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

33

—

LowBetter than 72% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

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

Recently: every ~359 days

Total

6

Last Release

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

[deptrac/deptrac

Deptrac is a static code analysis tool that helps to enforce rules for dependencies between software layers.

3.0k9.8M297](/packages/deptrac-deptrac)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

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

Instant Upgrade and Automated Refactoring of any PHP code

136411.0k14](/packages/rector-rector-src)[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87766.6k61](/packages/ticketswap-phpstan-error-formatter)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

39255.4k37](/packages/ec-europa-toolkit)[worksome/coding-style

Worksomes coding style

49826.1k69](/packages/worksome-coding-style)

PHPackages © 2026

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