nish/phpstan-namespace-dependency
最新稳定版本:v0.2.0
Composer 安装命令:
composer require nish/phpstan-namespace-dependency
包简介
Extension of PHPStan: Namespace Dependency Rules
README 文档
README
This package is a PHPStan extension for checking namespace dependencies.
Install
composer require --dev nish/phpstan-namespace-dependency
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
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
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
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 https://github.com/nishimura/phpstan-namespace-dependency-sample
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.
统计信息
- 总下载量: 48
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-15