forked from RetroAchievements/RAWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrector.php
115 lines (102 loc) · 4.94 KB
/
rector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodeQuality\Rector\Assign\CombinedAssignRector;
use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector;
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodeQuality\Rector\For_\ForToForeachRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessLastVariableAssignRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector;
use Rector\CodeQuality\Rector\If_\CombineIfRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
use Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector;
use Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector;
use Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector;
use Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector;
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector;
use Rector\Php71\Rector\FuncCall\CountOnNullRector;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;
use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
use RectorLaravel\Set\LaravelSetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->paths([
// __DIR__ . '/app', // TODO
__DIR__ . '/app_legacy',
__DIR__ . '/config',
__DIR__ . '/database',
__DIR__ . '/lang',
__DIR__ . '/public',
__DIR__ . '/resources',
__DIR__ . '/tests',
]);
$rectorConfig->rules([
InlineConstructorDefaultToPropertyRector::class,
]);
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
SetList::TYPE_DECLARATION,
LaravelSetList::LARAVEL_90,
LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelSetList::LARAVEL_ARRAY_STR_FUNCTION_TO_STATIC_CALL,
LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES,
]);
$rectorConfig->skip([
__DIR__ . '/app_legacy/Helpers/util/recaptcha.php',
// LevelSetList::UP_TO_PHP_XX
CountOnNullRector::class,
JsonThrowOnErrorRector::class,
// SetList::CODE_QUALITY
CallableThisArrayToAnonymousFunctionRector::class,
CombinedAssignRector::class,
CombineIfRector::class,
ExplicitBoolCompareRector::class, // TODO re-enable for PHPStan level 7+
FlipTypeControlToUseExclusiveTypeRector::class,
ForToForeachRector::class,
SimplifyConditionsRector::class,
SimplifyDeMorganBinaryRector::class,
SimplifyEmptyCheckOnEmptyArrayRector::class,
SwitchNegatedTernaryRector::class,
ShortenElseIfRector::class,
SimplifyIfReturnBoolRector::class,
SimplifyUselessLastVariableAssignRector::class,
// SetList::DEAD_CODE
RemoveDeadConditionAboveReturnRector::class,
RemoveNullPropertyInitializationRector::class,
RemoveUnreachableStatementRector::class,
RemoveUnusedPrivateMethodParameterRector::class,
SimplifyUselessVariableRector::class,
// SetList::EARLY_RETURN
ChangeAndIfToEarlyReturnRector::class,
ChangeNestedForeachIfsToEarlyContinueRector::class,
ChangeOrIfContinueToMultiContinueRector::class,
ChangeOrIfReturnToEarlyReturnRector::class,
// SetList::TYPE_DECLARATION,
AddArrowFunctionReturnTypeRector::class,
AddClosureReturnTypeRector::class,
AddVoidReturnTypeWhereNoReturnRector::class,
ArrayShapeFromConstantArrayReturnRector::class,
ReturnTypeFromReturnDirectArrayRector::class,
ReturnTypeFromStrictTypedCallRector::class, // TODO re-enable for PHPStan level 7+
]);
};