|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use Rector\Caching\ValueObject\Storage\FileCacheStorage; |
| 6 | +use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; |
| 7 | +use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector; |
| 8 | +use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector; |
| 9 | +use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector; |
| 10 | +use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; |
| 11 | +use Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector; |
| 12 | +use Rector\Config\RectorConfig; |
| 13 | +use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector; |
| 14 | +use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector; |
| 15 | +use Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector; |
| 16 | +use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; |
| 17 | +use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector; |
| 18 | +use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector; |
| 19 | +use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; |
| 20 | +use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; |
| 21 | +use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; |
| 22 | +use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; |
| 23 | + |
| 24 | +/** |
| 25 | + * How to run: |
| 26 | + * |
| 27 | + * ```bash |
| 28 | + * composer require rector/rector --dev |
| 29 | + * ./vendor/bin/rector process |
| 30 | + * ``` |
| 31 | + */ |
| 32 | +return RectorConfig::configure() |
| 33 | + ->withAutoloadPaths([ |
| 34 | + file_exists(__DIR__ . '/../../autoload.php') ? __DIR__ . '/../../autoload.php' : null, |
| 35 | + file_exists(__DIR__ . '/vendor/autoload.php') ? __DIR__ . '/vendor/autoload.php' : null, |
| 36 | + ]) |
| 37 | + ->withCache(__DIR__ . '/../../../runtime/cache/rector', FileCacheStorage::class) |
| 38 | + ->withPreparedSets(deadCode: true, codeQuality: true) |
| 39 | + ->withPhpSets(php83: true, php84: true) |
| 40 | + ->withPhpVersion(\Rector\ValueObject\PhpVersion::PHP_84) |
| 41 | + ->withoutParallel() |
| 42 | + ->withPaths([ |
| 43 | + __DIR__ . '/src', |
| 44 | + ]) |
| 45 | + ->withRules([ |
| 46 | + RemoveAlwaysElseRector::class, |
| 47 | + ChangeNestedIfsToEarlyReturnRector::class, |
| 48 | + ChangeIfElseValueAssignToEarlyReturnRector::class, |
| 49 | + ChangeNestedForeachIfsToEarlyContinueRector::class, |
| 50 | + ]) |
| 51 | + ->withSkip([ |
| 52 | + // Too many places where json_decode was used intentionally on wrong data =\ |
| 53 | + JsonThrowOnErrorRector::class, |
| 54 | + |
| 55 | + // Frequently used for debug. Maybe, such places should be annotated with @noRector? |
| 56 | + SimplifyUselessVariableRector::class, |
| 57 | + |
| 58 | + // Legacy modules are full of `_doSomeShit()` methods that are likely called as `$this->_do{$operation}` |
| 59 | + RemoveUnusedPrivateMethodRector::class, |
| 60 | + |
| 61 | + // Does not make sense for us |
| 62 | + SimplifyRegexPatternRector::class, |
| 63 | + |
| 64 | + // Requires whole project autoloaded to work well |
| 65 | + RemoveUnusedPrivateClassConstantRector::class, |
| 66 | + |
| 67 | + // don't refactor with `empty` check function |
| 68 | + DisallowedEmptyRuleFixerRector::class, |
| 69 | + SimplifyEmptyArrayCheckRector::class, |
| 70 | + SimplifyEmptyCheckOnEmptyArrayRector::class, |
| 71 | + |
| 72 | + // do not refactor `query` attribute like " . '$select' . " to 'SELECT $select ...' |
| 73 | + JoinStringConcatRector::class, |
| 74 | + |
| 75 | + // do not refactor php version id checkers |
| 76 | + RemovePhpVersionIdCheckRector::class, |
| 77 | + RemoveExtraParametersRector::class, |
| 78 | + |
| 79 | + SwitchNegatedTernaryRector::class, |
| 80 | + ]); |
0 commit comments