-
-
Notifications
You must be signed in to change notification settings - Fork 453
Expand file tree
/
Copy path.rector.php
More file actions
188 lines (185 loc) · 9.93 KB
/
.rector.php
File metadata and controls
188 lines (185 loc) · 9.93 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
declare(strict_types=1);
use OpenMage\Rector\Migration;
use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector;
use Rector\Carbon\Rector as Carbon;
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector as CodeQuality;
use Rector\CodingStyle\Rector as CodingStyle;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector as DeadCode;
use Rector\EarlyReturn\Rector as EarlyReturn;
use Rector\Exception\Configuration\InvalidConfigurationException;
use Rector\Php53\Rector as Php53;
use Rector\Php71\Rector as Php71;
use Rector\Php73\Rector as Php73;
use Rector\Php74\Rector as Php74;
use Rector\Php80\Rector as Php80;
use Rector\Php81\Rector as Php81;
use Rector\Php82\Rector as Php82;
use Rector\Php83\Rector as Php83;
use Rector\Php84\Rector as Php84;
use Rector\Php85\Rector as Php85;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\Privatization\Rector as Privatization;
use Rector\Renaming\Rector as Renaming;
use Rector\Strict\Rector as Strict;
use Rector\Transform\Rector as Transform;
use Rector\TypeDeclaration\Rector as TypeDeclaration;
try {
return RectorConfig::configure()
->withFileExtensions(['php', 'phtml'])
->withCache(
cacheDirectory: __DIR__ . '/.cache/.rector.result.cache',
cacheClass: FileCacheStorage::class,
)
->withImportNames(removeUnusedImports: true)
->withPhpSets(
php81: true,
)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: false,
privatization: true,
naming: false,
instanceOf: true,
earlyReturn: true,
strictBooleans: false,
carbon: true,
rectorPreset: true,
phpunitCodeQuality: true,
doctrineCodeQuality: false,
symfonyCodeQuality: false,
symfonyConfigs: false,
)
->withPaths([
__DIR__,
])
->withSkipPath(__DIR__ . '/vendor')
->withRules([
Php85\ArrayDimFetch\ArrayFirstLastRector::class,
])
->withRules(Migration\TypeDeclarationDocblocks::getRules())
->withConfiguredRule(Renaming\ClassConstFetch\RenameClassConstFetchRector::class, Migration\Zend\Log::renameClassConst())
->withConfiguredRule(Renaming\ClassConstFetch\RenameClassConstFetchRector::class, Migration\Zend\Measure::renameClassConst())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Admin::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Adminhtml::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Bundle::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Catalog::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\CatalogSearch::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\ConfigurableSwatches::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Checkout::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Core::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Eav::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Paypal::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Shipping::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Sitemap::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Tag::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Tax::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Usa::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Mage\Wishlist::renameMethod())
->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, Migration\Zend\Acl::renameMethod())
->withConfiguredRule(ReplaceArgumentDefaultValueRector::class, Migration\Mage\Adminhtml::replaceArgumentDefaultValue())
# skip: do not apply
->withSkip([
# skip avoid renaming of methods in tests
Carbon\FuncCall\DateFuncCallToCarbonRector::class => [
__DIR__ . '/tests/unit/Base/CarbonTest.php',
],
# skip avoid renaming of methods in tests
Carbon\FuncCall\TimeFuncCallToCarbonRector::class => [
__DIR__ . '/tests/unit/Base/CarbonTest.php',
],
# skip adding dynamic property to class ... not sure about
CodeQuality\Class_\CompleteDynamicPropertiesRector::class => [
__DIR__ . '/lib/3Dsecure/XMLParser.php',
],
# skip classes that throw an exception as a return value, which is not supported by Rector yet
# see https://github.com/rectorphp/rector/issues/9719
CodeQuality\ClassMethod\ExplicitReturnNullRector::class => [
__DIR__ . '/app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php',
__DIR__ . '/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php',
__DIR__ . '/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php',
__DIR__ . '/app/code/core/Mage/ImportExport/Model/Export.php',
__DIR__ . '/app/code/core/Mage/Oauth/Model/Token.php',
__DIR__ . '/app/code/core/Mage/Paygate/Model/Authorizenet.php',
__DIR__ . '/app/code/core/Mage/Sales/Model/Order/Payment.php',
__DIR__ . '/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract/Backend/Abstract.php',
],
# changes method signature
CodingStyle\ClassMethod\FuncGetArgsToVariadicParamRector::class,
# skip: conflicts with phpstan strict rules
Php53\Ternary\TernaryToElvisRector::class,
# skip: changes method signature
Php80\Class_\ClassPropertyAssignToConstructorPromotionRector::class,
# skip: changes method signature
TypeDeclaration\ClassMethod\ReturnNeverTypeRector::class,
# skip: strict_type cannot be applied to OpenMage codebase - yet
TypeDeclaration\StmtsAwareInterface\DeclareStrictTypesRector::class,
])
# skip: ... @todo: check later
->withSkip([
# ... causes issues with Mage_Api2_Model_Auth_Adapter_Oauth::getUserParams()
CodeQuality\Catch_\ThrowWithPreviousExceptionRector::class => [
__DIR__ . '/app/code/core/Mage/Api2/Model/Auth/Adapter/Oauth.php',
],
# ... +300 occurrences
CodeQuality\Equal\UseIdenticalOverEqualWithSameTypeRector::class,
# ... +300 occurrences
CodeQuality\If_\ExplicitBoolCompareRector::class,
# ... review autoloading at all
CodeQuality\Include_\AbsolutizeRequireAndIncludePathRector::class,
# ... breaks loading website
CodeQuality\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class,
# ... +250 occurrences
CodingStyle\Encapsed\EncapsedStringsToSprintfRector::class,
# --- wait for phpstan strict rules
CodingStyle\FuncCall\StrictArraySearchRector::class,
# ... +200 occurrences, need closer review
CodingStyle\PostInc\PostIncDecToPreIncDecRector::class,
# ... needs closer review
DeadCode\ClassMethod\RemoveUnusedConstructorParamRector::class,
# ... messes up code
DeadCode\If_\RemoveAlwaysTrueIfConditionRector::class => [
__DIR__ . '/app/design/adminhtml/base/default/template/system/store/tree.phtml',
],
# ... +400 occurrences, needs closer review
DeadCode\PropertyProperty\RemoveNullPropertyInitializationRector::class,
# ... needs closer review
DeadCode\TryCatch\RemoveDeadTryCatchRector::class,
# ... check again https://github.com/rectorphp/rector/issues/9732
EarlyReturn\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector::class => [
__DIR__ . '/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php',
],
# ... needs closer review and docblock fixes for magic methods
Php71\FuncCall\RemoveExtraParametersRector::class,
# ... needs closer review
Php74\Closure\ClosureToArrowFunctionRector::class,
# ... needs closer review
Php80\ClassMethod\AddParamBasedOnParentClassMethodRector::class => [
__DIR__ . '/lib/Varien/Directory/Collection.php',
],
# ... +300 occurrences
Php81\FuncCall\NullToStrictStringFuncCallArgRector::class,
# ... ~100 occurrences
Strict\Empty_\DisallowedEmptyRuleFixerRector::class,
# ... needs closer review
TypeDeclaration\BooleanAnd\BinaryOpNullableToInstanceofRector::class,
])
# WIP
->withSkip([
# https://github.com/OpenMage/magento-lts/pull/5434
Php81\Array_\ArrayToFirstClassCallableRector::class,
])
->withSkip([
# skip: use static methods
PreferPHPUnitThisCallRector::class,
__DIR__ . '/shell/translations.php',
__DIR__ . '/tests/unit/Mage/Reports/Model/Resource/Report/CollectionTest.php',
]);
} catch (InvalidConfigurationException $exception) {
echo $exception->getMessage();
exit(1);
}