forked from redaxo/redaxo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrector.php
102 lines (90 loc) · 4.67 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
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\Assign\CombinedAssignRector;
use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector;
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector;
use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector;
use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector;
use Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector;
use Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
use Rector\CodeQuality\Rector\NullsafeMethodCall\CleanupUnneededNullsafeOperatorRector;
use Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector;
use Rector\Config\RectorConfig;
use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector;
use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector;
use Rector\Php80\Rector\Identical\StrEndsWithRector;
use Rector\Php80\Rector\Identical\StrStartsWithRector;
use Rector\Php80\Rector\NotIdentical\StrContainsRector;
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\ValueObject\PhpVersion;
use Redaxo\Rector\Rule\UnderscoreToCamelCasePropertyNameRector;
use Redaxo\Rector\Rule\UnderscoreToCamelCaseVariableNameRector;
use Redaxo\Rector\Util\UnderscoreCamelCaseConflictingNameGuard;
use Redaxo\Rector\Util\UnderscoreCamelCaseExpectedNameResolver;
use Redaxo\Rector\Util\UnderscoreCamelCasePropertyRenamer;
require_once __DIR__ . '/.tools/rector/autoload.php';
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->bootstrapFiles([
__DIR__ . '/.tools/constants.php',
]);
// this list will grow over time.
// to make sure we can review every transformation and not introduce unseen bugs
$rectorConfig->paths([
// restrict to core and core addons, ignore other locally installed addons
'redaxo/src/core/',
'redaxo/src/addons/backup/',
'redaxo/src/addons/be_style/',
'redaxo/src/addons/cronjob/',
'redaxo/src/addons/debug/',
'redaxo/src/addons/install/',
'redaxo/src/addons/media_manager/',
'redaxo/src/addons/mediapool/',
'redaxo/src/addons/metainfo/',
'redaxo/src/addons/phpmailer/',
'redaxo/src/addons/project/',
'redaxo/src/addons/structure/',
'redaxo/src/addons/users/',
]);
$rectorConfig->skip([
'redaxo/src/core/vendor',
'redaxo/src/addons/backup/vendor',
'redaxo/src/addons/be_style/vendor',
'redaxo/src/addons/debug/vendor',
'redaxo/src/addons/phpmailer/vendor',
FirstClassCallableRector::class => ['redaxo/src/core/boot.php'],
]);
$rectorConfig->parallel();
$rectorConfig->phpVersion(PhpVersion::PHP_81);
// we will grow this rector list step by step.
// after some basic rectors have been enabled we can finally enable whole-sets (when diffs get stable and reviewable)
$rectorConfig->rule(ChangeSwitchToMatchRector::class);
$rectorConfig->rule(CleanupUnneededNullsafeOperatorRector::class);
$rectorConfig->rule(CombinedAssignRector::class);
$rectorConfig->rule(FirstClassCallableRector::class);
$rectorConfig->rule(IfIssetToCoalescingRector::class);
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
$rectorConfig->rule(RemoveUnusedVariableInCatchRector::class);
$rectorConfig->rule(SimplifyBoolIdenticalTrueRector::class);
$rectorConfig->rule(SimplifyConditionsRector::class);
$rectorConfig->rule(SimplifyDeMorganBinaryRector::class);
$rectorConfig->rule(SimplifyForeachToCoalescingRector::class);
$rectorConfig->rule(SimplifyIfReturnBoolRector::class);
$rectorConfig->rule(SimplifyRegexPatternRector::class);
$rectorConfig->rule(SingleInArrayToCompareRector::class);
$rectorConfig->rule(StrContainsRector::class);
$rectorConfig->rule(StrEndsWithRector::class);
$rectorConfig->rule(StrStartsWithRector::class);
$rectorConfig->rule(TernaryToNullCoalescingRector::class);
// Util services for own rules;
$rectorConfig->singleton(UnderscoreCamelCaseConflictingNameGuard::class);
$rectorConfig->singleton(UnderscoreCamelCaseExpectedNameResolver::class);
$rectorConfig->singleton(UnderscoreCamelCasePropertyRenamer::class);
// Own rules
$rectorConfig->rule(UnderscoreToCamelCasePropertyNameRector::class);
$rectorConfig->rule(UnderscoreToCamelCaseVariableNameRector::class);
$rectorConfig->rule(UnnecessaryTernaryExpressionRector::class);
};