Skip to content

Commit 9935bf9

Browse files
authored
Merge pull request #49 from samsonasik/use-structarmed-on-qa
Use StructArmed on QA
2 parents e06800a + dc466d3 commit 9935bf9

20 files changed

Lines changed: 74 additions & 21 deletions

‎composer.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"php": "~8.3.0 || ~8.4.0 || ~8.5.0"
3232
},
3333
"require-dev": {
34+
"boundwize/structarmed": "^0.19",
3435
"laminas/laminas-coding-standard": "^3.1.0",
3536
"mikey179/vfsstream": "^1.6.12",
3637
"phpstan/phpstan": "^2.1.33",

‎src/Component/ClassFile.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,22 @@ public function render(): string
235235
$class .= '{' . PHP_EOL;
236236

237237
if (count($this->traits) > 0) {
238-
$traits = array_map(fn (string $trait): string => $trait, $this->traits);
238+
$traits = array_map(static fn (string $trait): string => $trait, $this->traits);
239239

240240
$class .= ' ' . implode(PHP_EOL . ' ', $traits) . PHP_EOL . PHP_EOL;
241241
}
242242

243243
if (count($this->properties) > 0) {
244244
$properties = array_map(
245-
fn (ParameterInterface $property): string => $property->render(4),
245+
static fn (ParameterInterface $property): string => $property->render(4),
246246
$this->properties
247247
);
248248

249249
$class .= implode(PHP_EOL, $properties) . PHP_EOL . PHP_EOL;
250250
}
251251

252252
if (count($this->methods) > 0) {
253-
$methods = array_map(fn (MethodInterface $method): string => $method->render(), $this->methods);
253+
$methods = array_map(static fn (MethodInterface $method): string => $method->render(), $this->methods);
254254

255255
$class .= ' ' . implode(PHP_EOL . PHP_EOL . ' ', $methods) . PHP_EOL;
256256
}

‎src/Component/Declaration.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function renderParameters(): string
7979
}
8080

8181
return implode(PHP_EOL, array_map(
82-
fn (ParameterInterface $parameter): string => sprintf(' %s,', $parameter->render()),
82+
static fn (ParameterInterface $parameter): string => sprintf(' %s,', $parameter->render()),
8383
$this->parameters
8484
));
8585
}

‎src/Component/Inject.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ private function renderWithNamedArguments(): string
6969
private function renderWithPositionalArguments(int $spaces = 4): string
7070
{
7171
$arguments = array_map(
72-
fn (string $argument): string => sprintf('%s%s%s,', PHP_EOL, str_repeat(' ', $spaces + 4), $argument),
72+
static fn (string $argument): string =>
73+
sprintf('%s%s%s,', PHP_EOL, str_repeat(' ', $spaces + 4), $argument),
7374
$this->positionalArguments
7475
);
7576

‎src/Component/InterfaceFile.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function render(): string
169169

170170
if (count($this->declarations) > 0) {
171171
$declarations = array_map(
172-
fn (Declaration $declaration): string => $declaration->render(),
172+
static fn (Declaration $declaration): string => $declaration->render(),
173173
$this->declarations
174174
);
175175

‎src/Component/Method.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function renderInjects(): string
187187
return '';
188188
}
189189

190-
$injects = array_map(fn (Inject $inject): string => $inject->render(), $this->injects);
190+
$injects = array_map(static fn (Inject $inject): string => $inject->render(), $this->injects);
191191

192192
return implode(PHP_EOL, $injects);
193193
}
@@ -199,7 +199,7 @@ public function renderParameters(int $spaces = 0): string
199199
}
200200

201201
return implode(PHP_EOL, array_map(
202-
fn (ParameterInterface $parameter): string => sprintf(
202+
static fn (ParameterInterface $parameter): string => sprintf(
203203
'%s%s,',
204204
str_repeat(' ', $spaces),
205205
$parameter->render()

‎structarmed.php‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Boundwize\StructArmed\Architecture;
6+
use Boundwize\StructArmed\Preset\Preset;
7+
8+
return Architecture::define()
9+
->withPresets(Preset::PSR4(), Preset::CODEQUALITY())
10+
11+
->layer('ColorEnum', 'src/ColorEnum.php')
12+
->layer('VisibilityEnum', 'src/VisibilityEnum.php')
13+
->layer('Context', 'src/Context.php')
14+
->layer('Config', 'src/Config.php')
15+
->layer('Message', 'src/Message.php')
16+
->layer('Maker', 'src/Maker.php')
17+
->layer('IO', 'src/IO/')
18+
->layer('Exception', 'src/Exception/')
19+
->layer('BaseComponent', ['src/Component.php', 'src/Component/'], 'src/Component/Method/')
20+
->layer('MethodComponent', 'src/Component/Method/')
21+
->layer('FileSystem', ['src/FileSystem.php', 'src/FileSystem/'])
22+
->layer('CommonType', 'src/Type/', [
23+
'src/Type/Form/',
24+
'src/Type/Handler/',
25+
'src/Type/Input/',
26+
'src/Type/InputFilter/',
27+
])
28+
->layer('FormType', 'src/Type/Form/')
29+
->layer('HandlerType', 'src/Type/Handler/', 'src/Type/Handler/Api/')
30+
->layer('ApiHandlerType', 'src/Type/Handler/Api/')
31+
->layer('InputType', 'src/Type/Input/')
32+
->layer('InputFilterType', 'src/Type/InputFilter/')
33+
->ruleset([
34+
'ColorEnum' => [],
35+
'VisibilityEnum' => [],
36+
'Context' => [],
37+
'IO' => ['ColorEnum'],
38+
'Message' => ['ColorEnum', 'Context'],
39+
'BaseComponent' => ['Context', 'VisibilityEnum', 'MethodComponent'],
40+
'MethodComponent' => ['+BaseComponent'],
41+
'Exception' => ['FileSystem'],
42+
'FileSystem' => ['+BaseComponent', 'Exception'],
43+
'FormType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'],
44+
'HandlerType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'],
45+
'ApiHandlerType' => ['+HandlerType'],
46+
'InputType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'],
47+
'InputFilterType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'],
48+
'CommonType' => ['+FormType', '+ApiHandlerType', '+InputType', '+InputFilterType'],
49+
'Maker' => ['+CommonType'],
50+
'Config' => ['Maker'],
51+
]);

‎test/Component/ClassFileTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Component;
5+
namespace DotTest\Maker\Component;
66

77
use Dot\Maker\Component\ClassFile;
88
use Dot\Maker\Component\Inject;

‎test/Component/CoreImportTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Component;
5+
namespace DotTest\Maker\Component;
66

77
use Dot\Maker\Component\Import;
88
use Dot\Maker\Context;

‎test/Component/DeclarationTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Component;
5+
namespace DotTest\Maker\Component;
66

77
use Dot\Maker\Component\Declaration;
88
use Dot\Maker\Component\Parameter;

0 commit comments

Comments
 (0)