|
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\PHPUnit\Set\PHPUnitLevelSetList; |
| 29 | +use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector; |
33 | 30 | use Rector\PHPUnit\Set\PHPUnitSetList;
|
34 |
| -use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector; |
| 31 | +use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; |
35 | 32 | use Rector\Set\ValueObject\LevelSetList;
|
36 | 33 | use Rector\Set\ValueObject\SetList;
|
| 34 | +use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; |
37 | 35 |
|
38 | 36 | return static function (RectorConfig $rectorConfig): void {
|
39 |
| - $rectorConfig->sets([SetList::DEAD_CODE, LevelSetList::UP_TO_PHP_80, PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, PHPUnitLevelSetList::UP_TO_PHPUNIT_100]); |
| 37 | + $rectorConfig->sets([ |
| 38 | + SetList::DEAD_CODE, |
| 39 | + LevelSetList::UP_TO_PHP_80, |
| 40 | + PHPUnitSetList::PHPUNIT_CODE_QUALITY, |
| 41 | + PHPUnitSetList::PHPUNIT_100, |
| 42 | + ]); |
| 43 | + |
40 | 44 | $rectorConfig->parallel();
|
| 45 | + |
41 | 46 | // The paths to refactor (can also be supplied with CLI arguments)
|
42 | 47 | $rectorConfig->paths([
|
43 | 48 | __DIR__ . '/src/',
|
|
59 | 64 | }
|
60 | 65 |
|
61 | 66 | // Set the target version for refactoring
|
62 |
| - $rectorConfig->phpVersion(PhpVersion::PHP_80); |
| 67 | + $rectorConfig->phpVersion(PhpVersion::PHP_81); |
63 | 68 |
|
64 | 69 | // Auto-import fully qualified class names
|
65 | 70 | $rectorConfig->importNames();
|
|
74 | 79 | // Note: requires php 8
|
75 | 80 | RemoveUnusedPromotedPropertyRector::class,
|
76 | 81 |
|
77 |
| - // Ignore tests that might make calls without a result |
78 |
| - RemoveEmptyMethodCallRector::class => [ |
79 |
| - __DIR__ . '/tests', |
80 |
| - ], |
81 |
| - |
82 |
| - // Ignore files that should not be namespaced |
83 |
| - NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [ |
84 |
| - __DIR__ . '/src/Common.php', |
85 |
| - __DIR__ . '/tests/_support/Views/', |
86 |
| - ], |
87 |
| - |
88 | 82 | // May load view files directly when detecting classes
|
89 | 83 | StringClassNameToClassConstantRector::class,
|
90 | 84 |
|
91 |
| - // May be uninitialized on purpose |
92 |
| - AddDefaultValueForUndefinedVariableRector::class, |
| 85 | + // Supported from PHPUnit 10 |
| 86 | + DataProviderAnnotationToAttributeRector::class, |
93 | 87 | ]);
|
| 88 | + |
| 89 | + // auto import fully qualified class names |
| 90 | + $rectorConfig->importNames(); |
| 91 | + |
94 | 92 | $rectorConfig->rule(SimplifyUselessVariableRector::class);
|
95 | 93 | $rectorConfig->rule(RemoveAlwaysElseRector::class);
|
96 | 94 | $rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class);
|
97 |
| - $rectorConfig->rule(ForToForeachRector::class); |
98 | 95 | $rectorConfig->rule(ChangeNestedForeachIfsToEarlyContinueRector::class);
|
99 | 96 | $rectorConfig->rule(ChangeIfElseValueAssignToEarlyReturnRector::class);
|
100 | 97 | $rectorConfig->rule(SimplifyStrposLowerRector::class);
|
|
107 | 104 | $rectorConfig->rule(UnusedForeachValueToArrayKeysRector::class);
|
108 | 105 | $rectorConfig->rule(ChangeArrayPushToArrayAssignRector::class);
|
109 | 106 | $rectorConfig->rule(UnnecessaryTernaryExpressionRector::class);
|
110 |
| - $rectorConfig->rule(AddPregQuoteDelimiterRector::class); |
111 | 107 | $rectorConfig->rule(SimplifyRegexPatternRector::class);
|
112 | 108 | $rectorConfig->rule(FuncGetArgsToVariadicParamRector::class);
|
113 | 109 | $rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class);
|
114 | 110 | $rectorConfig->rule(SimplifyEmptyArrayCheckRector::class);
|
115 |
| - $rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class); |
| 111 | + $rectorConfig |
| 112 | + ->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [ |
| 113 | + /** |
| 114 | + * 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 |
| 115 | + * Set to true for projects that allow BC break |
| 116 | + */ |
| 117 | + TypedPropertyFromAssignsRector::INLINE_PUBLIC => false, |
| 118 | + ]); |
| 119 | + $rectorConfig->rule(StringClassNameToClassConstantRector::class); |
| 120 | + $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); |
| 121 | + $rectorConfig->rule(CompleteDynamicPropertiesRector::class); |
116 | 122 | };
|
0 commit comments