|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use Rector\Caching\ValueObject\Storage\FileCacheStorage; |
3 | 6 | use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; |
4 | 7 | use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector; |
| 8 | +use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector; |
5 | 9 | use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector; |
6 | 10 | use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector; |
7 | 11 | use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector; |
8 | 12 | use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector; |
9 | 13 | use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector; |
| 14 | +use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector; |
10 | 15 | use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; |
11 | 16 | use Rector\CodeQuality\Rector\If_\CombineIfRector; |
| 17 | +use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector; |
12 | 18 | use Rector\CodeQuality\Rector\If_\ShortenElseIfRector; |
13 | 19 | use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector; |
14 | 20 | use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector; |
| 21 | +use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector; |
15 | 22 | use Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector; |
16 | 23 | use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector; |
17 | 24 | use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector; |
18 | 25 | use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; |
| 26 | +use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector; |
19 | 27 | use Rector\Config\RectorConfig; |
20 | | -use Rector\Core\ValueObject\PhpVersion; |
21 | 28 | use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector; |
22 | 29 | use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; |
23 | 30 | use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector; |
24 | 31 | use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; |
25 | 32 | use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; |
26 | 33 | use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; |
27 | | -use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; |
28 | 34 | use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector; |
| 35 | +use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector; |
| 36 | +use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; |
29 | 37 | use Rector\PHPUnit\Set\PHPUnitSetList; |
30 | 38 | use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; |
31 | 39 | use Rector\Set\ValueObject\LevelSetList; |
32 | 40 | use Rector\Set\ValueObject\SetList; |
| 41 | +use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; |
| 42 | +use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector; |
| 43 | +use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector; |
33 | 44 | use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; |
| 45 | +use Rector\ValueObject\PhpVersion; |
34 | 46 |
|
35 | 47 | return static function (RectorConfig $rectorConfig): void { |
36 | 48 | $rectorConfig->sets([ |
|
42 | 54 |
|
43 | 55 | $rectorConfig->parallel(); |
44 | 56 |
|
| 57 | + // Github action cache |
| 58 | + $rectorConfig->cacheClass(FileCacheStorage::class); |
| 59 | + if (is_dir('/tmp')) { |
| 60 | + $rectorConfig->cacheDirectory('/tmp/rector'); |
| 61 | + } |
| 62 | + |
45 | 63 | // The paths to refactor (can also be supplied with CLI arguments) |
46 | 64 | $rectorConfig->paths([ |
47 | 65 | __DIR__ . '/src/', |
|
70 | 88 |
|
71 | 89 | // Are there files or rules you need to skip? |
72 | 90 | $rectorConfig->skip([ |
73 | | - __DIR__ . '/app/Views', |
74 | | - __DIR__ . '/src/Language/en', |
75 | | - |
76 | | - JsonThrowOnErrorRector::class, |
77 | 91 | StringifyStrNeedlesRector::class, |
| 92 | + YieldDataProviderRector::class, |
78 | 93 |
|
79 | 94 | // Note: requires php 8 |
80 | 95 | RemoveUnusedPromotedPropertyRector::class, |
| 96 | + AnnotationWithValueToAttributeRector::class, |
81 | 97 |
|
82 | 98 | // May load view files directly when detecting classes |
83 | 99 | StringClassNameToClassConstantRector::class, |
|
105 | 121 | $rectorConfig->rule(FuncGetArgsToVariadicParamRector::class); |
106 | 122 | $rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class); |
107 | 123 | $rectorConfig->rule(SimplifyEmptyArrayCheckRector::class); |
| 124 | + $rectorConfig->rule(SimplifyEmptyCheckOnEmptyArrayRector::class); |
| 125 | + $rectorConfig->rule(TernaryEmptyArrayArrayDimFetchToCoalesceRector::class); |
| 126 | + $rectorConfig->rule(EmptyOnNullableObjectToInstanceOfRector::class); |
| 127 | + $rectorConfig->rule(DisallowedEmptyRuleFixerRector::class); |
108 | 128 | $rectorConfig |
109 | 129 | ->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [ |
110 | 130 | /** |
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 |
| 131 | + * The INLINE_PUBLIC value is default to false to avoid BC break, |
| 132 | + * if you use for libraries and want to preserve BC break, you don't |
| 133 | + * need to configure it, as it included in LevelSetList::UP_TO_PHP_74 |
112 | 134 | * Set to true for projects that allow BC break |
113 | 135 | */ |
114 | 136 | TypedPropertyFromAssignsRector::INLINE_PUBLIC => false, |
115 | 137 | ]); |
116 | 138 | $rectorConfig->rule(StringClassNameToClassConstantRector::class); |
117 | 139 | $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); |
118 | 140 | $rectorConfig->rule(CompleteDynamicPropertiesRector::class); |
| 141 | + $rectorConfig->rule(BooleanInIfConditionRuleFixerRector::class); |
| 142 | + $rectorConfig->rule(SingleInArrayToCompareRector::class); |
| 143 | + $rectorConfig->rule(VersionCompareFuncCallToConstantRector::class); |
| 144 | + $rectorConfig->rule(ExplicitBoolCompareRector::class); |
119 | 145 | }; |
0 commit comments