Skip to content

Commit c69dda1

Browse files
authored
refactor: update rector dependency and configuration (#533)
1 parent 108d429 commit c69dda1

File tree

1 file changed

+39
-43
lines changed

1 file changed

+39
-43
lines changed

rector.php

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\Core\Configuration\Option;
76
use Rector\Core\ValueObject\PhpVersion;
87
use Rector\Set\ValueObject\SetList;
98
use RectorLaravel\Set\LaravelSetList;
109

1110
return static function (RectorConfig $rectorConfig): void {
12-
$parameters = $rectorConfig->parameters();
13-
$services = $rectorConfig->services();
14-
$dir = getcwd();
11+
$dir = getcwd();
1512

1613
$rectorConfig->sets([
1714
SetList::PRIVATIZATION,
@@ -30,17 +27,15 @@
3027
*/
3128
$rectorConfig->bootstrapFiles([$dir.'/vendor/arkecosystem/foundation/rector-bootstrap.php']);
3229

33-
$parameters->set(Option::PATHS, [
30+
$rectorConfig->paths([
3431
$dir.'/app',
3532
]);
3633

37-
$parameters->set(Option::SKIP, [
34+
$rectorConfig->skip([
3835
// skip Livewire
3936
$dir.'/app/Http/Livewire',
40-
$dir.'/app/App/Blog/Components',
4137
$dir.'/app/App/Collaborator/Components',
4238
$dir.'/app/App/Http/Components',
43-
$dir.'/app/App/Platform/Components',
4439
$dir.'/app/App/SecureShell/Components',
4540
$dir.'/app/App/Server/Components',
4641
$dir.'/app/App/Token/Components',
@@ -60,49 +55,50 @@
6055
$rectorConfig->phpstanConfig($neon);
6156
}
6257

63-
$services->remove(\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class);
64-
$services->remove(\Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector::class);
65-
$services->remove(\Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
66-
$services->remove(\Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
67-
$services->remove(\Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector::class);
68-
$services->remove(\Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class);
69-
$services->remove(\Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector::class);
70-
$services->remove(\Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class);
71-
$services->remove(\Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector::class);
72-
$services->remove(\Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class);
73-
$services->remove(\Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class);
58+
$rectorConfig->skip([
59+
\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class,
60+
\Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector::class,
61+
\Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class,
62+
\Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector::class,
63+
\Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector::class,
64+
\Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class,
65+
\Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector::class,
66+
\Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class,
67+
\Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector::class,
68+
\Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class,
69+
\Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class,
70+
]);
7471

7572
// Restoration
76-
$services->set(\Rector\Restoration\Rector\Property\MakeTypedPropertyNullableIfCheckedRector::class);
73+
$rectorConfig->rule(\Rector\Restoration\Rector\Property\MakeTypedPropertyNullableIfCheckedRector::class);
7774

7875
// php5.5
79-
$services->set(\Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector::class);
76+
$rectorConfig->rule(\Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector::class);
8077

8178
// php7.4
82-
$services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class);
83-
$services->set(\Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector::class);
84-
$services->set(\Rector\Php74\Rector\Assign\NullCoalescingOperatorRector::class);
85-
$services->set(\Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class);
79+
$rectorConfig->rule(\Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector::class);
80+
$rectorConfig->rule(\Rector\Php74\Rector\Assign\NullCoalescingOperatorRector::class);
81+
$rectorConfig->rule(\Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class);
8682

8783
// php8.0
88-
$services->set(\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class);
89-
$services->set(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class);
90-
$services->set(\Rector\Php80\Rector\Identical\StrStartsWithRector::class);
91-
$services->set(\Rector\Php80\Rector\Identical\StrEndsWithRector::class);
92-
$services->set(\Rector\Php80\Rector\Class_\StringableForToStringRector::class);
93-
$services->set(\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class);
94-
$services->set(\Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class);
95-
$services->set(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class);
96-
$services->set(\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class);
97-
$services->set(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
98-
$services->set(\Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class);
99-
$services->set(\Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class);
100-
$services->set(\Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class);
84+
$rectorConfig->rule(\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class);
85+
$rectorConfig->rule(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class);
86+
$rectorConfig->rule(\Rector\Php80\Rector\Identical\StrStartsWithRector::class);
87+
$rectorConfig->rule(\Rector\Php80\Rector\Identical\StrEndsWithRector::class);
88+
$rectorConfig->rule(\Rector\Php80\Rector\Class_\StringableForToStringRector::class);
89+
$rectorConfig->rule(\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class);
90+
$rectorConfig->rule(\Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class);
91+
$rectorConfig->rule(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class);
92+
$rectorConfig->rule(\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class);
93+
$rectorConfig->rule(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
94+
$rectorConfig->rule(\Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class);
95+
$rectorConfig->rule(\Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class);
96+
$rectorConfig->rule(\Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class);
10197

10298
// php8.1
103-
$services->set(\Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector::class);
104-
$services->set(\Rector\Php81\Rector\Property\ReadOnlyPropertyRector::class);
105-
$services->set(\Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector::class);
106-
$services->set(\Rector\Php81\Rector\FuncCall\Php81ResourceReturnToObjectRector::class);
107-
$services->set(\Rector\Php81\Rector\FunctionLike\IntersectionTypesRector::class);
99+
$rectorConfig->rule(\Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector::class);
100+
$rectorConfig->rule(\Rector\Php81\Rector\Property\ReadOnlyPropertyRector::class);
101+
$rectorConfig->rule(\Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector::class);
102+
$rectorConfig->rule(\Rector\Php81\Rector\FuncCall\Php81ResourceReturnToObjectRector::class);
103+
$rectorConfig->rule(\Rector\Php81\Rector\FunctionLike\IntersectionTypesRector::class);
108104
};

0 commit comments

Comments
 (0)