Repository navigation
Expand file tree
/
Copy pathstructarmed.php
More file actions
136 lines (114 loc) · 5.17 KB
/
Copy pathstructarmed.php
File metadata and controls
136 lines (114 loc) · 5.17 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
declare(strict_types=1);
use Boundwize\StructArmed\Architecture;
use Boundwize\StructArmed\Preset\Preset;
return Architecture::define()
// apply on qa and src directory for now
// for ease gradual changes
->layer('Source', ['qa', 'src'])
// One layer per top-level namespace. A nested layer is excluded from its
// parent (third argument), so a class always belongs to a single layer.
->layer('Utility', 'src/Utility', [
'src/Utility/TypeHelper.php',
'src/Utility/Reflection/Annotations.php',
])
// keeps the rest of `Utility` unaware of `Type`
->layer('UtilityType', [
'src/Utility/TypeHelper.php',
'src/Utility/Reflection/Annotations.php',
])
->layer('Compiler', 'src/Compiler', 'src/Compiler/Library')
->layer('CompilerLibrary', 'src/Compiler/Library')
->layer('Type', 'src/Type', 'src/Type/Dumper')
->layer('TypeDumper', 'src/Type/Dumper')
->layer('Definition', 'src/Definition', [
'src/Definition/Repository/Cache',
'src/Definition/Attributes.php',
'src/Definition/AttributeDefinition.php',
])
->layer('DefinitionCache', 'src/Definition/Repository/Cache')
// the only part of `Definition` that `Type` may see
->layer('Attributes', [
'src/Definition/Attributes.php',
'src/Definition/AttributeDefinition.php',
])
->layer('Cache', 'src/Cache', 'src/Cache/Warmup')
->layer('CacheWarmup', 'src/Cache/Warmup')
->layer('Mapper', 'src/Mapper', [
'src/Mapper/Configurator',
'src/Mapper/Http',
'src/Mapper/Tree/Message',
'src/Mapper/AsConverter.php',
'src/Mapper/Object/Constructor.php',
'src/Mapper/Object/DynamicConstructor.php',
])
->layer('MapperConfigurator', 'src/Mapper/Configurator')
// the only part of `Mapper` that `Utility` may see
->layer('MapperHttp', 'src/Mapper/Http')
// the only part of `Mapper` that `Type` may see
->layer('Message', 'src/Mapper/Tree/Message')
->layer('Normalizer', 'src/Normalizer', [
'src/Normalizer/Configurator',
'src/Normalizer/AsTransformer.php',
])
->layer('NormalizerConfigurator', 'src/Normalizer/Configurator')
// the only part of `Mapper` and `Normalizer` that `Definition` may see
->layer('FeatureAttribute', [
'src/Mapper/AsConverter.php',
'src/Mapper/Object/Constructor.php',
'src/Mapper/Object/DynamicConstructor.php',
'src/Normalizer/AsTransformer.php',
])
->layer('Settings', 'src/Library/Settings.php')
->layer('Container', 'src/Library/Container.php')
->layer('Builder', [
'src/MapperBuilder.php',
'src/NormalizerBuilder.php',
])
->layer('QA', [
'qa/Benchmark',
'qa/PHPStan',
'qa/Psalm',
])
// Allowed dependencies of each layer, kept to what is used today.
// `+Layer` means: that layer and everything it may depend on.
->ruleset([
'Utility' => ['MapperHttp'],
'UtilityType' => ['Utility', 'Type'],
'Compiler' => [],
'CompilerLibrary' => ['Compiler', 'Type', 'Attributes'],
'Type' => ['Utility', 'UtilityType', 'Compiler', 'Message', 'Attributes'],
'TypeDumper' => ['+Type', 'Definition', 'Mapper'],
'Definition' => ['Utility', 'UtilityType', 'Type', 'Attributes', 'FeatureAttribute'],
'DefinitionCache' => ['+Definition', 'Cache'],
'Attributes' => ['Definition'],
'Cache' => ['Utility', 'UtilityType', 'Type', 'Definition', 'Attributes', 'Settings'],
'CacheWarmup' => ['+Cache', 'Mapper'],
// `Mapper` and `Normalizer` must stay independent from each other
'Mapper' => [
'Utility', 'UtilityType', 'Type', 'TypeDumper', 'Definition', 'Attributes', 'Settings',
'MapperConfigurator', 'MapperHttp', 'Message', 'FeatureAttribute',
],
'MapperConfigurator' => ['+Mapper', 'Builder'],
'MapperHttp' => ['Mapper'],
'Message' => ['Utility'],
'Normalizer' => [
'Utility', 'Compiler', 'CompilerLibrary', 'Type', 'Definition', 'Attributes', 'Cache',
'NormalizerConfigurator',
],
'NormalizerConfigurator' => ['+Normalizer', 'FeatureAttribute', 'Builder'],
// `DynamicConstructor` imports the builder for its docblock only
'FeatureAttribute' => ['Builder'],
'Settings' => ['Cache', 'MapperHttp', 'Message', 'FeatureAttribute'],
// composition root: only `Builder` may depend on it
'Container' => [
'Settings', 'Type', 'TypeDumper', 'Definition', 'DefinitionCache', 'Cache', 'CacheWarmup',
'Mapper', 'Normalizer',
],
'Builder' => [
'Settings', 'Container', 'Cache',
'Mapper', 'MapperConfigurator', 'Message', 'Normalizer', 'NormalizerConfigurator',
],
'QA' => ['Utility', 'Mapper', 'Builder'],
])
->withPresets(Preset::PSR4(), Preset::CODEQUALITY());