-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathrector.dist.php
More file actions
161 lines (155 loc) · 6.35 KB
/
rector.dist.php
File metadata and controls
161 lines (155 loc) · 6.35 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
<?php
/** @noinspection PhpInternalEntityUsedInspection */
/** @noinspection PhpMultipleClassDeclarationsInspection */
/** @noinspection PhpUnhandledExceptionInspection */
declare(strict_types=1);
/**
* Copyright (c) 2019-2026 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/soar-php
*/
use Ergebnis\Rector\Rules\Arrays\SortAssociativeArrayByKeyRector;
use Ergebnis\Rector\Rules\Faker\GeneratorPropertyFetchToMethodCallRector;
use Ergebnis\Rector\Rules\Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector;
use Guanguans\RectorRules\Rector\File\AddNoinspectionDocblockToFileFirstStmtRector;
use Guanguans\RectorRules\Rector\Name\RenameToConventionalCaseNameRector;
use Guanguans\RectorRules\Set\SetList;
use Guanguans\SoarPHP\Support\Rectors\AddDocCommentForHasOptionsRector;
use PhpParser\NodeVisitor\ParentConnectingVisitor;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector;
use Rector\CodingStyle\Rector\ArrowFunction\ArrowFunctionDelegatingCallToFirstClassCallableRector;
use Rector\CodingStyle\Rector\ArrowFunction\StaticArrowFunctionRector;
use Rector\CodingStyle\Rector\ClassLike\NewlineBetweenClassLikeStmtsRector;
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
use Rector\CodingStyle\Rector\Enum_\EnumCaseToPascalCaseRector;
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Php82\Rector\Param\AddSensitiveParameterAttributeRector;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\Transform\Rector\Scalar\ScalarValueToConstFetchRector;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\SafeDeclareStrictTypesRector;
use Rector\ValueObject\PhpVersion;
use RectorPest\Set\PestLevelSetList;
use RectorPest\Set\PestSetList;
return RectorConfig::configure()
->withPaths([
__DIR__.'/benchmarks/',
__DIR__.'/examples/',
__DIR__.'/src/',
__DIR__.'/tests/',
__DIR__.'/composer-bump',
])
->withRootFiles()
->withSkip(['*/Fixtures/*', __DIR__.'/tests.php'])
->withCache(__DIR__.'/.build/rector/')
// ->withoutParallel()
->withParallel()
->withImportNames(importDocBlockNames: false, importShortClasses: false)
// ->withImportNames(importNames: false)
// ->withEditorUrl()
->withFluentCallNewLine()
->withTreatClassesAsFinal()
->withAttributesSets(phpunit: true, all: true)
->withComposerBased(phpunit: true/* , laravel: true */)
->withPhpVersion(PhpVersion::PHP_82)
->withDowngradeSets(php82: true)
->withPhpSets(php82: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
typeDeclarationDocblocks: true,
privatization: true,
naming: true,
instanceOf: true,
earlyReturn: true,
// strictBooleans: true,
// carbon: true,
rectorPreset: true,
phpunitCodeQuality: true,
)
->withSets([
SetList::ALL,
PestLevelSetList::UP_TO_PEST_30,
PestSetList::PEST_CODE_QUALITY,
])
->withRules([
AddDocCommentForHasOptionsRector::class,
ArraySpreadInsteadOfArrayMergeRector::class,
EnumCaseToPascalCaseRector::class,
GeneratorPropertyFetchToMethodCallRector::class,
JsonThrowOnErrorRector::class,
SafeDeclareStrictTypesRector::class,
SortAssociativeArrayByKeyRector::class,
StaticArrowFunctionRector::class,
StaticClosureRector::class,
])
->withConfiguredRule(AddNoinspectionDocblockToFileFirstStmtRector::class, [
'*/tests/*' => [
'AnonymousFunctionStaticInspection',
'NullPointerExceptionInspection',
'PhpPossiblePolymorphicInvocationInspection',
'PhpUndefinedClassInspection',
'PhpUnhandledExceptionInspection',
'PhpVoidFunctionResultUsedInspection',
'SqlResolve',
'StaticClosureCanBeUsedInspection',
],
])
->registerDecoratingNodeVisitor(ParentConnectingVisitor::class)
->withConfiguredRule(RenameToConventionalCaseNameRector::class, ['MIT'])
->withConfiguredRule(ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector::class, [
'namespacePrefixes' => [
// 'Guanguans\\SoarPHP',
],
])
->withSkip([
AddSensitiveParameterAttributeRector::class,
ScalarValueToConstFetchRector::class,
ChangeOrIfContinueToMultiContinueRector::class,
DisallowedEmptyRuleFixerRector::class,
EncapsedStringsToSprintfRector::class,
ExplicitBoolCompareRector::class,
LogicalToBooleanRector::class,
NewlineBetweenClassLikeStmtsRector::class,
ReturnBinaryOrToEarlyReturnRector::class,
WrapEncapsedVariableInCurlyBracesRector::class,
])
->withSkip([
ArrowFunctionDelegatingCallToFirstClassCallableRector::class => [
__DIR__.'/tests/Concerns/HasOptionsTest.php',
],
JsonThrowOnErrorRector::class => [
__DIR__.'/tests/Pest.php',
],
RemoveAnnotationRector::class => [
__DIR__.'/src/Concerns/HasBinary.php',
__DIR__.'/src/Concerns/WithDumpable.php',
],
RenameParamToMatchTypeRector::class => [
__DIR__.'/tests/Pest.php',
],
SortAssociativeArrayByKeyRector::class => [
__DIR__.'/benchmarks/',
__DIR__.'/examples/',
__DIR__.'/src/',
__DIR__.'/tests/',
],
StaticArrowFunctionRector::class => $staticClosureSkipPaths = [
__DIR__.'/tests/*Test.php',
__DIR__.'/tests/Pest.php',
],
StaticClosureRector::class => $staticClosureSkipPaths,
]);