- Require
ampeco/phpstan-rulesas a composer dependency in your project - In your
phpstan.neonfile, add the following line to theincludessection:
- ./vendor/ampeco/phpstan-rules/rules.neon
- In the parameters section, configure the directories by adding the
preventNamespacesUsageInDirectoriesparameter. For instance:
preventNamespacesUsageInDirectories:
directories:
- modules:
- App
In this example, importing anything from the "App" namespace in the modules directory is forbidden.
You can define multiple rules as shown below:
preventNamespacesUsageInDirectories:
directories:
- modules:
- App
- app/Csv/Resources:
- Ampeco\Modules
Here, it is forbidden to import anything from the App namespace in the modules directory. Additionally, importing anything from Ampeco\Modules to the files in the app/Csv/Resources directory is also prohibited.