-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathrector.php
139 lines (133 loc) · 4.78 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
<?php
/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection PhpInternalEntityUsedInspection */
declare(strict_types=1);
/**
* Copyright (c) 2019-2025 guanguans<[email protected]>
*
* 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 Guanguans\SoarPHP\Support\Rectors\ToInternalExceptionRector;
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector;
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
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\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector;
use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector;
use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\RemoveExpectAnyFromMockRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return RectorConfig::configure()
->withPaths([
__DIR__.'/benchmarks',
__DIR__.'/examples',
__DIR__.'/src',
__DIR__.'/tests',
__DIR__.'/.*.php',
__DIR__.'/*.php',
__DIR__.'/composer-updater',
])
->withParallel()
// ->withoutParallel()
->withImportNames(false)
->withAttributesSets()
->withDeadCodeLevel(42)
->withTypeCoverageLevel(37)
->withFluentCallNewLine()
// ->withPhpSets()
// ->withPreparedSets()
->withDowngradeSets(false, false, false, true)
->withSets([
LevelSetList::UP_TO_PHP_74,
])
->withSets([
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
// SetList::DEAD_CODE,
// SetList::STRICT_BOOLEANS,
// SetList::GMAGICK_TO_IMAGICK,
SetList::NAMING,
// SetList::PRIVATIZATION,
// SetList::TYPE_DECLARATION,
SetList::EARLY_RETURN,
SetList::INSTANCEOF,
])
->withSets([
PHPUnitSetList::PHPUNIT_90,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
])
->withRules([
InlineConstructorDefaultToPropertyRector::class,
StaticArrowFunctionRector::class,
StaticClosureRector::class,
ToInternalExceptionRector::class,
])
->withConfiguredRule(
RenameFunctionRector::class,
[
'test' => 'it',
] + array_reduce(
[
// 'make',
// 'env_explode',
],
static function (array $carry, string $func): array {
/** @see https://github.com/laravel/framework/blob/11.x/src/Illuminate/Support/functions.php */
$carry[$func] = "Guanguans\\SoarPHP\\Support\\$func";
return $carry;
},
[]
)
)
->withSkip([
'**/__aspect_mock__/*',
'**/__snapshots__/*',
'**/fixtures/*',
'**/Fixtures/*',
__DIR__.'/tests/Concerns/WithRunableTest.php',
])
->withSkip([
EncapsedStringsToSprintfRector::class,
ExplicitBoolCompareRector::class,
ExplicitReturnNullRector::class,
InlineIfToExplicitIfRector::class,
LogicalToBooleanRector::class,
NewlineAfterStatementRector::class,
RenameParamToMatchTypeRector::class,
RenameVariableToMatchMethodCallReturnTypeRector::class,
ReturnBinaryOrToEarlyReturnRector::class,
WrapEncapsedVariableInCurlyBracesRector::class,
])
->withSkip([
ReturnEarlyIfVariableRector::class => [
__DIR__.'/src/Support/EscapeArg.php',
],
RemoveExpectAnyFromMockRector::class => [
__DIR__.'/tests/Concerns/WithDumpableTest.php',
],
RenameFunctionRector::class => [
// __DIR__.'/src/Support/helpers.php',
],
ToInternalExceptionRector::class => [
__DIR__.'/tests',
],
StaticArrowFunctionRector::class => $staticClosureSkipPaths = [
__DIR__.'/tests',
],
StaticClosureRector::class => $staticClosureSkipPaths,
]);