From 0c85c88b5ed8999c39879c6d7f54f7f8f692d92e Mon Sep 17 00:00:00 2001 From: Daniele Barbaro Date: Tue, 8 Sep 2026 08:46:07 +0200 Subject: [PATCH 1/2] ci(rector): run the refactoring check on every build Rector was added with the dev dependencies but left out of both the aggregate test script and the workflow, because it could not be verified at the time. It now passes clean on Laravel 12 and 13, so it joins the chain after the formatting check and gets its own step. The step skips Windows, matching type coverage and the test suite. The check describes code shape rather than runtime behaviour, so the eight Linux rows already cover both supported Laravel versions and both PHP versions. Claude-Session: https://claude.ai/code/session_0131mg78D5c5ao3zWZ5c8sDX --- .github/workflows/tests.yml | 4 ++++ README.md | 20 ++++++++++++++------ composer.json | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 40dc8ea..e5fb17a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -58,6 +58,10 @@ jobs: - name: Linter run: composer lint:check + - name: Rector + if: runner.os != 'Windows' + run: composer rector:check + - name: Type Coverage if: runner.os != 'Windows' run: composer test:types diff --git a/README.md b/README.md index 2df0938..5460480 100644 --- a/README.md +++ b/README.md @@ -758,14 +758,22 @@ the filter that serves it, since the built in filter refuses an operation it doe composer test ``` -That runs static analysis, the formatting check, the type coverage check and the test -suite. Each step is also available on its own: +That runs static analysis, the formatting check, the refactoring check, the type coverage +check and the test suite. Each step is also available on its own: ```bash -composer analyse # PHPStan -composer lint:check # Pint, in check mode -composer test:types # Pest type coverage -composer test:unit # Pest +composer analyse # PHPStan +composer lint:check # Pint, in check mode +composer rector:check # Rector, as a dry run +composer test:types # Pest type coverage +composer test:unit # Pest +``` + +`composer lint` applies the formatting rather than checking it. Rector has no apply script +on purpose, so a refactoring it proposes is read before it is taken: + +```bash +vendor/bin/rector process ``` ## Contributing diff --git a/composer.json b/composer.json index bec7637..3d7c32f 100644 --- a/composer.json +++ b/composer.json @@ -94,6 +94,7 @@ "test": [ "@analyse", "@lint:check", + "@rector:check", "@test:types", "@test:unit" ], From 344e3dc6d8632d0fb07fe5fabf4bdca5c7a6c173 Mon Sep 17 00:00:00 2001 From: Daniele Barbaro Date: Tue, 8 Sep 2026 08:52:22 +0200 Subject: [PATCH 2/2] build(rector): require the versions the config depends on rector.php skips three rules by class name, and Rector fails hard when a skipped rule does not exist. On a prefer-lowest build the previous constraints resolved rector 2.0.0 and rector-laravel 2.0.0, where none of the three had been written yet: [ERROR] These rules from "$rectorConfig->skip()" does not exist * RectorLaravel\Rector\FuncCall\AppToResolveRector * RectorLaravel\Rector\ClassMethod\MakeModelAttributesAndScopesProtectedRector * Rector\Php84\Rector\MethodCall\NewMethodCallWithoutParenthesesRector Both constraints move to ^2.6, the range that carries them. Verified on the two ends of the matrix: Laravel 12 with prefer-lowest, which resolves rector 2.6.4 and rector-laravel 2.6.1, and Laravel 13 with prefer-stable. Both dependencies are dev only, so nothing changes for an application installing the package. Claude-Session: https://claude.ai/code/session_0131mg78D5c5ao3zWZ5c8sDX --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3d7c32f..5198d9a 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "spatie/laravel-query-builder": "^7.3.1" }, "require-dev": { - "driftingly/rector-laravel": "^2.0", + "driftingly/rector-laravel": "^2.6", "larastan/larastan": "^3.9", "laravel/pao": "^1.0", "laravel/pint": "^1.29", @@ -42,7 +42,7 @@ "phpstan/extension-installer": "^1.4", "phpstan/phpstan-deprecation-rules": "^2.0", "phpstan/phpstan-phpunit": "^2.0", - "rector/rector": "^2.0" + "rector/rector": "^2.6" }, "autoload": { "psr-4": {