kvush / layer-violation-psalm-plugin
Detect layer dependency violation psalm-plugin
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:psalm-plugin
Requires
- php: >=7.1
- ext-simplexml: *
- vimeo/psalm: ^4.13
Requires (Dev)
- codeception/codeception: ^4.1
- phpunit/phpunit: ^9.5.5
- psalm/plugin-phpunit: ^0.16.0
- squizlabs/php_codesniffer: ^3.3
- weirdan/codeception-psalm-module: ^0.13.1
- weirdan/prophecy-shim: ^2.0
This package is auto-updated.
Last update: 2024-09-16 13:43:08 UTC
README
Installation
composer require --dev kvush/layer-violation-psalm-plugin
vendor/bin/psalm-plugin enable kvush/layer-violation-psalm-plugin
Features
- Detects layers dependency violation based on provided config
- Configuration can be split by multiple xml files
- Ability to configure nested namespaces or keep strict match
Configuration
Simple configuration
<?xml version="1.0"?> <psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" totallyTyped="true" > <!-- project configuration --> <plugins> <pluginClass class="Kvush\LayerViolationPsalmPlugin\Plugin"> <context> <common> <acceptable name="JetBrains\PhpStorm" /> </common> <layer name="App"> <acceptable name="Symfony" /> </layer> <layer name="App\Domain\ContextA\*"> <acceptable name="App\Domain\ContextA\*" /> <acceptable name="App\DateTime" /> <acceptable name="App\EntityId" /> </layer> <layer name="App\Domain\ContextB\*"> <acceptable name="App\Domain\ContextB\*" /> <acceptable name="App\EntityId" /> </layer> </context> </pluginClass> </plugins> </psalm>
Extracted to arbitrary named xml files
<?xml version="1.0"?> <psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" xmlns:xi="http://www.w3.org/2001/XInclude" totallyTyped="true" > <!-- project configuration --> <plugins> <pluginClass class="Kvush\LayerViolationPsalmPlugin\Plugin"> <xi:include href="path/to/root.xml"/> <xi:include href="path/to/common.xml"/> <xi:include href="path/to/contextA.xml"/> <xi:include href="path/to/contextB.xml"/> </pluginClass> </plugins> </psalm>
For Example Kernel class could be handled by root.xml
<?xml version="1.0" encoding="UTF-8"?> <layer name="App"> <acceptable name="Symfony" /> </layer>
Some Common rules in common.xml
<?xml version="1.0" encoding="UTF-8"?> <common> <acceptable name="JetBrains\PhpStorm" /> </common>
Split context rules contextA.xml
<?xml version="1.0" encoding="UTF-8"?> <context> <layer name="App\Domain\ContextA\*"> <acceptable name="App\Domain\ContextA\*" /> <acceptable name="App\DateTime" /> <acceptable name="App\EntityId" /> </layer> </context>
contextB.xml
<?xml version="1.0" encoding="UTF-8"?> <context> <layer name="App\Domain\ContextB\*"> <acceptable name="App\Domain\ContextB\*" /> <acceptable name="App\EntityId" /> </layer> </context>