spencermalone / phpstan-no-transitive-use
PHPStan extension to disallow transitive dependency use
Installs: 142
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 0
Forks: 1
Open Issues: 0
Type:phpstan-extension
Requires
- php: >=7.4
- nikic/php-parser: ^4|^5
- phpstan/phpstan: ^2
- symfony/polyfill-php80: ^1.32
Requires (Dev)
- phpunit/phpunit: ^10|^11|^12
This package is not auto-updated.
Last update: 2025-06-25 22:46:19 UTC
README
A PHPStan extension that disallows using classes from transitive dependencies.
Installation
composer require --dev spencermalone/phpstan-no-transitive-use
Usage
The extension will automatically be loaded when you run PHPStan. It will check all use
statements in your code and report an error if you're trying to use a class from a transitive dependency.
For example, if your project depends on package A
which depends on package B
, and you try to use a class from package B
directly, PHPStan will report an error.
Configuration
If you do not use phpstan/extension-installer, you need to add:
includes:
- vendor/spencermalone/phpstan-no-transitive-use/extension.neon
to your phpstan.neon
No additional configuration is needed if you use phpstan/extension-installer.
The extension automatically reads your composer.json
to determine which dependencies are primary (directly required) and which are transitive.
Example
// This will cause an error if 'vendor/transitive/package' is not in your composer.json use Transitive\Package\SomeClass;
License
MIT