Skip to content

Commit cad7f2d

Browse files
authored
chore: Bump to Rector 2.5.2 and clean up unused skip config (#10332)
* chore: Bump to Rector ~2.5.2 and clean up unused skip config * chore: fix re-run rector * chore: fix skip bug * chore: clean up config * chore: clean up config * chore: clean up config
1 parent 18887b2 commit cad7f2d

5 files changed

Lines changed: 11 additions & 31 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"phpunit/phpcov": "^9.0.2 || ^10.0",
3030
"phpunit/phpunit": "^10.5.16 || ^11.2",
3131
"predis/predis": "^3.0",
32-
"rector/rector": "2.4.6",
32+
"rector/rector": "2.5.2",
3333
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3434
},
3535
"replace": {

rector.php

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,19 @@
2424
use Rector\Config\RectorConfig;
2525
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
2626
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
27-
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
2827
use Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector;
2928
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
3029
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
3130
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
3231
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
3332
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
34-
use Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector;
3533
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
3634
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
3735
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
3836
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
3937
use Rector\PHPUnit\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector;
4038
use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector;
39+
use Rector\PostRector\Rector\UnusedImportRemovingPostRector;
4140
use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector;
4241
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
4342
use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
@@ -96,17 +95,10 @@
9695

9796
RemoveUnusedPrivateMethodRector::class => [
9897
// private method called via getPrivateMethodInvoker
99-
__DIR__ . '/tests/system/Test/ReflectionHelperTest.php',
10098
__DIR__ . '/tests/_support/Test/TestForReflectionHelper.php',
10199
],
102100

103101
RemoveUnusedConstructorParamRector::class => [
104-
// there are deprecated parameters
105-
__DIR__ . '/system/Debug/Exceptions.php',
106-
// @TODO remove if deprecated $httpVerb is removed
107-
__DIR__ . '/system/Router/AutoRouterImproved.php',
108-
// @TODO remove if deprecated $config is removed
109-
__DIR__ . '/system/HTTP/Request.php',
110102
__DIR__ . '/system/HTTP/Response.php',
111103
],
112104

@@ -115,11 +107,6 @@
115107
__DIR__ . '/tests/system/Debug/ToolbarTest.php',
116108
],
117109

118-
// check on constant compare
119-
UnwrapFutureCompatibleIfPhpVersionRector::class => [
120-
__DIR__ . '/system/Autoloader/Autoloader.php',
121-
],
122-
123110
UnderscoreToCamelCaseVariableNameRector::class => [
124111
// session handlers have the gc() method with underscored parameter `$max_lifetime`
125112
__DIR__ . '/system/Session/Handlers',
@@ -130,10 +117,7 @@
130117
__DIR__ . '/app',
131118
__DIR__ . '/system/CodeIgniter.php',
132119
__DIR__ . '/system/Config/BaseConfig.php',
133-
__DIR__ . '/system/Commands/Generators/Views',
134-
__DIR__ . '/system/Pager/Views',
135120
__DIR__ . '/system/Test/ControllerTestTrait.php',
136-
__DIR__ . '/system/Validation/Views',
137121
__DIR__ . '/system/View/Parser.php',
138122
__DIR__ . '/tests/system/Debug/ExceptionsTest.php',
139123
],
@@ -149,15 +133,11 @@
149133
__DIR__ . '/system/Filters/Filters.php',
150134
__DIR__ . '/system/HTTP/CURLRequest.php',
151135
__DIR__ . '/system/HTTP/DownloadResponse.php',
152-
__DIR__ . '/system/HTTP/IncomingRequest.php',
153136
__DIR__ . '/system/Security/Security.php',
154137
__DIR__ . '/system/Session/Session.php',
155138
],
156139

157140
ReturnNeverTypeRector::class => [
158-
__DIR__ . '/system/Cache/Handlers/BaseHandler.php',
159-
__DIR__ . '/system/Cache/Handlers/MemcachedHandler.php',
160-
__DIR__ . '/system/Cache/Handlers/WincacheHandler.php',
161141
__DIR__ . '/system/CodeIgniter.php',
162142
__DIR__ . '/system/Database/MySQLi/Utils.php',
163143
__DIR__ . '/system/Database/OCI8/Utils.php',
@@ -166,8 +146,6 @@
166146
__DIR__ . '/system/Database/SQLite3/Utils.php',
167147
__DIR__ . '/system/HTTP/DownloadResponse.php',
168148
__DIR__ . '/system/HTTP/SiteURI.php',
169-
__DIR__ . '/system/Helpers/kint_helper.php',
170-
__DIR__ . '/tests/_support/Autoloader/FatalLocator.php',
171149
],
172150

173151
// Unnecessary (string) is inserted
@@ -197,12 +175,13 @@
197175
__DIR__ . '/tests/system/Models',
198176
],
199177

200-
StaticCallOnNonStaticToInstanceCallRector::class => [
201-
__DIR__ . '/tests/_support/Config/Services.php',
178+
UnusedImportRemovingPostRector::class => [
179+
// buggy on auto import removed
180+
__DIR__ . '/system/HTTP/Response.php',
202181
],
203182
])
204183
// auto import fully qualified class names
205-
->withImportNames(removeUnusedImports: true)
184+
->withImportNames()
206185
->withRules([
207186
DeclareStrictTypesRector::class,
208187
UnderscoreToCamelCaseVariableNameRector::class,
@@ -231,4 +210,5 @@
231210
->withConfiguredRule(RenameConstantRector::class, [
232211
'FILTER_DEFAULT' => 'FILTER_UNSAFE_RAW',
233212
])
234-
->withCodeQualityLevel(61);
213+
->withCodeQualityLevel(61)
214+
->reportUnusedSkips();

system/CLI/CLI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ public static function getOptionString(bool $useLongOpts = false, bool $trim = f
10121012
continue;
10131013
}
10141014

1015-
if (mb_strpos($value, ' ') !== false) {
1015+
if (str_contains($value, ' ')) {
10161016
$out .= "\"{$value}\" ";
10171017
} elseif ($value !== null) {
10181018
$out .= "{$value} ";

system/HTTP/CLIRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function getOptionString(bool $useLongOpts = false): string
164164
continue;
165165
}
166166

167-
if (mb_strpos($value, ' ') !== false) {
167+
if (str_contains($value, ' ')) {
168168
$out .= '"' . $value . '" ';
169169
} else {
170170
$out .= "{$value} ";

system/Test/DOMParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function see(?string $search = null, ?string $element = null): bool
112112
if ($element === null) {
113113
$content = $this->dom->saveHTML($this->dom->documentElement);
114114

115-
return mb_strpos($content, $search) !== false;
115+
return str_contains($content, $search);
116116
}
117117

118118
$result = $this->doXPath($search, $element);

0 commit comments

Comments
 (0)