|
1 | 1 | <?php
|
2 | 2 |
|
3 | 3 | use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
|
| 4 | +use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector; |
4 | 5 | use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
|
5 |
| -use Rector\CodeQuality\Rector\For_\ForToForeachRector; |
6 | 6 | use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
|
7 |
| -use Rector\CodeQuality\Rector\FuncCall\AddPregQuoteDelimiterRector; |
8 | 7 | use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
|
9 | 8 | use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector;
|
10 | 9 | use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector;
|
|
20 | 19 | use Rector\Config\RectorConfig;
|
21 | 20 | use Rector\Core\ValueObject\PhpVersion;
|
22 | 21 | use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
|
23 |
| -use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector; |
24 | 22 | use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
|
25 | 23 | use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
|
26 | 24 | use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
|
27 | 25 | use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
|
28 | 26 | use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
29 |
| -use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector; |
30 | 27 | use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
|
31 | 28 | use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
|
32 |
| -use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; |
33 |
| -use Rector\PHPUnit\Set\PHPUnitLevelSetList; |
34 | 29 | use Rector\PHPUnit\Set\PHPUnitSetList;
|
35 |
| -use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector; |
| 30 | +use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; |
36 | 31 | use Rector\Set\ValueObject\LevelSetList;
|
37 | 32 | use Rector\Set\ValueObject\SetList;
|
| 33 | +use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; |
38 | 34 |
|
39 | 35 | return static function (RectorConfig $rectorConfig): void {
|
40 |
| - $rectorConfig->sets([SetList::DEAD_CODE, LevelSetList::UP_TO_PHP_80, PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, PHPUnitLevelSetList::UP_TO_PHPUNIT_100]); |
| 36 | + $rectorConfig->sets([ |
| 37 | + SetList::DEAD_CODE, |
| 38 | + LevelSetList::UP_TO_PHP_80, |
| 39 | + PHPUnitSetList::PHPUNIT_CODE_QUALITY, |
| 40 | + PHPUnitSetList::PHPUNIT_100, |
| 41 | + ]); |
| 42 | + |
41 | 43 | $rectorConfig->parallel();
|
| 44 | + |
42 | 45 | // The paths to refactor (can also be supplied with CLI arguments)
|
43 | 46 | $rectorConfig->paths([
|
44 |
| - __DIR__ . '/src/', |
| 47 | + __DIR__ . '/app/', |
45 | 48 | __DIR__ . '/tests/',
|
46 | 49 | ]);
|
47 | 50 |
|
|
76 | 79 | // Note: requires php 8
|
77 | 80 | RemoveUnusedPromotedPropertyRector::class,
|
78 | 81 |
|
79 |
| - // Ignore tests that might make calls without a result |
80 |
| - RemoveEmptyMethodCallRector::class => [ |
81 |
| - __DIR__ . '/tests', |
82 |
| - ], |
83 |
| - |
84 |
| - // Ignore files that should not be namespaced |
85 |
| - NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [ |
86 |
| - __DIR__ . '/src/Common.php', |
87 |
| - __DIR__ . '/tests/_support/Views/', |
88 |
| - ], |
89 |
| - |
90 | 82 | // May load view files directly when detecting classes
|
91 | 83 | StringClassNameToClassConstantRector::class,
|
| 84 | + ]); |
92 | 85 |
|
93 |
| - // May be uninitialized on purpose |
94 |
| - AddDefaultValueForUndefinedVariableRector::class, |
| 86 | + // auto import fully qualified class names |
| 87 | + $rectorConfig->importNames(); |
95 | 88 |
|
96 |
| - // PHPUnit attributes |
97 |
| - AnnotationToAttributeRector::class, |
98 |
| - ]); |
99 | 89 | $rectorConfig->rule(SimplifyUselessVariableRector::class);
|
100 | 90 | $rectorConfig->rule(RemoveAlwaysElseRector::class);
|
101 | 91 | $rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class);
|
102 |
| - $rectorConfig->rule(ForToForeachRector::class); |
103 | 92 | $rectorConfig->rule(ChangeNestedForeachIfsToEarlyContinueRector::class);
|
104 | 93 | $rectorConfig->rule(ChangeIfElseValueAssignToEarlyReturnRector::class);
|
105 | 94 | $rectorConfig->rule(SimplifyStrposLowerRector::class);
|
|
112 | 101 | $rectorConfig->rule(UnusedForeachValueToArrayKeysRector::class);
|
113 | 102 | $rectorConfig->rule(ChangeArrayPushToArrayAssignRector::class);
|
114 | 103 | $rectorConfig->rule(UnnecessaryTernaryExpressionRector::class);
|
115 |
| - $rectorConfig->rule(AddPregQuoteDelimiterRector::class); |
116 | 104 | $rectorConfig->rule(SimplifyRegexPatternRector::class);
|
117 | 105 | $rectorConfig->rule(FuncGetArgsToVariadicParamRector::class);
|
118 | 106 | $rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class);
|
119 | 107 | $rectorConfig->rule(SimplifyEmptyArrayCheckRector::class);
|
120 |
| - $rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class); |
| 108 | + $rectorConfig |
| 109 | + ->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [ |
| 110 | + /** |
| 111 | + * The INLINE_PUBLIC value is default to false to avoid BC break, if you use for libraries and want to preserve BC break, you don't need to configure it, as it included in LevelSetList::UP_TO_PHP_74 |
| 112 | + * Set to true for projects that allow BC break |
| 113 | + */ |
| 114 | + TypedPropertyFromAssignsRector::INLINE_PUBLIC => true, |
| 115 | + ]); |
| 116 | + $rectorConfig->rule(StringClassNameToClassConstantRector::class); |
| 117 | + $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); |
| 118 | + $rectorConfig->rule(CompleteDynamicPropertiesRector::class); |
121 | 119 | };
|
0 commit comments