forked from mautic/mautic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrector.php
131 lines (114 loc) · 5.96 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
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\Class_\ReturnTypeFromStrictTernaryRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromStrictScalarReturnsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictBoolReturnExprRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictConstantReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictParamRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__.'/app/bundles',
__DIR__.'/plugins',
]);
$rectorConfig->skip([
'*/Test/*',
'*/Tests/*',
'*.html.php',
ReturnTypeFromReturnDirectArrayRector::class => [
// require bit test update
__DIR__.'/app/bundles/LeadBundle/Model/LeadModel.php',
// array vs doctrine collection
__DIR__.'/app/bundles/CoreBundle/Entity/TranslationEntityTrait.php',
],
// lets handle later, once we have more type declaratoins
RecastingRemovalRector::class,
RemoveUnusedPrivatePropertyRector::class => [
// entities
__DIR__.'/app/bundles/UserBundle/Entity',
// typo fallback
__DIR__.'/app/bundles/LeadBundle/Entity/LeadField.php',
],
ReturnTypeFromStrictBoolReturnExprRector::class => [
__DIR__.'/app/bundles/LeadBundle/Segment/Decorator/BaseDecorator.php',
// requires quite a refactoring
__DIR__.'/app/bundles/CoreBundle/Factory/MauticFactory.php',
],
RemoveUnusedVariableAssignRector::class => [
// unset variable to clear garbage collector
__DIR__.'/app/bundles/LeadBundle/Model/ImportModel.php',
],
TypedPropertyFromStrictConstructorRector::class => [
// entities magic
__DIR__.'/app/bundles/LeadBundle/Entity',
// fixed in rector dev-main
__DIR__.'/app/bundles/CoreBundle/DependencyInjection/Builder/BundleMetadata.php',
],
ClassPropertyAssignToConstructorPromotionRector::class => [
__DIR__.'/app/bundles/CacheBundle/EventListener/CacheClearSubscriber.php',
__DIR__.'/app/bundles/ReportBundle/Event/ReportBuilderEvent.php',
// false positive
__DIR__.'/app/bundles/CoreBundle/DependencyInjection/Builder/BundleMetadata.php',
],
\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector::class => [
'*/Entity/*',
],
// handle later with full PHP 8.0 upgrade
\Rector\Php80\Rector\FunctionLike\MixedTypeRector::class,
\Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class,
\Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class,
// handle later, case by case as lot of chnaged code
\Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector::class => [
__DIR__.'/app/bundles/PointBundle/Controller/TriggerController.php',
__DIR__.'/app/bundles/LeadBundle/Controller/ImportController.php',
__DIR__.'/app/bundles/FormBundle/Controller/FormController.php',
// watch out on this one - the variables are set magically via $$name
// @see app/bundles/FormBundle/Form/Type/FieldType.php:99
__DIR__.'/app/bundles/FormBundle/Form/Type/FieldType.php',
],
]);
// Define what rule sets will be applied
$rectorConfig->sets([
SetList::DEAD_CODE,
SetList::PHP_80,
// SetList::TYPE_DECLARATION,
]);
// Define what single rules will be applied
$rectorConfig->rules([
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector::class,
\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector::class,
NumericReturnTypeFromStrictScalarReturnsRector::class,
ReturnTypeFromReturnNewRector::class,
ReturnTypeFromStrictNativeCallRector::class,
ReturnTypeFromStrictNewArrayRector::class,
ReturnTypeFromStrictParamRector::class,
ReturnTypeFromStrictTernaryRector::class,
ClassPropertyAssignToConstructorPromotionRector::class,
BoolReturnTypeFromStrictScalarReturnsRector::class,
AddVoidReturnTypeWhereNoReturnRector::class,
TypedPropertyFromStrictConstructorRector::class,
TypedPropertyFromStrictSetUpRector::class,
RemoveUnusedVariableAssignRector::class,
RemoveUselessVarTagRector::class,
SimplifyUselessVariableRector::class,
ReturnTypeFromStrictBoolReturnExprRector::class,
ReturnTypeFromStrictConstantReturnRector::class,
ReturnTypeFromReturnDirectArrayRector::class,
]);
};