-
Notifications
You must be signed in to change notification settings - Fork 65
/
rector.php
223 lines (217 loc) · 10.8 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
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
declare(strict_types=1);
/**
* Copyright (c) 2019-2024 guanguans<ityaozm@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://github.com/guanguans/music-dl
*/
// use App\Support\Rectors\RenameToPsrNameRector;
use App\Music;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector;
use Rector\CodingStyle\Rector\ArrowFunction\StaticArrowFunctionRector;
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\Config\RectorConfig;
use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector;
use Rector\Renaming\Rector\String_\RenameStringRector;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector;
use Rector\Transform\ValueObject\MethodCallToStaticCall;
use RectorLaravel\Rector\MethodCall\UseComponentPropertyWithinCommandsRector;
use RectorLaravel\Set\LaravelSetList;
// (function ($rectorConfig): void {
// $rectorConfig->ruleConfigurations[AnnotationToAttributeRector::class] = array_filter(
// $rectorConfig->ruleConfigurations[AnnotationToAttributeRector::class],
// static fn (AnnotationToAttribute $annotationToAttribute): bool => !\in_array(
// $annotationToAttribute->getAttributeClass(),
// [
// CodeCoverageIgnore::class,
// ],
// true
// )
// );
// })->call($rectorConfig, $rectorConfig);
return RectorConfig::configure()
->withPaths([
__DIR__.'/*.php',
__DIR__.'/.*.php',
__DIR__.'/app',
__DIR__.'/composer-updater',
__DIR__.'/config',
__DIR__.'/tests',
])
->withPHPStanConfigs([
__DIR__.'/phpstan.neon',
])
->withParallel()
// ->withoutParallel()
->withImportNames(importNames: false, importDocBlockNames: false)
// ->withDeadCodeLevel(42)
// ->withTypeCoverageLevel(23)
// ->withFluentCallNewLine()
->withPhpSets(php82: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
privatization: true,
naming: true,
instanceOf: true,
earlyReturn: true,
)
->withAttributesSets(
phpunit: true
)
->withSets([
DowngradeLevelSetList::DOWN_TO_PHP_82,
PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
LaravelSetList::LARAVEL_110,
// LaravelSetList::LARAVEL_STATIC_TO_INJECTION,
LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelSetList::LARAVEL_ARRAY_STR_FUNCTION_TO_STATIC_CALL,
LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES,
LaravelSetList::LARAVEL_FACADE_ALIASES_TO_FULL_NAMES,
LaravelSetList::LARAVEL_ELOQUENT_MAGIC_METHOD_TO_QUERY_BUILDER,
])
->withRules([
StaticArrowFunctionRector::class,
StaticClosureRector::class,
])
->withRules([
// // RectorLaravel\Rector\Assign\CallOnAppArrayAccessToStandaloneAssignRector::class,
// // RectorLaravel\Rector\Cast\DatabaseExpressionCastsToMethodCallRector::class,
RectorLaravel\Rector\ClassMethod\AddParentBootToModelClassMethodRector::class,
RectorLaravel\Rector\ClassMethod\AddParentRegisterToEventServiceProviderRector::class,
RectorLaravel\Rector\ClassMethod\MigrateToSimplifiedAttributeRector::class,
RectorLaravel\Rector\Class_\AddExtendsAnnotationToModelFactoriesRector::class,
RectorLaravel\Rector\Class_\AddMockConsoleOutputFalseToConsoleTestsRector::class,
RectorLaravel\Rector\Class_\AnonymousMigrationsRector::class,
RectorLaravel\Rector\Class_\ModelCastsPropertyToCastsMethodRector::class,
RectorLaravel\Rector\Class_\PropertyDeferToDeferrableProviderToRector::class,
RectorLaravel\Rector\Class_\RemoveModelPropertyFromFactoriesRector::class,
// // RectorLaravel\Rector\Class_\ReplaceExpectsMethodsInTestsRector::class,
// // RectorLaravel\Rector\Class_\UnifyModelDatesWithCastsRector::class,
// RectorLaravel\Rector\Empty_\EmptyToBlankAndFilledFuncRector::class,
RectorLaravel\Rector\Expr\AppEnvironmentComparisonToParameterRector::class,
RectorLaravel\Rector\Expr\SubStrToStartsWithOrEndsWithStaticMethodCallRector\SubStrToStartsWithOrEndsWithStaticMethodCallRector::class,
// // RectorLaravel\Rector\FuncCall\DispatchNonShouldQueueToDispatchSyncRector::class,
// // RectorLaravel\Rector\FuncCall\FactoryFuncCallToStaticCallRector::class,
// RectorLaravel\Rector\FuncCall\HelperFuncCallToFacadeClassRector::class,
RectorLaravel\Rector\FuncCall\NotFilledBlankFuncCallToBlankFilledFuncCallRector::class,
RectorLaravel\Rector\FuncCall\NowFuncWithStartOfDayMethodCallToTodayFuncRector::class,
RectorLaravel\Rector\FuncCall\RemoveDumpDataDeadCodeRector::class,
RectorLaravel\Rector\FuncCall\RemoveRedundantValueCallsRector::class,
RectorLaravel\Rector\FuncCall\RemoveRedundantWithCallsRector::class,
RectorLaravel\Rector\FuncCall\SleepFuncToSleepStaticCallRector::class,
// RectorLaravel\Rector\FuncCall\ThrowIfAndThrowUnlessExceptionsToUseClassStringRector::class,
RectorLaravel\Rector\If_\AbortIfRector::class,
RectorLaravel\Rector\If_\ReportIfRector::class,
// RectorLaravel\Rector\If_\ThrowIfRector::class,
RectorLaravel\Rector\MethodCall\AssertStatusToAssertMethodRector::class,
RectorLaravel\Rector\MethodCall\ChangeQueryWhereDateValueWithCarbonRector::class,
// // RectorLaravel\Rector\MethodCall\DatabaseExpressionToStringToMethodCallRector::class,
RectorLaravel\Rector\MethodCall\EloquentWhereRelationTypeHintingParameterRector::class,
RectorLaravel\Rector\MethodCall\EloquentWhereTypeHintClosureParameterRector::class,
// // RectorLaravel\Rector\MethodCall\FactoryApplyingStatesRector::class,
RectorLaravel\Rector\MethodCall\JsonCallToExplicitJsonCallRector::class,
// RectorLaravel\Rector\MethodCall\LumenRoutesStringActionToUsesArrayRector::class,
// RectorLaravel\Rector\MethodCall\LumenRoutesStringMiddlewareToArrayRector::class,
RectorLaravel\Rector\MethodCall\RedirectBackToBackHelperRector::class,
RectorLaravel\Rector\MethodCall\RedirectRouteToToRouteHelperRector::class,
RectorLaravel\Rector\MethodCall\RefactorBlueprintGeometryColumnsRector::class,
// // RectorLaravel\Rector\MethodCall\ReplaceWithoutJobsEventsAndNotificationsWithFacadeFakeRector::class,
RectorLaravel\Rector\MethodCall\UseComponentPropertyWithinCommandsRector::class,
RectorLaravel\Rector\MethodCall\ValidationRuleArrayStringValueToArrayRector::class,
// // RectorLaravel\Rector\Namespace_\FactoryDefinitionRector::class,
RectorLaravel\Rector\New_\AddGuardToLoginEventRector::class,
RectorLaravel\Rector\PropertyFetch\ReplaceFakerInstanceWithHelperRector::class,
RectorLaravel\Rector\StaticCall\DispatchToHelperFunctionsRector::class,
// RectorLaravel\Rector\StaticCall\MinutesToSecondsInCacheRector::class,
RectorLaravel\Rector\StaticCall\Redirect301ToPermanentRedirectRector::class,
// // RectorLaravel\Rector\StaticCall\ReplaceAssertTimesSendWithAssertSentTimesRector::class,
])
->withRules([
// // RectorLaravel\Rector\ClassMethod\AddArgumentDefaultValueRector::class,
// // RectorLaravel\Rector\FuncCall\ArgumentFuncCallToMethodCallRector::class,
// RectorLaravel\Rector\MethodCall\EloquentOrderByToLatestOrOldestRector::class,
// RectorLaravel\Rector\MethodCall\ReplaceServiceContainerCallArgRector::class,
// RectorLaravel\Rector\PropertyFetch\OptionalToNullsafeOperatorRector::class,
// // RectorLaravel\Rector\StaticCall\EloquentMagicMethodToQueryBuilderRector::class,
// RectorLaravel\Rector\StaticCall\RouteActionCallableRector::class,
])
->withConfiguredRule(RectorLaravel\Rector\MethodCall\EloquentOrderByToLatestOrOldestRector::class, [
])
->withConfiguredRule(RectorLaravel\Rector\MethodCall\ReplaceServiceContainerCallArgRector::class, [
])
->withConfiguredRule(RectorLaravel\Rector\PropertyFetch\OptionalToNullsafeOperatorRector::class, [
])
->withConfiguredRule(RectorLaravel\Rector\StaticCall\RouteActionCallableRector::class, [
])
->withConfiguredRule(RenameFunctionRector::class, [
'test' => 'it',
])
// ->withConfiguredRule(RenameToPsrNameRector::class, [
// '_*',
// ])
->withConfiguredRule(RenameClassRector::class, [
])
->withConfiguredRule(RenameStaticMethodRector::class, [
])
->withConfiguredRule(RenameStringRector::class, [
])
->withConfiguredRule(MethodCallToStaticCallRector::class, [
// new MethodCallToStaticCall(Music::class, 'createHttpClient', Music::class, 'createHttpClient'),
])
->withSkip([
'**/__snapshots__/*',
'**/Fixtures/*',
__DIR__.'/.phpstorm.meta.php',
__DIR__.'/_ide_helper.php',
__DIR__.'/_ide_helper_models.php',
__DIR__.'/dcat_admin_ide_helper.php',
__DIR__.'/deploy.example.php',
__DIR__.'/deploy.php',
__DIR__.'/rector-dist.php',
__FILE__,
])
->withSkip([
EncapsedStringsToSprintfRector::class,
ExplicitBoolCompareRector::class,
LogicalToBooleanRector::class,
NewlineAfterStatementRector::class,
WrapEncapsedVariableInCurlyBracesRector::class,
])
->withSkip([
CompactToVariablesRector::class => [
__DIR__.'/app/Commands/MusicCommand.php',
],
RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class => [
__DIR__.'/tests/Pest.php',
],
RenamePropertyToMatchTypeRector::class => [
__DIR__.'/app/Commands/MusicCommand.php',
],
UseComponentPropertyWithinCommandsRector::class => [
__DIR__.'/app/Commands/InspireCommand.php',
],
StaticArrowFunctionRector::class => $staticClosureSkipPaths = [
__FILE__,
__DIR__.'/tests',
],
StaticClosureRector::class => $staticClosureSkipPaths,
]);