From b0bdf73638adbad3b43e782f06fc68757369ddc5 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 28 Oct 2026 06:38:58 +0700 Subject: [PATCH 1/3] Use StructArmed on QA Signed-off-by: Abdul Malik Ikhsan --- composer.json | 3 +- src/Component/ClassFile.php | 6 +-- src/Component/Declaration.php | 2 +- src/Component/Inject.php | 3 +- src/Component/InterfaceFile.php | 2 +- src/Component/Method.php | 4 +- structarmed.php | 51 +++++++++++++++++++++++ test/Component/ClassFileTest.php | 2 +- test/Component/CoreImportTest.php | 2 +- test/Component/DeclarationTest.php | 2 +- test/Component/ImportTest.php | 2 +- test/Component/InjectTest.php | 2 +- test/Component/InterfaceFileTest.php | 2 +- test/Component/Method/ConstructorTest.php | 2 +- test/Component/Method/GetterTest.php | 2 +- test/Component/Method/SetterTest.php | 2 +- test/Component/MethodTest.php | 2 +- test/Component/ParameterTest.php | 2 +- test/Component/PromotedPropertyTest.php | 2 +- test/Component/PropertyTest.php | 2 +- 20 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 structarmed.php diff --git a/composer.json b/composer.json index f15c939..3218f0f 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,8 @@ "mikey179/vfsstream": "^1.6.12", "phpstan/phpstan": "^2.1.33", "phpstan/phpstan-phpunit": "^2.0.10", - "phpunit/phpunit": "^10.5.60" + "phpunit/phpunit": "^10.5.60", + "boundwize/structarmed": "^0.19" }, "scripts": { "check": [ diff --git a/src/Component/ClassFile.php b/src/Component/ClassFile.php index 409fdd2..b14b4fa 100644 --- a/src/Component/ClassFile.php +++ b/src/Component/ClassFile.php @@ -235,14 +235,14 @@ public function render(): string $class .= '{' . PHP_EOL; if (count($this->traits) > 0) { - $traits = array_map(fn (string $trait): string => $trait, $this->traits); + $traits = array_map(static fn (string $trait): string => $trait, $this->traits); $class .= ' ' . implode(PHP_EOL . ' ', $traits) . PHP_EOL . PHP_EOL; } if (count($this->properties) > 0) { $properties = array_map( - fn (ParameterInterface $property): string => $property->render(4), + static fn (ParameterInterface $property): string => $property->render(4), $this->properties ); @@ -250,7 +250,7 @@ public function render(): string } if (count($this->methods) > 0) { - $methods = array_map(fn (MethodInterface $method): string => $method->render(), $this->methods); + $methods = array_map(static fn (MethodInterface $method): string => $method->render(), $this->methods); $class .= ' ' . implode(PHP_EOL . PHP_EOL . ' ', $methods) . PHP_EOL; } diff --git a/src/Component/Declaration.php b/src/Component/Declaration.php index 5b93e4e..b9e0e46 100644 --- a/src/Component/Declaration.php +++ b/src/Component/Declaration.php @@ -79,7 +79,7 @@ public function renderParameters(): string } return implode(PHP_EOL, array_map( - fn (ParameterInterface $parameter): string => sprintf(' %s,', $parameter->render()), + static fn (ParameterInterface $parameter): string => sprintf(' %s,', $parameter->render()), $this->parameters )); } diff --git a/src/Component/Inject.php b/src/Component/Inject.php index a8f3cd4..27fb508 100644 --- a/src/Component/Inject.php +++ b/src/Component/Inject.php @@ -69,7 +69,8 @@ private function renderWithNamedArguments(): string private function renderWithPositionalArguments(int $spaces = 4): string { $arguments = array_map( - fn (string $argument): string => sprintf('%s%s%s,', PHP_EOL, str_repeat(' ', $spaces + 4), $argument), + static fn (string $argument): string => + sprintf('%s%s%s,', PHP_EOL, str_repeat(' ', $spaces + 4), $argument), $this->positionalArguments ); diff --git a/src/Component/InterfaceFile.php b/src/Component/InterfaceFile.php index 0067187..a5ea24d 100644 --- a/src/Component/InterfaceFile.php +++ b/src/Component/InterfaceFile.php @@ -169,7 +169,7 @@ public function render(): string if (count($this->declarations) > 0) { $declarations = array_map( - fn (Declaration $declaration): string => $declaration->render(), + static fn (Declaration $declaration): string => $declaration->render(), $this->declarations ); diff --git a/src/Component/Method.php b/src/Component/Method.php index 3e76cdd..bf6aa6e 100644 --- a/src/Component/Method.php +++ b/src/Component/Method.php @@ -187,7 +187,7 @@ public function renderInjects(): string return ''; } - $injects = array_map(fn (Inject $inject): string => $inject->render(), $this->injects); + $injects = array_map(static fn (Inject $inject): string => $inject->render(), $this->injects); return implode(PHP_EOL, $injects); } @@ -199,7 +199,7 @@ public function renderParameters(int $spaces = 0): string } return implode(PHP_EOL, array_map( - fn (ParameterInterface $parameter): string => sprintf( + static fn (ParameterInterface $parameter): string => sprintf( '%s%s,', str_repeat(' ', $spaces), $parameter->render() diff --git a/structarmed.php b/structarmed.php new file mode 100644 index 0000000..bf42d63 --- /dev/null +++ b/structarmed.php @@ -0,0 +1,51 @@ +withPresets(Preset::PSR4(), Preset::CODEQUALITY()) + + ->layer('ColorEnum', 'src/ColorEnum.php') + ->layer('VisibilityEnum', 'src/VisibilityEnum.php') + ->layer('Context', 'src/Context.php') + ->layer('Config', 'src/Config.php') + ->layer('Message', 'src/Message.php') + ->layer('Maker', 'src/Maker.php') + ->layer('IO', 'src/IO/') + ->layer('Exception', 'src/Exception/') + ->layer('Component', ['src/Component.php', 'src/Component/'], 'src/Component/Method/') + ->layer('Method', 'src/Component/Method/') + ->layer('FileSystem', ['src/FileSystem.php', 'src/FileSystem/']) + ->layer('Type', 'src/Type/', [ + 'src/Type/Form/', + 'src/Type/Handler/', + 'src/Type/Input/', + 'src/Type/InputFilter/', + ]) + ->layer('Form', 'src/Type/Form/') + ->layer('Handler', 'src/Type/Handler/', 'src/Type/Handler/Api/') + ->layer('ApiHandler', 'src/Type/Handler/Api/') + ->layer('Input', 'src/Type/Input/') + ->layer('InputFilter', 'src/Type/InputFilter/') + ->ruleset([ + 'ColorEnum' => [], + 'VisibilityEnum' => [], + 'Context' => [], + 'IO' => ['ColorEnum'], + 'Message' => ['ColorEnum', 'Context'], + 'Component' => ['Context', 'VisibilityEnum', 'Method'], + 'Method' => ['+Component'], + 'Exception' => ['FileSystem'], + 'FileSystem' => ['+Component', 'Exception'], + 'Form' => ['Type', 'Config', '+FileSystem', '+IO', '+Message'], + 'Handler' => ['Type', 'Config', '+FileSystem', '+IO', '+Message'], + 'ApiHandler' => ['+Handler'], + 'Input' => ['Type', 'Config', '+FileSystem', '+IO', '+Message'], + 'InputFilter' => ['Type', 'Config', '+FileSystem', '+IO', '+Message'], + 'Type' => ['+Form', '+ApiHandler', '+Input', '+InputFilter'], + 'Maker' => ['+Type'], + 'Config' => ['Maker'], + ]); diff --git a/test/Component/ClassFileTest.php b/test/Component/ClassFileTest.php index f4bbaee..1693d11 100644 --- a/test/Component/ClassFileTest.php +++ b/test/Component/ClassFileTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component; +namespace DotTest\Maker\Component; use Dot\Maker\Component\ClassFile; use Dot\Maker\Component\Inject; diff --git a/test/Component/CoreImportTest.php b/test/Component/CoreImportTest.php index 4f4ae70..c0895cd 100644 --- a/test/Component/CoreImportTest.php +++ b/test/Component/CoreImportTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component; +namespace DotTest\Maker\Component; use Dot\Maker\Component\Import; use Dot\Maker\Context; diff --git a/test/Component/DeclarationTest.php b/test/Component/DeclarationTest.php index c6fd406..9f24bbd 100644 --- a/test/Component/DeclarationTest.php +++ b/test/Component/DeclarationTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component; +namespace DotTest\Maker\Component; use Dot\Maker\Component\Declaration; use Dot\Maker\Component\Parameter; diff --git a/test/Component/ImportTest.php b/test/Component/ImportTest.php index 54725ea..7fe8bd0 100644 --- a/test/Component/ImportTest.php +++ b/test/Component/ImportTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component; +namespace DotTest\Maker\Component; use Dot\Maker\Component\Import; use Dot\Maker\Context; diff --git a/test/Component/InjectTest.php b/test/Component/InjectTest.php index b762592..370ce27 100644 --- a/test/Component/InjectTest.php +++ b/test/Component/InjectTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component; +namespace DotTest\Maker\Component; use Dot\Maker\Component\Inject; use PHPUnit\Framework\TestCase; diff --git a/test/Component/InterfaceFileTest.php b/test/Component/InterfaceFileTest.php index ee9c859..9f71eb0 100644 --- a/test/Component/InterfaceFileTest.php +++ b/test/Component/InterfaceFileTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component; +namespace DotTest\Maker\Component; use Dot\Maker\Component\Declaration; use Dot\Maker\Component\InterfaceFile; diff --git a/test/Component/Method/ConstructorTest.php b/test/Component/Method/ConstructorTest.php index 7105a8d..fa27a78 100644 --- a/test/Component/Method/ConstructorTest.php +++ b/test/Component/Method/ConstructorTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component\Method; +namespace DotTest\Maker\Component\Method; use Dot\Maker\Component\Inject; use Dot\Maker\Component\Method\Constructor; diff --git a/test/Component/Method/GetterTest.php b/test/Component/Method/GetterTest.php index 5fb75e1..92c1948 100644 --- a/test/Component/Method/GetterTest.php +++ b/test/Component/Method/GetterTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component\Method; +namespace DotTest\Maker\Component\Method; use Dot\Maker\Component\Method\Getter; use Dot\Maker\Component\Parameter; diff --git a/test/Component/Method/SetterTest.php b/test/Component/Method/SetterTest.php index 8f0b172..5407c1b 100644 --- a/test/Component/Method/SetterTest.php +++ b/test/Component/Method/SetterTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component\Method; +namespace DotTest\Maker\Component\Method; use Dot\Maker\Component\Method\Setter; use Dot\Maker\Component\Parameter; diff --git a/test/Component/MethodTest.php b/test/Component/MethodTest.php index 86b5c7a..389bb52 100644 --- a/test/Component/MethodTest.php +++ b/test/Component/MethodTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component; +namespace DotTest\Maker\Component; use Dot\Maker\Component\Inject; use Dot\Maker\Component\Method; diff --git a/test/Component/ParameterTest.php b/test/Component/ParameterTest.php index 90c4920..fc4ada5 100644 --- a/test/Component/ParameterTest.php +++ b/test/Component/ParameterTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component; +namespace DotTest\Maker\Component; use Dot\Maker\Component\Parameter; use Dot\Maker\VisibilityEnum; diff --git a/test/Component/PromotedPropertyTest.php b/test/Component/PromotedPropertyTest.php index 89c0601..cce09ea 100644 --- a/test/Component/PromotedPropertyTest.php +++ b/test/Component/PromotedPropertyTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component; +namespace DotTest\Maker\Component; use Dot\Maker\Component\PromotedProperty; use Dot\Maker\VisibilityEnum; diff --git a/test/Component/PropertyTest.php b/test/Component/PropertyTest.php index 71cbbd2..02bef92 100644 --- a/test/Component/PropertyTest.php +++ b/test/Component/PropertyTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Component; +namespace DotTest\Maker\Component; use Dot\Maker\Component\Property; use Dot\Maker\VisibilityEnum; From 51b32b4b39b34f1321a3cc608425443c07e6a74b Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 28 Oct 2026 06:45:51 +0700 Subject: [PATCH 2/3] better naming for layer Signed-off-by: Abdul Malik Ikhsan --- structarmed.php | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/structarmed.php b/structarmed.php index bf42d63..99a9bed 100644 --- a/structarmed.php +++ b/structarmed.php @@ -16,36 +16,36 @@ ->layer('Maker', 'src/Maker.php') ->layer('IO', 'src/IO/') ->layer('Exception', 'src/Exception/') - ->layer('Component', ['src/Component.php', 'src/Component/'], 'src/Component/Method/') - ->layer('Method', 'src/Component/Method/') + ->layer('BaseComponent', ['src/Component.php', 'src/Component/'], 'src/Component/Method/') + ->layer('MethodComponent', 'src/Component/Method/') ->layer('FileSystem', ['src/FileSystem.php', 'src/FileSystem/']) - ->layer('Type', 'src/Type/', [ + ->layer('CommonType', 'src/Type/', [ 'src/Type/Form/', 'src/Type/Handler/', 'src/Type/Input/', 'src/Type/InputFilter/', ]) - ->layer('Form', 'src/Type/Form/') - ->layer('Handler', 'src/Type/Handler/', 'src/Type/Handler/Api/') - ->layer('ApiHandler', 'src/Type/Handler/Api/') - ->layer('Input', 'src/Type/Input/') - ->layer('InputFilter', 'src/Type/InputFilter/') + ->layer('FormType', 'src/Type/Form/') + ->layer('HandlerType', 'src/Type/Handler/', 'src/Type/Handler/Api/') + ->layer('ApiHandlerType', 'src/Type/Handler/Api/') + ->layer('InputType', 'src/Type/Input/') + ->layer('InputFilterType', 'src/Type/InputFilter/') ->ruleset([ - 'ColorEnum' => [], - 'VisibilityEnum' => [], - 'Context' => [], - 'IO' => ['ColorEnum'], - 'Message' => ['ColorEnum', 'Context'], - 'Component' => ['Context', 'VisibilityEnum', 'Method'], - 'Method' => ['+Component'], - 'Exception' => ['FileSystem'], - 'FileSystem' => ['+Component', 'Exception'], - 'Form' => ['Type', 'Config', '+FileSystem', '+IO', '+Message'], - 'Handler' => ['Type', 'Config', '+FileSystem', '+IO', '+Message'], - 'ApiHandler' => ['+Handler'], - 'Input' => ['Type', 'Config', '+FileSystem', '+IO', '+Message'], - 'InputFilter' => ['Type', 'Config', '+FileSystem', '+IO', '+Message'], - 'Type' => ['+Form', '+ApiHandler', '+Input', '+InputFilter'], - 'Maker' => ['+Type'], - 'Config' => ['Maker'], + 'ColorEnum' => [], + 'VisibilityEnum' => [], + 'Context' => [], + 'IO' => ['ColorEnum'], + 'Message' => ['ColorEnum', 'Context'], + 'BaseComponent' => ['Context', 'VisibilityEnum', 'MethodComponent'], + 'MethodComponent' => ['+BaseComponent'], + 'Exception' => ['FileSystem'], + 'FileSystem' => ['+BaseComponent', 'Exception'], + 'FormType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'], + 'HandlerType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'], + 'ApiHandlerType' => ['+HandlerType'], + 'InputType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'], + 'InputFilterType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'], + 'CommonType' => ['+FormType', '+ApiHandlerType', '+InputType', '+InputFilterType'], + 'Maker' => ['+CommonType'], + 'Config' => ['Maker'], ]); From dc466d3ce80c2a95c55cadd57096ad7867629789 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 28 Oct 2026 11:55:34 +0700 Subject: [PATCH 3/3] Move boundwize/structarmed to first position Signed-off-by: Abdul Malik Ikhsan --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3218f0f..7250728 100644 --- a/composer.json +++ b/composer.json @@ -31,12 +31,12 @@ "php": "~8.3.0 || ~8.4.0 || ~8.5.0" }, "require-dev": { + "boundwize/structarmed": "^0.19", "laminas/laminas-coding-standard": "^3.1.0", "mikey179/vfsstream": "^1.6.12", "phpstan/phpstan": "^2.1.33", "phpstan/phpstan-phpunit": "^2.0.10", - "phpunit/phpunit": "^10.5.60", - "boundwize/structarmed": "^0.19" + "phpunit/phpunit": "^10.5.60" }, "scripts": { "check": [