|
53 | 53 | use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
|
54 | 54 | use Rector\PHPUnit\Set\PHPUnitSetList;
|
55 | 55 | use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
|
56 |
| -use Rector\Set\ValueObject\LevelSetList; |
57 |
| -use Rector\Set\ValueObject\SetList; |
58 | 56 | use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
|
59 | 57 | use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;
|
60 | 58 | use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
|
64 | 62 | use Utils\Rector\RemoveErrorSuppressInTryCatchStmtsRector;
|
65 | 63 | use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;
|
66 | 64 |
|
67 |
| -return static function (RectorConfig $rectorConfig): void { |
68 |
| - $rectorConfig->sets([ |
69 |
| - SetList::DEAD_CODE, |
70 |
| - LevelSetList::UP_TO_PHP_81, |
| 65 | +return RectorConfig::configure() |
| 66 | + ->withPhpSets(php81: true) |
| 67 | + ->withPreparedSets(deadCode: true) |
| 68 | + ->withSets([ |
71 | 69 | PHPUnitSetList::PHPUNIT_CODE_QUALITY,
|
72 | 70 | PHPUnitSetList::PHPUNIT_100,
|
73 |
| - ]); |
74 |
| - |
75 |
| - $rectorConfig->parallel(120, 8, 10); |
76 |
| - |
77 |
| - // Github action cache |
78 |
| - $rectorConfig->cacheClass(FileCacheStorage::class); |
79 |
| - if (is_dir('/tmp')) { |
80 |
| - $rectorConfig->cacheDirectory('/tmp/rector'); |
81 |
| - } |
82 |
| - |
| 71 | + ]) |
| 72 | + ->withParallel(120, 8, 10) |
| 73 | + ->withCache( |
| 74 | + // Github action cache or local |
| 75 | + is_dir('/tmp') ? '/tmp/rector' : sys_get_temp_dir() . '/rector', |
| 76 | + FileCacheStorage::class |
| 77 | + ) |
83 | 78 | // paths to refactor; solid alternative to CLI arguments
|
84 |
| - $rectorConfig->paths([__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils']); |
85 |
| - |
| 79 | + ->withPaths( |
| 80 | + [__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils'] |
| 81 | + ) |
86 | 82 | // do you need to include constants, class aliases or custom autoloader? files listed will be executed
|
87 |
| - $rectorConfig->bootstrapFiles([ |
| 83 | + ->withBootstrapFiles([ |
88 | 84 | __DIR__ . '/system/Test/bootstrap.php',
|
89 |
| - ]); |
90 |
| - |
91 |
| - $rectorConfig->phpstanConfigs([ |
| 85 | + ]) |
| 86 | + ->withPHPStanConfigs([ |
92 | 87 | __DIR__ . '/phpstan.neon.dist',
|
93 | 88 | __DIR__ . '/vendor/codeigniter/phpstan-codeigniter/extension.neon',
|
94 | 89 | __DIR__ . '/vendor/phpstan/phpstan-strict-rules/rules.neon',
|
95 |
| - ]); |
96 |
| - |
| 90 | + ]) |
97 | 91 | // is there a file you need to skip?
|
98 |
| - $rectorConfig->skip([ |
| 92 | + ->withSkip([ |
99 | 93 | __DIR__ . '/system/Debug/Toolbar/Views/toolbar.tpl.php',
|
100 | 94 | __DIR__ . '/system/ThirdParty',
|
101 | 95 | __DIR__ . '/tests/system/Config/fixtures',
|
|
187 | 181 | AnnotationWithValueToAttributeRector::class,
|
188 | 182 | AnnotationToAttributeRector::class,
|
189 | 183 | CoversAnnotationWithValueToAttributeRector::class,
|
190 |
| - ]); |
191 |
| - |
| 184 | + ]) |
192 | 185 | // auto import fully qualified class names
|
193 |
| - $rectorConfig->importNames(); |
194 |
| - $rectorConfig->removeUnusedImports(); |
195 |
| - |
196 |
| - $rectorConfig->rule(DeclareStrictTypesRector::class); |
197 |
| - $rectorConfig->rule(UnderscoreToCamelCaseVariableNameRector::class); |
198 |
| - $rectorConfig->rule(SimplifyUselessVariableRector::class); |
199 |
| - $rectorConfig->rule(RemoveAlwaysElseRector::class); |
200 |
| - $rectorConfig->rule(PassStrictParameterToFunctionParameterRector::class); |
201 |
| - $rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class); |
202 |
| - $rectorConfig->rule(ChangeNestedForeachIfsToEarlyContinueRector::class); |
203 |
| - $rectorConfig->rule(ChangeIfElseValueAssignToEarlyReturnRector::class); |
204 |
| - $rectorConfig->rule(SimplifyStrposLowerRector::class); |
205 |
| - $rectorConfig->rule(CombineIfRector::class); |
206 |
| - $rectorConfig->rule(SimplifyIfReturnBoolRector::class); |
207 |
| - $rectorConfig->rule(InlineIfToExplicitIfRector::class); |
208 |
| - $rectorConfig->rule(PreparedValueToEarlyReturnRector::class); |
209 |
| - $rectorConfig->rule(ShortenElseIfRector::class); |
210 |
| - $rectorConfig->rule(SimplifyIfElseToTernaryRector::class); |
211 |
| - $rectorConfig->rule(UnusedForeachValueToArrayKeysRector::class); |
212 |
| - $rectorConfig->rule(ChangeArrayPushToArrayAssignRector::class); |
213 |
| - $rectorConfig->rule(UnnecessaryTernaryExpressionRector::class); |
214 |
| - $rectorConfig->rule(RemoveErrorSuppressInTryCatchStmtsRector::class); |
215 |
| - $rectorConfig->rule(FuncGetArgsToVariadicParamRector::class); |
216 |
| - $rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class); |
217 |
| - $rectorConfig->rule(SimplifyEmptyArrayCheckRector::class); |
218 |
| - $rectorConfig->rule(SimplifyEmptyCheckOnEmptyArrayRector::class); |
219 |
| - $rectorConfig->rule(TernaryEmptyArrayArrayDimFetchToCoalesceRector::class); |
220 |
| - $rectorConfig->rule(EmptyOnNullableObjectToInstanceOfRector::class); |
221 |
| - $rectorConfig->rule(DisallowedEmptyRuleFixerRector::class); |
222 |
| - $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); |
223 |
| - $rectorConfig->rule(CompleteDynamicPropertiesRector::class); |
224 |
| - $rectorConfig->rule(BooleanInIfConditionRuleFixerRector::class); |
225 |
| - $rectorConfig->rule(SingleInArrayToCompareRector::class); |
226 |
| - $rectorConfig->rule(VersionCompareFuncCallToConstantRector::class); |
227 |
| - $rectorConfig->rule(ExplicitBoolCompareRector::class); |
228 |
| - |
229 |
| - $rectorConfig |
230 |
| - ->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [ |
231 |
| - // keep '\\' prefix string on string '\Foo\Bar' |
232 |
| - StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true, |
233 |
| - ]); |
234 |
| -}; |
| 186 | + ->withImportNames(removeUnusedImports: true) |
| 187 | + ->withRules([ |
| 188 | + DeclareStrictTypesRector::class, |
| 189 | + UnderscoreToCamelCaseVariableNameRector::class, |
| 190 | + SimplifyUselessVariableRector::class, |
| 191 | + RemoveAlwaysElseRector::class, |
| 192 | + PassStrictParameterToFunctionParameterRector::class, |
| 193 | + CountArrayToEmptyArrayComparisonRector::class, |
| 194 | + ChangeNestedForeachIfsToEarlyContinueRector::class, |
| 195 | + ChangeIfElseValueAssignToEarlyReturnRector::class, |
| 196 | + SimplifyStrposLowerRector::class, |
| 197 | + CombineIfRector::class, |
| 198 | + SimplifyIfReturnBoolRector::class, |
| 199 | + InlineIfToExplicitIfRector::class, |
| 200 | + PreparedValueToEarlyReturnRector::class, |
| 201 | + ShortenElseIfRector::class, |
| 202 | + SimplifyIfElseToTernaryRector::class, |
| 203 | + UnusedForeachValueToArrayKeysRector::class, |
| 204 | + ChangeArrayPushToArrayAssignRector::class, |
| 205 | + UnnecessaryTernaryExpressionRector::class, |
| 206 | + RemoveErrorSuppressInTryCatchStmtsRector::class, |
| 207 | + FuncGetArgsToVariadicParamRector::class, |
| 208 | + MakeInheritedMethodVisibilitySameAsParentRector::class, |
| 209 | + SimplifyEmptyArrayCheckRector::class, |
| 210 | + SimplifyEmptyCheckOnEmptyArrayRector::class, |
| 211 | + TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, |
| 212 | + EmptyOnNullableObjectToInstanceOfRector::class, |
| 213 | + DisallowedEmptyRuleFixerRector::class, |
| 214 | + PrivatizeFinalClassPropertyRector::class, |
| 215 | + CompleteDynamicPropertiesRector::class, |
| 216 | + BooleanInIfConditionRuleFixerRector::class, |
| 217 | + SingleInArrayToCompareRector::class, |
| 218 | + VersionCompareFuncCallToConstantRector::class, |
| 219 | + ExplicitBoolCompareRector::class, |
| 220 | + ]) |
| 221 | + ->withConfiguredRule(StringClassNameToClassConstantRector::class, [ |
| 222 | + // keep '\\' prefix string on string '\Foo\Bar' |
| 223 | + StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true, |
| 224 | + ]); |
0 commit comments