Architecture Sniffer for Spryker projects. Over 80
rules adapted for Spryker Project.
-
1
: Сritical (stop it) -
2
: Major (it is not a Spryker project) -
3
: Medium (better to have) -
4
: Minor (nice to have) -
5
: Spryker Core (code matches Spryker Architecture Rules and even more)
We recommend minimum priority 3
by default for local and CI checks.
Note: Lower priorities (higher numbers) always include the higher priorities (lower numbers).
36
adapted PHPMD rules38
adapted Spryker Architecture sniffer rules10
new Project level rules
Make sure you include the sniffer as require-dev
dependency:
composer require --dev vitaliiivanovspryker/project-architecture-sniffer:dev-main
namespace Pyz\Zed\Development;
class DevelopmentConfig extends \Spryker\Zed\Development\DevelopmentConfig
{
public function getArchitectureSnifferRuleset(): string
{
$vendorDir = APPLICATION_VENDOR_DIR . DIRECTORY_SEPARATOR;
return $vendorDir . 'vitaliiivanovspryker/project-architecture-sniffer/src/ruleset.xml';
}
}
When using Spryker you can use the Spryker CLI console command for it:
console code:sniff:architecture [-m ModuleName] [optional-sub-path] -v [-p priority]
Verbose output is recommended here.
You can also manually run the Project Architecture Sniffer from console by using:
vendor/bin/phpmd src/Pyz/ (xml|text|html) vendor/vitaliiivanovspryker/project-architecture-sniffer/src/ruleset.xml --minimumpriority 2
vendor/bin/phpmd src json vendor/vitaliiivanovspryker/project-architecture-sniffer/src/ruleset.xml --minimumpriority 4 --reportfile results.json
cp vendor/vitaliiivanovspryker/project-architecture-sniffer/tools/script.php script.php
php script.php
docker/sdk cli -x
PHPMD_ALLOW_XDEBUG=true vendor/bin/phpmd src/Pyz/ (xml|text|html) vendor/vitaliiivanovspryker/project-architecture-sniffer/src/ruleset.xml --minimumpriority 2
feel free to suggest
Add them to inside src/Project folder with the same folder structure.
Don't forget to update ruleset.xml
.
Every sniff needs to implement either the ClassAware
, FunctionAware
, InterfaceAware
, or MethodAware
interface to be recognised.
Run
composer install
no testing at this moment
Make sure this repository is Spryker coding standard conform:
composer cs-check
If you want to fix the fixable errors, use
composer cs-fix
If you want to run phpstan
composer stan
Once everything is green you can make a PR with your changes.