Skip to content

Commit 59d9520

Browse files
authored
refactor: update rector config for latest changes (#9989)
* remove skipped rules that no longer applies * do not skip `AssertFuncCallToPHPUnitAssertRector` * do not skip `StaticCallOnNonStaticToInstanceCallRector`
1 parent 651988a commit 59d9520

File tree

3 files changed

+6
-40
lines changed

3 files changed

+6
-40
lines changed

rector.php

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,17 @@
2222
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
2323
use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector;
2424
use Rector\Config\RectorConfig;
25-
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
2625
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
27-
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
2826
use Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector;
2927
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
3028
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
3129
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
3230
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
3331
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
34-
use Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector;
3532
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
3633
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
3734
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
3835
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
39-
use Rector\PHPUnit\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector;
4036
use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector;
4137
use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector;
4238
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
@@ -99,26 +95,11 @@
9995
__DIR__ . '/tests/_support/Test/TestForReflectionHelper.php',
10096
],
10197

102-
RemoveUnusedConstructorParamRector::class => [
103-
// there are deprecated parameters
104-
__DIR__ . '/system/Debug/Exceptions.php',
105-
// @TODO remove if deprecated $httpVerb is removed
106-
__DIR__ . '/system/Router/AutoRouterImproved.php',
107-
// @TODO remove if deprecated $config is removed
108-
__DIR__ . '/system/HTTP/Request.php',
109-
__DIR__ . '/system/HTTP/Response.php',
110-
],
111-
11298
// Exclude test file because `is_cli()` is mocked and Rector might remove needed parameters.
11399
RemoveExtraParametersRector::class => [
114100
__DIR__ . '/tests/system/Debug/ToolbarTest.php',
115101
],
116102

117-
// check on constant compare
118-
UnwrapFutureCompatibleIfPhpVersionRector::class => [
119-
__DIR__ . '/system/Autoloader/Autoloader.php',
120-
],
121-
122103
UnderscoreToCamelCaseVariableNameRector::class => [
123104
// session handlers have the gc() method with underscored parameter `$max_lifetime`
124105
__DIR__ . '/system/Session/Handlers',
@@ -137,6 +118,10 @@
137118
__DIR__ . '/tests/system/Debug/ExceptionsTest.php',
138119
],
139120

121+
DeclareStrictTypesTestsRector::class => [
122+
__DIR__ . '/tests/system/Debug/ExceptionsTest.php',
123+
],
124+
140125
// use mt_rand instead of random_int on purpose on non-cryptographically random
141126
RandomFunctionRector::class,
142127

@@ -153,19 +138,13 @@
153138
],
154139

155140
ReturnNeverTypeRector::class => [
156-
__DIR__ . '/system/Cache/Handlers/BaseHandler.php',
157-
__DIR__ . '/system/Cache/Handlers/MemcachedHandler.php',
158-
__DIR__ . '/system/Cache/Handlers/WincacheHandler.php',
159-
__DIR__ . '/system/CodeIgniter.php',
160141
__DIR__ . '/system/Database/MySQLi/Utils.php',
161142
__DIR__ . '/system/Database/OCI8/Utils.php',
162143
__DIR__ . '/system/Database/Postgre/Utils.php',
163144
__DIR__ . '/system/Database/SQLSRV/Utils.php',
164145
__DIR__ . '/system/Database/SQLite3/Utils.php',
165146
__DIR__ . '/system/HTTP/DownloadResponse.php',
166147
__DIR__ . '/system/HTTP/SiteURI.php',
167-
__DIR__ . '/system/Helpers/kint_helper.php',
168-
__DIR__ . '/tests/_support/Autoloader/FatalLocator.php',
169148
],
170149

171150
// Unnecessary (string) is inserted
@@ -176,28 +155,15 @@
176155
// possibly isset() on purpose, on updated Config classes property accross versions
177156
IssetOnPropertyObjectToPropertyExistsRector::class,
178157

179-
AssertFuncCallToPHPUnitAssertRector::class => [
180-
// use $this inside static closure
181-
__DIR__ . '/tests/system/AutoReview/FrameworkCodeTest.php',
182-
],
183-
184158
// some tests extended by other tests
185159
FinalizeTestCaseClassRector::class,
186160

187-
DeclareStrictTypesTestsRector::class => [
188-
__DIR__ . '/tests/system/Debug/ExceptionsTest.php',
189-
],
190-
191161
RemoveNullArgOnNullDefaultParamRector::class => [
192162
// skip form query usage, easier to read
193163
__DIR__ . '/system/Model.php',
194164
__DIR__ . '/tests/system/Database',
195165
__DIR__ . '/tests/system/Models',
196166
],
197-
198-
StaticCallOnNonStaticToInstanceCallRector::class => [
199-
__DIR__ . '/tests/_support/Config/Services.php',
200-
],
201167
])
202168
// auto import fully qualified class names
203169
->withImportNames(removeUnusedImports: true)

tests/_support/Config/Services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static function uri(?string $uri = null, bool $getShared = true): URI
4545

4646
if ($uri === null) {
4747
$appConfig = config(App::class);
48-
$factory = new SiteURIFactory($appConfig, Services::superglobals());
48+
$factory = new SiteURIFactory($appConfig, static::superglobals());
4949

5050
return $factory->createFromGlobals();
5151
}

tests/system/AutoReview/FrameworkCodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testEachTestClassHasCorrectGroupAttributeName(string $class): vo
6262
$unrecognizedGroups = array_diff(
6363
array_map(static function (ReflectionAttribute $attribute): string {
6464
$groupAttribute = $attribute->newInstance();
65-
assert($groupAttribute instanceof Group);
65+
self::assertInstanceOf(Group::class, $groupAttribute);
6666

6767
return $groupAttribute->name();
6868
}, $attributes),

0 commit comments

Comments
 (0)