-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrector.php
More file actions
133 lines (130 loc) · 5.69 KB
/
rector.php
File metadata and controls
133 lines (130 loc) · 5.69 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
<?php
/**
* Rector Configuration
*
* phpcs:disable
*/
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodingStyle\Rector\ArrowFunction\ArrowFunctionDelegatingCallToFirstClassCallableRector;
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
use Rector\CodingStyle\Rector\Closure\ClosureDelegatingCallToFirstClassCallableRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\FunctionLike\FunctionLikeToFirstClassCallableRector;
use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\NotIdentical\StrContainsRector;
use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnArrayDocblockBasedOnArrayMapRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNullableTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictFluentReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnUnionTypeRector;
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;
use Rector\ValueObject\PhpVersion;
/**
* Rector Configuration
*
* Overtime this file will have more rules enabled for it. Right now, most of
* them are commented out. They will be spread out over multiple pull requests.
*
* Rules that are known to cause issues and should not be used:
*
* - RemoveUselessParamTagRector: Conflicts with WordPress Coding Standards
* - ChangeOrIfContinueToMultiContinueRector: doesn't make sense.
*/
return RectorConfig::configure()
->withPhpVersion( PhpVersion::PHP_85 )
->withPhpSets()
->withIndent( "\t" )
->withPaths( [ __DIR__ . '/src' ] )
->withPreparedSets(
deadCode: true,
codingStyle: true,
codeQuality: true,
earlyReturn: true,
instanceOf: true,
typeDeclarations: true,
)
->withRules(
[
RenameForeachValueVariableToMatchExprVariableRector::class,
ExplicitNullableParamTypeRector::class,
AddParamTypeDeclarationRector::class,
AddReturnArrayDocblockBasedOnArrayMapRector::class,
]
)
->withSkip( [
AddVoidReturnTypeWhereNoReturnRector::class => [
__DIR__ . '/src/mantle/testing/concerns/trait-core-shim.php',
__DIR__ . '/tests/Testing/CoreTestShimTest.php',
__DIR__ . '/tests/testing/CoreTestShimTest.php',
],
ClassPropertyAssignToConstructorPromotionRector::class => [
__DIR__ . '/src/mantle/support/class-service-provider.php',
],
RemoveUselessReturnTagRector::class => [
__DIR__ . '/src/mantle/database/model/relations',
],
ReturnNullableTypeRector::class => [
__DIR__ . '/src/mantle/database/model/relations',
],
ReturnTypeFromStrictTypedCallRector::class => [
__DIR__ . '/src/mantle/database/model/relations',
],
ArrayToFirstClassCallableRector::class,
RemoveUselessParamTagRector::class,
StrContainsRector::class,
AddArrowFunctionReturnTypeRector::class,
ChangeOrIfContinueToMultiContinueRector::class,
EmptyOnNullableObjectToInstanceOfRector::class,
ReturnBinaryOrToEarlyReturnRector::class => [
__DIR__ . '/src/mantle/http-client/class-response.php',
],
RemoveExtraParametersRector::class => [
__DIR__ . '/src/mantle/support/helpers/helpers-general.php',
],
ReturnTypeFromReturnNewRector::class => [
__DIR__ . '/src/mantle/support/class-collection.php',
__DIR__ . '/src/mantle/support/traits/trait-enumerates-values.php',
],
ReturnUnionTypeRector::class => [
__DIR__ . '/src/mantle/framework/exceptions/class-handler.php',
],
ReturnTypeFromStrictFluentReturnRector::class => [
__DIR__ . '/src/mantle/database/query/class-collection.php',
__DIR__ . '/src/mantle/support/class-collection.php',
__DIR__ . '/src/mantle/support/traits/trait-enumerates-values.php',
],
ExplicitBoolCompareRector::class => [
__DIR__ . '/src/mantle/database/model/class-post.php',
__DIR__ . '/src/mantle/testing',
],
SimplifyEmptyCheckOnEmptyArrayRector::class,
DisallowedEmptyRuleFixerRector::class,
NullableCompareToNullRector::class,
CatchExceptionNameMatchingTypeRector::class,
EncapsedStringsToSprintfRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
ClosureDelegatingCallToFirstClassCallableRector::class,
ArrowFunctionDelegatingCallToFirstClassCallableRector::class,
RemoveNullArgOnNullDefaultParamRector::class,
IfIssetToCoalescingRector::class,
] );