From 9c192d2f5d8db30dd1af703e6031f74a97499b9f Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 22 Jun 2026 20:27:59 +0700 Subject: [PATCH 1/6] chore: Bump to Rector ~2.5.2 and clean up unused skip config --- composer.json | 2 +- rector.php | 30 ++---------------------------- system/CLI/CLI.php | 2 +- system/HTTP/CLIRequest.php | 2 +- system/HTTP/Response.php | 1 - system/Test/DOMParser.php | 2 +- 6 files changed, 6 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index 6f15a3622b7a..9de4dacdf72f 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "phpunit/phpcov": "^9.0.2 || ^10.0", "phpunit/phpunit": "^10.5.16 || ^11.2", "predis/predis": "^3.0", - "rector/rector": "2.4.6", + "rector/rector": "2.5.2", "shipmonk/phpstan-baseline-per-identifier": "^2.0" }, "replace": { diff --git a/rector.php b/rector.php index 4552a898aee3..05a5e6dae07b 100644 --- a/rector.php +++ b/rector.php @@ -24,14 +24,12 @@ use Rector\Config\RectorConfig; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector; -use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector; use Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector; use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\Php70\Rector\FuncCall\RandomFunctionRector; -use Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; @@ -96,17 +94,10 @@ RemoveUnusedPrivateMethodRector::class => [ // private method called via getPrivateMethodInvoker - __DIR__ . '/tests/system/Test/ReflectionHelperTest.php', __DIR__ . '/tests/_support/Test/TestForReflectionHelper.php', ], RemoveUnusedConstructorParamRector::class => [ - // there are deprecated parameters - __DIR__ . '/system/Debug/Exceptions.php', - // @TODO remove if deprecated $httpVerb is removed - __DIR__ . '/system/Router/AutoRouterImproved.php', - // @TODO remove if deprecated $config is removed - __DIR__ . '/system/HTTP/Request.php', __DIR__ . '/system/HTTP/Response.php', ], @@ -115,11 +106,6 @@ __DIR__ . '/tests/system/Debug/ToolbarTest.php', ], - // check on constant compare - UnwrapFutureCompatibleIfPhpVersionRector::class => [ - __DIR__ . '/system/Autoloader/Autoloader.php', - ], - UnderscoreToCamelCaseVariableNameRector::class => [ // session handlers have the gc() method with underscored parameter `$max_lifetime` __DIR__ . '/system/Session/Handlers', @@ -130,10 +116,7 @@ __DIR__ . '/app', __DIR__ . '/system/CodeIgniter.php', __DIR__ . '/system/Config/BaseConfig.php', - __DIR__ . '/system/Commands/Generators/Views', - __DIR__ . '/system/Pager/Views', __DIR__ . '/system/Test/ControllerTestTrait.php', - __DIR__ . '/system/Validation/Views', __DIR__ . '/system/View/Parser.php', __DIR__ . '/tests/system/Debug/ExceptionsTest.php', ], @@ -149,15 +132,11 @@ __DIR__ . '/system/Filters/Filters.php', __DIR__ . '/system/HTTP/CURLRequest.php', __DIR__ . '/system/HTTP/DownloadResponse.php', - __DIR__ . '/system/HTTP/IncomingRequest.php', __DIR__ . '/system/Security/Security.php', __DIR__ . '/system/Session/Session.php', ], ReturnNeverTypeRector::class => [ - __DIR__ . '/system/Cache/Handlers/BaseHandler.php', - __DIR__ . '/system/Cache/Handlers/MemcachedHandler.php', - __DIR__ . '/system/Cache/Handlers/WincacheHandler.php', __DIR__ . '/system/CodeIgniter.php', __DIR__ . '/system/Database/MySQLi/Utils.php', __DIR__ . '/system/Database/OCI8/Utils.php', @@ -166,8 +145,6 @@ __DIR__ . '/system/Database/SQLite3/Utils.php', __DIR__ . '/system/HTTP/DownloadResponse.php', __DIR__ . '/system/HTTP/SiteURI.php', - __DIR__ . '/system/Helpers/kint_helper.php', - __DIR__ . '/tests/_support/Autoloader/FatalLocator.php', ], // Unnecessary (string) is inserted @@ -196,10 +173,6 @@ __DIR__ . '/tests/system/Database', __DIR__ . '/tests/system/Models', ], - - StaticCallOnNonStaticToInstanceCallRector::class => [ - __DIR__ . '/tests/_support/Config/Services.php', - ], ]) // auto import fully qualified class names ->withImportNames(removeUnusedImports: true) @@ -231,4 +204,5 @@ ->withConfiguredRule(RenameConstantRector::class, [ 'FILTER_DEFAULT' => 'FILTER_UNSAFE_RAW', ]) - ->withCodeQualityLevel(61); + ->withCodeQualityLevel(61) + ->reportUnusedSkips(); diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 9cdbbbada0b5..d26681213914 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -1012,7 +1012,7 @@ public static function getOptionString(bool $useLongOpts = false, bool $trim = f continue; } - if (mb_strpos($value, ' ') !== false) { + if (str_contains($value, ' ')) { $out .= "\"{$value}\" "; } elseif ($value !== null) { $out .= "{$value} "; diff --git a/system/HTTP/CLIRequest.php b/system/HTTP/CLIRequest.php index bde4e1b8e3f8..453272a4f59a 100644 --- a/system/HTTP/CLIRequest.php +++ b/system/HTTP/CLIRequest.php @@ -164,7 +164,7 @@ public function getOptionString(bool $useLongOpts = false): string continue; } - if (mb_strpos($value, ' ') !== false) { + if (str_contains($value, ' ')) { $out .= '"' . $value . '" '; } else { $out .= "{$value} "; diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php index 3c59f2e9800d..1e4af4142d0c 100644 --- a/system/HTTP/Response.php +++ b/system/HTTP/Response.php @@ -16,7 +16,6 @@ use CodeIgniter\Cookie\Cookie; use CodeIgniter\Cookie\CookieStore; use CodeIgniter\HTTP\Exceptions\HTTPException; -use Config\App; use Config\Cookie as CookieConfig; /** diff --git a/system/Test/DOMParser.php b/system/Test/DOMParser.php index d8521edfbc86..52765a4d656b 100644 --- a/system/Test/DOMParser.php +++ b/system/Test/DOMParser.php @@ -112,7 +112,7 @@ public function see(?string $search = null, ?string $element = null): bool if ($element === null) { $content = $this->dom->saveHTML($this->dom->documentElement); - return mb_strpos($content, $search) !== false; + return str_contains($content, $search); } $result = $this->doXPath($search, $element); From 34e4546bcf8606f78d4cace1daa27d72865bd6d3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 22 Jun 2026 20:33:46 +0700 Subject: [PATCH 2/6] chore: fix re-run rector --- system/HTTP/Response.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php index 1e4af4142d0c..3c59f2e9800d 100644 --- a/system/HTTP/Response.php +++ b/system/HTTP/Response.php @@ -16,6 +16,7 @@ use CodeIgniter\Cookie\Cookie; use CodeIgniter\Cookie\CookieStore; use CodeIgniter\HTTP\Exceptions\HTTPException; +use Config\App; use Config\Cookie as CookieConfig; /** From b1e20fef37983c46290aa82bb19f8535d71225d2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 22 Jun 2026 20:35:00 +0700 Subject: [PATCH 3/6] chore: fix skip bug --- rector.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rector.php b/rector.php index 05a5e6dae07b..b9cdcd0b35ec 100644 --- a/rector.php +++ b/rector.php @@ -173,6 +173,9 @@ __DIR__ . '/tests/system/Database', __DIR__ . '/tests/system/Models', ], + + // buggy on auto import removed + __DIR__ . '/system/HTTP/Response.php', ]) // auto import fully qualified class names ->withImportNames(removeUnusedImports: true) From 02ffeb5097d1ce205f44ed84b61f6e44947f78d6 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 22 Jun 2026 20:46:26 +0700 Subject: [PATCH 4/6] chore: clean up config --- rector.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/rector.php b/rector.php index b9cdcd0b35ec..0a91be617f2d 100644 --- a/rector.php +++ b/rector.php @@ -22,7 +22,6 @@ use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector; use Rector\Config\RectorConfig; -use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector; use Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; @@ -97,10 +96,6 @@ __DIR__ . '/tests/_support/Test/TestForReflectionHelper.php', ], - RemoveUnusedConstructorParamRector::class => [ - __DIR__ . '/system/HTTP/Response.php', - ], - // Exclude test file because `is_cli()` is mocked and Rector might remove needed parameters. RemoveExtraParametersRector::class => [ __DIR__ . '/tests/system/Debug/ToolbarTest.php', From 9755978300ad62502b3514a0b84b291bc8ac6daf Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 22 Jun 2026 20:47:10 +0700 Subject: [PATCH 5/6] chore: clean up config --- rector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 0a91be617f2d..b0b9da14b65c 100644 --- a/rector.php +++ b/rector.php @@ -173,7 +173,7 @@ __DIR__ . '/system/HTTP/Response.php', ]) // auto import fully qualified class names - ->withImportNames(removeUnusedImports: true) + ->withImportNames() ->withRules([ DeclareStrictTypesRector::class, UnderscoreToCamelCaseVariableNameRector::class, From 4f6aca25a236c68a023d17aa17007a44e5a08497 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 22 Jun 2026 20:52:16 +0700 Subject: [PATCH 6/6] chore: clean up config --- rector.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rector.php b/rector.php index b0b9da14b65c..cfcbbd236bad 100644 --- a/rector.php +++ b/rector.php @@ -22,6 +22,7 @@ use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector; use Rector\Config\RectorConfig; +use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector; use Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; @@ -35,6 +36,7 @@ use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; use Rector\PHPUnit\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector; use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector; +use Rector\PostRector\Rector\UnusedImportRemovingPostRector; use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector; use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; use Rector\Renaming\Rector\ConstFetch\RenameConstantRector; @@ -96,6 +98,10 @@ __DIR__ . '/tests/_support/Test/TestForReflectionHelper.php', ], + RemoveUnusedConstructorParamRector::class => [ + __DIR__ . '/system/HTTP/Response.php', + ], + // Exclude test file because `is_cli()` is mocked and Rector might remove needed parameters. RemoveExtraParametersRector::class => [ __DIR__ . '/tests/system/Debug/ToolbarTest.php', @@ -169,8 +175,10 @@ __DIR__ . '/tests/system/Models', ], - // buggy on auto import removed - __DIR__ . '/system/HTTP/Response.php', + UnusedImportRemovingPostRector::class => [ + // buggy on auto import removed + __DIR__ . '/system/HTTP/Response.php', + ], ]) // auto import fully qualified class names ->withImportNames()