From 3a9f9a784326a0ed1b0add1f9c7a1f64fd0d92ae Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 May 2026 22:17:16 +0700 Subject: [PATCH 1/7] Add StructArmed to QA --- .github/workflows/ci.yml | 3 +++ composer.json | 3 +++ structarmed.php | 15 +++++++++++++++ .../Fixture/fixture.php.inc | 4 ++-- .../config/configured_rule.php | 2 +- .../Fixture/fixture.php.inc | 4 ++-- .../Source/SomeModelType.php | 2 +- .../config/configured_rule.php | 2 +- 8 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 structarmed.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a28041ec..1048ef9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,3 +96,6 @@ jobs: - name: Run PHP CodeSniffer run: vendor/bin/phpcs --report=checkstyle | cs2pr + + - name: Run StructArmed + run: vendor/bin/structarmed analyze diff --git a/composer.json b/composer.json index 609d7398..4d410dd0 100644 --- a/composer.json +++ b/composer.json @@ -38,5 +38,8 @@ }, "support": { "source": "https://github.com/cakephp/upgrade" + }, + "require-dev": { + "boundwize/structarmed": "^0.7.7" } } diff --git a/structarmed.php b/structarmed.php new file mode 100644 index 00000000..fde91bfa --- /dev/null +++ b/structarmed.php @@ -0,0 +1,15 @@ +skip([ + Psr4Preset::CLASSES_MUST_MATCH_COMPOSER => [ + __DIR__ . '/tests/TestCase/Rector/Namespace_/AppUsesStaticCallToUseStatementRector/Source', + ], + ]) + ->withPreset(Preset::PSR4()); diff --git a/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/Fixture/fixture.php.inc b/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/Fixture/fixture.php.inc index 422637f1..f448a889 100644 --- a/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/Fixture/fixture.php.inc +++ b/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/Fixture/fixture.php.inc @@ -2,7 +2,7 @@ namespace Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRectorTest\Fixture; -use Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRector\Source\SomeModelType; +use Cake\Upgrade\Test\TestCase\Rector\MethodCall\RemoveMethodCallArgsRector\Source\SomeModelType; function addMethodCallArgs() { @@ -17,7 +17,7 @@ function addMethodCallArgs() namespace Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRectorTest\Fixture; -use Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRector\Source\SomeModelType; +use Cake\Upgrade\Test\TestCase\Rector\MethodCall\RemoveMethodCallArgsRector\Source\SomeModelType; function addMethodCallArgs() { diff --git a/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/config/configured_rule.php b/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/config/configured_rule.php index db960bed..1da79830 100644 --- a/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/config/configured_rule.php +++ b/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/config/configured_rule.php @@ -3,7 +3,7 @@ use Cake\Upgrade\Rector\Rector\MethodCall\AddMethodCallArgsRector; use Cake\Upgrade\Rector\ValueObject\AddMethodCallArgs; -use Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRector\Source\SomeModelType; +use Cake\Upgrade\Test\TestCase\Rector\MethodCall\RemoveMethodCallArgsRector\Source\SomeModelType; use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { diff --git a/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc b/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc index 4dbbc418..3790b567 100644 --- a/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc +++ b/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc @@ -2,7 +2,7 @@ namespace Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRectorTest\Fixture; -use Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRector\Source\SomeModelType; +use Cake\Upgrade\Test\TestCase\Rector\MethodCall\RemoveMethodCallArgsRector\Source\SomeModelType; function addMethodCallArgs() { @@ -17,7 +17,7 @@ function addMethodCallArgs() namespace Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRectorTest\Fixture; -use Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRector\Source\SomeModelType; +use Cake\Upgrade\Test\TestCase\Rector\MethodCall\RemoveMethodCallArgsRector\Source\SomeModelType; function addMethodCallArgs() { diff --git a/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Source/SomeModelType.php b/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Source/SomeModelType.php index e4b96b5f..6a461108 100644 --- a/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Source/SomeModelType.php +++ b/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Source/SomeModelType.php @@ -1,7 +1,7 @@ Date: Sun, 24 May 2026 22:24:32 +0700 Subject: [PATCH 2/7] final touch: fix reference --- .../AddMethodCallArgsRector/Fixture/fixture.php.inc | 4 ++-- .../AddMethodCallArgsRector/config/configured_rule.php | 2 +- .../RemoveMethodCallArgsRector/Fixture/fixture.php.inc | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/Fixture/fixture.php.inc b/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/Fixture/fixture.php.inc index f448a889..422637f1 100644 --- a/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/Fixture/fixture.php.inc +++ b/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/Fixture/fixture.php.inc @@ -2,7 +2,7 @@ namespace Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRectorTest\Fixture; -use Cake\Upgrade\Test\TestCase\Rector\MethodCall\RemoveMethodCallArgsRector\Source\SomeModelType; +use Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRector\Source\SomeModelType; function addMethodCallArgs() { @@ -17,7 +17,7 @@ function addMethodCallArgs() namespace Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRectorTest\Fixture; -use Cake\Upgrade\Test\TestCase\Rector\MethodCall\RemoveMethodCallArgsRector\Source\SomeModelType; +use Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRector\Source\SomeModelType; function addMethodCallArgs() { diff --git a/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/config/configured_rule.php b/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/config/configured_rule.php index 1da79830..db960bed 100644 --- a/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/config/configured_rule.php +++ b/tests/TestCase/Rector/MethodCall/AddMethodCallArgsRector/config/configured_rule.php @@ -3,7 +3,7 @@ use Cake\Upgrade\Rector\Rector\MethodCall\AddMethodCallArgsRector; use Cake\Upgrade\Rector\ValueObject\AddMethodCallArgs; -use Cake\Upgrade\Test\TestCase\Rector\MethodCall\RemoveMethodCallArgsRector\Source\SomeModelType; +use Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRector\Source\SomeModelType; use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { diff --git a/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc b/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc index 3790b567..4dbbc418 100644 --- a/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc +++ b/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc @@ -2,7 +2,7 @@ namespace Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRectorTest\Fixture; -use Cake\Upgrade\Test\TestCase\Rector\MethodCall\RemoveMethodCallArgsRector\Source\SomeModelType; +use Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRector\Source\SomeModelType; function addMethodCallArgs() { @@ -17,7 +17,7 @@ function addMethodCallArgs() namespace Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRectorTest\Fixture; -use Cake\Upgrade\Test\TestCase\Rector\MethodCall\RemoveMethodCallArgsRector\Source\SomeModelType; +use Cake\Upgrade\Test\TestCase\Rector\MethodCall\AddMethodCallArgsRector\Source\SomeModelType; function addMethodCallArgs() { From 8d0220b22137a52682b3d7a0131751133f7a0a7f Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 May 2026 22:42:08 +0700 Subject: [PATCH 3/7] final touch: fix reference --- .../RemoveMethodCallArgsRector/Fixture/fixture.php.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc b/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc index 4dbbc418..25d4969d 100644 --- a/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc +++ b/tests/TestCase/Rector/MethodCall/RemoveMethodCallArgsRector/Fixture/fixture.php.inc @@ -1,8 +1,8 @@ Date: Sun, 24 May 2026 22:45:38 +0700 Subject: [PATCH 4/7] move no namespace on purpose to stubs with classmap --- composer.json | 5 ++++- structarmed.php | 5 ----- .../Source/App.php | 12 ------------ .../Source/Xml.php | 8 -------- 4 files changed, 4 insertions(+), 26 deletions(-) delete mode 100644 tests/TestCase/Rector/Namespace_/AppUsesStaticCallToUseStatementRector/Source/App.php delete mode 100644 tests/TestCase/Rector/Namespace_/AppUsesStaticCallToUseStatementRector/Source/Xml.php diff --git a/composer.json b/composer.json index 4d410dd0..b345f14b 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,10 @@ "autoload-dev": { "psr-4": { "Cake\\Upgrade\\Test\\TestCase\\": "tests/TestCase/" - } + }, + "classmap": [ + "stubs" + ] }, "prefer-stable": true, "minimum-stability": "dev", diff --git a/structarmed.php b/structarmed.php index fde91bfa..dd754728 100644 --- a/structarmed.php +++ b/structarmed.php @@ -7,9 +7,4 @@ use Boundwize\StructArmed\Preset\Presets\Psr4Preset; return Architecture::define() - ->skip([ - Psr4Preset::CLASSES_MUST_MATCH_COMPOSER => [ - __DIR__ . '/tests/TestCase/Rector/Namespace_/AppUsesStaticCallToUseStatementRector/Source', - ], - ]) ->withPreset(Preset::PSR4()); diff --git a/tests/TestCase/Rector/Namespace_/AppUsesStaticCallToUseStatementRector/Source/App.php b/tests/TestCase/Rector/Namespace_/AppUsesStaticCallToUseStatementRector/Source/App.php deleted file mode 100644 index e5851176..00000000 --- a/tests/TestCase/Rector/Namespace_/AppUsesStaticCallToUseStatementRector/Source/App.php +++ /dev/null @@ -1,12 +0,0 @@ - Date: Sun, 24 May 2026 22:47:40 +0700 Subject: [PATCH 5/7] move source different namespace to stubs --- stubs/App.php | 12 ++++++++++++ stubs/Cake/Utility/Xml.php | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 stubs/App.php create mode 100644 stubs/Cake/Utility/Xml.php diff --git a/stubs/App.php b/stubs/App.php new file mode 100644 index 00000000..e5851176 --- /dev/null +++ b/stubs/App.php @@ -0,0 +1,12 @@ + Date: Sun, 24 May 2026 22:48:01 +0700 Subject: [PATCH 6/7] move source different namespace to stubs --- structarmed.php | 1 - 1 file changed, 1 deletion(-) diff --git a/structarmed.php b/structarmed.php index dd754728..2cd501fd 100644 --- a/structarmed.php +++ b/structarmed.php @@ -4,7 +4,6 @@ use Boundwize\StructArmed\Architecture; use Boundwize\StructArmed\Preset\Preset; -use Boundwize\StructArmed\Preset\Presets\Psr4Preset; return Architecture::define() ->withPreset(Preset::PSR4()); From 4b86db4abeb0da40a8f0e67217aa779dc767123e Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 May 2026 22:51:14 +0700 Subject: [PATCH 7/7] really final touch: move require-dev to Makefile --- Makefile | 3 ++- composer.json | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 16c57f0a..372ae5ec 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,8 @@ DEV_DEPENDENCIES = cakephp/cakephp:5.x-dev \ cakephp/cakephp-codesniffer:^5.0 \ mikey179/vfsstream:^1.6.8 \ phpunit/phpunit:^10.5.38 \ - cakephp/migrations:^4.5.0 + cakephp/migrations:^4.5.0 \ + boundwize/structarmed:^0.7.7 install-dev: composer require --dev $(DEV_DEPENDENCIES) diff --git a/composer.json b/composer.json index b345f14b..b6c74c6c 100644 --- a/composer.json +++ b/composer.json @@ -41,8 +41,5 @@ }, "support": { "source": "https://github.com/cakephp/upgrade" - }, - "require-dev": { - "boundwize/structarmed": "^0.7.7" } }