-
Notifications
You must be signed in to change notification settings - Fork 8
/
deptrac.config.php
executable file
·118 lines (115 loc) · 5.77 KB
/
deptrac.config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
use Internal\Qossmic\Deptrac\IgnoreDependenciesOnContract;
use Qossmic\Deptrac\Contract\Config\AnalyserConfig;
use Qossmic\Deptrac\Contract\Config\Collector\BoolConfig;
use Qossmic\Deptrac\Contract\Config\Collector\ComposerConfig;
use Qossmic\Deptrac\Contract\Config\Collector\DirectoryConfig;
use Qossmic\Deptrac\Contract\Config\DeptracConfig;
use Qossmic\Deptrac\Contract\Config\EmitterType;
use Qossmic\Deptrac\Contract\Config\Formatter\GraphvizConfig;
use Qossmic\Deptrac\Contract\Config\Formatter\MermaidJsConfig;
use Qossmic\Deptrac\Contract\Config\Layer;
use Qossmic\Deptrac\Contract\Config\Ruleset;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (DeptracConfig $config, ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(IgnoreDependenciesOnContract::class)
->tag('kernel.event_subscriber');
$config
->paths('src')
->cacheFile('.cache/deptrac.cache')
->analyser(
AnalyserConfig::create()
->internalTag( '@internal' )
->types(
EmitterType::CLASS_TOKEN,
EmitterType::CLASS_SUPERGLOBAL_TOKEN,
EmitterType::FILE_TOKEN,
EmitterType::FUNCTION_TOKEN,
EmitterType::FUNCTION_SUPERGLOBAL_TOKEN,
EmitterType::FUNCTION_CALL
)
)
->layers(
$analyser = Layer::withName('Analyser')->collectors(
DirectoryConfig::create('src/Core/Analyser/.*')
),
$ast = Layer::withName('Ast')->collectors(
DirectoryConfig::create('src/Core/Ast/.*'),
ComposerConfig::create()
->addPackage('phpstan/phpdoc-parser')
->addPackage('nikic/php-parser')
->addPackage('phpdocumentor/type-resolver')
->private(),
),
$console = Layer::withName('Console')->collectors(
DirectoryConfig::create('src/Supportive/Console/.*')
),
$dependency = Layer::withName('Dependency')->collectors(
DirectoryConfig::create('src/Core/Dependency/.*')
),
$dependencyInjection = Layer::withName('DependencyInjection')->collectors(
DirectoryConfig::create('src/Supportive/DependencyInjection/.*')
),
$contract = Layer::withName('Contract')->collectors(
DirectoryConfig::create('src/Contract/.*')
),
$inputCollector = Layer::withName('InputCollector')->collectors(
DirectoryConfig::create('src/Core/InputCollector/.*')
),
$layer = Layer::withName('Layer')->collectors(
DirectoryConfig::create('src/Core/Layer/.*')
),
$outputFormatter = Layer::withName('OutputFormatter')->collectors(
DirectoryConfig::create('src/Supportive/OutputFormatter/.*'),
ComposerConfig::create('composer.json', 'composer.lock')
->addPackage('phpdocumentor/graphviz')->private(),
),
$file = Layer::withName('File')->collectors(
DirectoryConfig::create('src/Supportive/File/.*')
),
$time = Layer::withName('Time')->collectors(
DirectoryConfig::create('src/Supportive/Time/.*')
),
$supportive = Layer::withName('Supportive')->collectors(
BoolConfig::create()
->mustNot(DirectoryConfig::create('src/Supportive/.*/.*'))
->must(DirectoryConfig::create('src/Supportive/.*'))
),
$symfony = Layer::withName('Symfony')->collectors(
ComposerConfig::create()
->addPackage('symfony/config')
->addPackage('symfony/console')
->addPackage('symfony/dependency-injection')
->addPackage('symfony/event-dispatcher')
->addPackage('symfony/filesystem')
->addPackage('symfony/finder')
->addPackage('symfony/yaml'),
),
)
->rulesets(
Ruleset::forLayer($layer)->accesses($ast, $symfony),
Ruleset::forLayer($console)->accesses($analyser, $outputFormatter, $dependencyInjection, $file, $time, $symfony),
Ruleset::forLayer($dependency)->accesses($ast),
Ruleset::forLayer($analyser)->accesses($layer, $dependency, $ast, $symfony),
Ruleset::forLayer($outputFormatter)->accesses($dependencyInjection, $symfony),
Ruleset::forLayer($ast)->accesses($file, $inputCollector, $symfony),
Ruleset::forLayer($inputCollector)->accesses($file, $symfony),
Ruleset::forLayer($supportive)->accesses($file),
Ruleset::forLayer($contract)->accesses($symfony),
Ruleset::forLayer($file)->accesses($symfony),
Ruleset::forLayer($dependencyInjection)->accesses($symfony),
)
->formatters(
GraphvizConfig::create()
->pointsToGroup(true)
->groups('Contract', $contract)
->groups('Supportive', $supportive, $file, $symfony, $console, $dependencyInjection, $outputFormatter, $time)
->groups('Core', $analyser, $ast, $dependency, $inputCollector, $layer),
MermaidJsConfig::create()
->direction('TD')
->groups('Contract', $contract)
->groups('Supportive', $supportive, $file, $symfony, $console, $dependencyInjection, $outputFormatter, $time)
->groups('Core', $analyser, $ast, $dependency, $inputCollector, $layer)
);
};