|
11 | 11 | * the LICENSE file that was distributed with this source code. |
12 | 12 | */ |
13 | 13 |
|
| 14 | +use Rector\Caching\ValueObject\Storage\FileCacheStorage; |
14 | 15 | use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; |
| 16 | +use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector; |
| 17 | +use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector; |
15 | 18 | use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector; |
16 | 19 | use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector; |
17 | 20 | use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector; |
18 | 21 | use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector; |
19 | 22 | use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector; |
| 23 | +use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector; |
20 | 24 | use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; |
21 | 25 | use Rector\CodeQuality\Rector\If_\CombineIfRector; |
| 26 | +use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector; |
22 | 27 | use Rector\CodeQuality\Rector\If_\ShortenElseIfRector; |
23 | 28 | use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector; |
24 | 29 | use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector; |
| 30 | +use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector; |
25 | 31 | use Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector; |
26 | 32 | use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector; |
27 | 33 | use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector; |
28 | 34 | use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; |
| 35 | +use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector; |
29 | 36 | use Rector\Config\RectorConfig; |
30 | 37 | use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector; |
31 | 38 | use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; |
|
34 | 41 | use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; |
35 | 42 | use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; |
36 | 43 | use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector; |
| 44 | +use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector; |
| 45 | +use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; |
37 | 46 | use Rector\PHPUnit\Set\PHPUnitSetList; |
| 47 | +use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; |
38 | 48 | use Rector\Set\ValueObject\LevelSetList; |
39 | 49 | use Rector\Set\ValueObject\SetList; |
| 50 | +use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; |
| 51 | +use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector; |
| 52 | +use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector; |
| 53 | +use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; |
40 | 54 | use Rector\ValueObject\PhpVersion; |
41 | 55 |
|
42 | 56 | return static function (RectorConfig $rectorConfig): void { |
43 | | - $rectorConfig->sets([SetList::DEAD_CODE, LevelSetList::UP_TO_PHP_74, PHPUnitSetList::PHPUNIT_80]); |
| 57 | + $rectorConfig->sets([ |
| 58 | + SetList::DEAD_CODE, |
| 59 | + LevelSetList::UP_TO_PHP_81, |
| 60 | + PHPUnitSetList::PHPUNIT_CODE_QUALITY, |
| 61 | + PHPUnitSetList::PHPUNIT_100, |
| 62 | + ]); |
| 63 | + |
44 | 64 | $rectorConfig->parallel(); |
| 65 | + |
| 66 | + // Github action cache |
| 67 | + $rectorConfig->cacheClass(FileCacheStorage::class); |
| 68 | + if (is_dir('/tmp')) { |
| 69 | + $rectorConfig->cacheDirectory('/tmp/rector'); |
| 70 | + } |
| 71 | + |
45 | 72 | // The paths to refactor (can also be supplied with CLI arguments) |
46 | 73 | $rectorConfig->paths([ |
47 | 74 | __DIR__ . '/src/', |
|
63 | 90 | } |
64 | 91 |
|
65 | 92 | // Set the target version for refactoring |
66 | | - $rectorConfig->phpVersion(PhpVersion::PHP_74); |
| 93 | + $rectorConfig->phpVersion(PhpVersion::PHP_81); |
67 | 94 |
|
68 | 95 | // Auto-import fully qualified class names |
69 | 96 | $rectorConfig->importNames(); |
70 | 97 |
|
71 | 98 | // Are there files or rules you need to skip? |
72 | 99 | $rectorConfig->skip([ |
73 | | - __DIR__ . '/src/Views', |
| 100 | + __DIR__ . '/app/Views', |
74 | 101 |
|
75 | 102 | StringifyStrNeedlesRector::class, |
| 103 | + YieldDataProviderRector::class, |
76 | 104 |
|
77 | 105 | // Note: requires php 8 |
78 | 106 | RemoveUnusedPromotedPropertyRector::class, |
| 107 | + AnnotationWithValueToAttributeRector::class, |
79 | 108 |
|
80 | 109 | // May load view files directly when detecting classes |
81 | 110 | StringClassNameToClassConstantRector::class, |
| 111 | + |
| 112 | + // Because of the BaseCommand |
| 113 | + TypedPropertyFromAssignsRector::class => [ |
| 114 | + __DIR__ . '/src/Commands/Disable.php', |
| 115 | + __DIR__ . '/src/Commands/Enable.php', |
| 116 | + __DIR__ . '/src/Commands/Lister.php', |
| 117 | + __DIR__ . '/src/Commands/Publish.php', |
| 118 | + __DIR__ . '/src/Commands/Run.php', |
| 119 | + __DIR__ . '/src/Commands/TaskCommand.php', |
| 120 | + __DIR__ . '/tests/_support/Commands/TasksExample.php', |
| 121 | + __DIR__ . '/tests/unit/TaskRunnerTest.php', |
| 122 | + ], |
82 | 123 | ]); |
| 124 | + |
| 125 | + // auto import fully qualified class names |
| 126 | + $rectorConfig->importNames(); |
| 127 | + |
83 | 128 | $rectorConfig->rule(SimplifyUselessVariableRector::class); |
84 | 129 | $rectorConfig->rule(RemoveAlwaysElseRector::class); |
85 | 130 | $rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class); |
|
99 | 144 | $rectorConfig->rule(FuncGetArgsToVariadicParamRector::class); |
100 | 145 | $rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class); |
101 | 146 | $rectorConfig->rule(SimplifyEmptyArrayCheckRector::class); |
| 147 | + $rectorConfig->rule(SimplifyEmptyCheckOnEmptyArrayRector::class); |
| 148 | + $rectorConfig->rule(TernaryEmptyArrayArrayDimFetchToCoalesceRector::class); |
| 149 | + $rectorConfig->rule(EmptyOnNullableObjectToInstanceOfRector::class); |
| 150 | + $rectorConfig->rule(DisallowedEmptyRuleFixerRector::class); |
| 151 | + $rectorConfig |
| 152 | + ->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [ |
| 153 | + /** |
| 154 | + * The INLINE_PUBLIC value is default to false to avoid BC break, |
| 155 | + * if you use for libraries and want to preserve BC break, you don't |
| 156 | + * need to configure it, as it included in LevelSetList::UP_TO_PHP_74 |
| 157 | + * Set to true for projects that allow BC break |
| 158 | + */ |
| 159 | + TypedPropertyFromAssignsRector::INLINE_PUBLIC => true, |
| 160 | + ]); |
| 161 | + $rectorConfig->rule(StringClassNameToClassConstantRector::class); |
| 162 | + $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); |
| 163 | + $rectorConfig->rule(CompleteDynamicPropertiesRector::class); |
| 164 | + $rectorConfig->rule(BooleanInIfConditionRuleFixerRector::class); |
| 165 | + $rectorConfig->rule(SingleInArrayToCompareRector::class); |
| 166 | + $rectorConfig->rule(VersionCompareFuncCallToConstantRector::class); |
| 167 | + $rectorConfig->rule(ExplicitBoolCompareRector::class); |
102 | 168 | }; |
0 commit comments