From 8931c843ed3c604255945fe4243931e12d4b8fcf Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 4 Sep 2026 14:56:21 +0700 Subject: [PATCH] Bump structarmed to ^0.17 and enable CodeQuality preset --- .github/workflows/main.yml | 2 +- src/Files/src/FilesInterface.php | 4 ++-- src/Prototype/tests/Commands/DumpCommandTest.php | 2 +- src/Storage/tests/FileTest.php | 2 +- src/Storage/tests/ManagerTest.php | 2 +- src/Storage/tests/StorageTest.php | 2 +- src/Tokenizer/tests/Listener/ClassLocatorByTargetTest.php | 2 +- src/Tokenizer/tests/Listener/EnumLocatorByTargetTest.php | 2 +- .../tests/Listener/InterfaceLocatorByTargetTest.php | 2 +- src/Tokenizer/tests/Listener/ListenerInvokerTest.php | 2 +- structarmed.php | 6 +++++- 11 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4de5d2524..50a49c09b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -134,7 +134,7 @@ jobs: composer-options: "--prefer-dist --no-audit" - name: Install StructArmed - run: composer require --dev boundwize/structarmed:^0.16.0 --no-interaction --prefer-dist --no-audit + run: composer require --dev boundwize/structarmed:^0.17.0 --no-interaction --prefer-dist --no-audit # Execution - name: Run StructArmed diff --git a/src/Files/src/FilesInterface.php b/src/Files/src/FilesInterface.php index 24046846c..cc9ba5a3e 100644 --- a/src/Files/src/FilesInterface.php +++ b/src/Files/src/FilesInterface.php @@ -24,8 +24,8 @@ interface FilesInterface */ public const KB = 1024; - public const MB = 1048576; - public const GB = 1073741824; + public const MB = 1_048_576; + public const GB = 1_073_741_824; /** * Default location (directory) separator. diff --git a/src/Prototype/tests/Commands/DumpCommandTest.php b/src/Prototype/tests/Commands/DumpCommandTest.php index 6b56e294e..077003f6d 100644 --- a/src/Prototype/tests/Commands/DumpCommandTest.php +++ b/src/Prototype/tests/Commands/DumpCommandTest.php @@ -27,7 +27,7 @@ public function testDump(): void $files ->expects(self::once()) ->method('write') - ->with(static::callback(fn (): bool => true), static::callback($this->validateTrait(...))); + ->with(static::callback(static fn (): bool => true), static::callback($this->validateTrait(...))); $this->app->getContainer()->bindSingleton(FilesInterface::class, $files, true); diff --git a/src/Storage/tests/FileTest.php b/src/Storage/tests/FileTest.php index 05cbeb93e..c549256f1 100644 --- a/src/Storage/tests/FileTest.php +++ b/src/Storage/tests/FileTest.php @@ -218,7 +218,7 @@ public function testLastModified(): void self::assertGreaterThanOrEqual($now, $before); // Wait 1.1 seconds and then again modify file - \usleep(1100000); + \usleep(1_100_000); $file->write('content'); $after = $file->getLastModified(); diff --git a/src/Storage/tests/ManagerTest.php b/src/Storage/tests/ManagerTest.php index c47d63d04..642430206 100644 --- a/src/Storage/tests/ManagerTest.php +++ b/src/Storage/tests/ManagerTest.php @@ -267,7 +267,7 @@ public function testLastModified(): void self::assertGreaterThanOrEqual($now, $before); // Wait 1.1 seconds and then again modify file - \usleep(1100000); + \usleep(1_100_000); $this->manager->write('file.txt', 'content'); $after = $this->manager->getLastModified('file.txt'); diff --git a/src/Storage/tests/StorageTest.php b/src/Storage/tests/StorageTest.php index 2cb06662f..792080c5a 100644 --- a/src/Storage/tests/StorageTest.php +++ b/src/Storage/tests/StorageTest.php @@ -172,7 +172,7 @@ public function testLastModified(): void self::assertGreaterThanOrEqual($now, $before); // Wait 1.1 seconds and then again modify file - \usleep(1100000); + \usleep(1_100_000); $this->local->write('file.txt', 'content'); $after = $this->local->getLastModified('file.txt'); diff --git a/src/Tokenizer/tests/Listener/ClassLocatorByTargetTest.php b/src/Tokenizer/tests/Listener/ClassLocatorByTargetTest.php index cbaf5093b..8070f3bad 100644 --- a/src/Tokenizer/tests/Listener/ClassLocatorByTargetTest.php +++ b/src/Tokenizer/tests/Listener/ClassLocatorByTargetTest.php @@ -90,7 +90,7 @@ public function testGetClasses( array $expected, ): void { $classes = \array_map( - fn (string $class): \ReflectionClass => new \ReflectionClass($class), + static fn (string $class): \ReflectionClass => new \ReflectionClass($class), [ Targets\ConsoleCommand::class, Targets\Filter::class, diff --git a/src/Tokenizer/tests/Listener/EnumLocatorByTargetTest.php b/src/Tokenizer/tests/Listener/EnumLocatorByTargetTest.php index 239e1498c..ce40c4085 100644 --- a/src/Tokenizer/tests/Listener/EnumLocatorByTargetTest.php +++ b/src/Tokenizer/tests/Listener/EnumLocatorByTargetTest.php @@ -66,7 +66,7 @@ public function testGetEnums( array $expected, ): void { $enums = \array_map( - fn (string $class): \ReflectionEnum => new \ReflectionEnum($class), + static fn (string $class): \ReflectionEnum => new \ReflectionEnum($class), [ Targets\EnumWithAttributeOnClass::class, Targets\EnumWithAllTargets::class, diff --git a/src/Tokenizer/tests/Listener/InterfaceLocatorByTargetTest.php b/src/Tokenizer/tests/Listener/InterfaceLocatorByTargetTest.php index 5a66071f4..c0006f878 100644 --- a/src/Tokenizer/tests/Listener/InterfaceLocatorByTargetTest.php +++ b/src/Tokenizer/tests/Listener/InterfaceLocatorByTargetTest.php @@ -88,7 +88,7 @@ public function testGetEnums( array $expected, ): void { $interfaces = \array_map( - fn (string $class): \ReflectionClass => new \ReflectionClass($class), + static fn (string $class): \ReflectionClass => new \ReflectionClass($class), [ Targets\InterfaceWithAllTargets::class, Targets\InterfaceWithAttributeOnClass::class, diff --git a/src/Tokenizer/tests/Listener/ListenerInvokerTest.php b/src/Tokenizer/tests/Listener/ListenerInvokerTest.php index f1a339cd5..60a9af4e6 100644 --- a/src/Tokenizer/tests/Listener/ListenerInvokerTest.php +++ b/src/Tokenizer/tests/Listener/ListenerInvokerTest.php @@ -29,7 +29,7 @@ public function testInvoke(): void $invoker = new ListenerInvoker(); $classes = \array_map( - fn(string $class): \ReflectionClass => new \ReflectionClass($class), + static fn(string $class): \ReflectionClass => new \ReflectionClass($class), [ Targets\ConsoleCommand::class, Targets\Filter::class, diff --git a/structarmed.php b/structarmed.php index f31cff5c4..11d8fde3c 100644 --- a/structarmed.php +++ b/structarmed.php @@ -4,6 +4,7 @@ use Boundwize\StructArmed\Architecture; use Boundwize\StructArmed\Preset\Preset; +use Boundwize\StructArmed\Preset\Presets\CodeQualityPreset; use Boundwize\StructArmed\Rule\Rules\Class_\MustBeFinalRule; $layerPatterns = [ @@ -149,6 +150,9 @@ 'tests/app/src/Command/DeadCommand.php', 'tests/app/src/Controller/TestController.php', ], + CodeQualityPreset::ANONYMOUS_FUNCTIONS_MUST_BE_STATIC => [ + __DIR__ . '/src/Core/tests/Exception/ClosureRendererTraitTest.php', + ], ]) ->skipPaths([ // fixtures @@ -172,4 +176,4 @@ $architecture->layerPattern($name, $pattern); } -return $architecture->withPreset(Preset::PSR4()); +return $architecture->withPresets(Preset::PSR4(), Preset::CODEQUALITY());