|
27 | 27 | use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; |
28 | 28 | use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; |
29 | 29 | use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector; |
30 | | -use Rector\Php70\Rector\FuncCall\RandomFunctionRector; |
31 | | -use Rector\Php71\Rector\FuncCall\CountOnNullRector; |
32 | 30 | use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; |
33 | 31 | use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector; |
34 | | -use Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector; |
35 | 32 | use Rector\PHPUnit\Set\PHPUnitSetList; |
36 | 33 | use Rector\Set\ValueObject\LevelSetList; |
37 | 34 | use Rector\Set\ValueObject\SetList; |
38 | 35 | use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; |
39 | 36 |
|
40 | 37 | return static function (ContainerConfigurator $containerConfigurator): void { |
| 38 | + // Rule sets to apply |
41 | 39 | $containerConfigurator->import(SetList::DEAD_CODE); |
42 | 40 | $containerConfigurator->import(LevelSetList::UP_TO_PHP_73); |
43 | 41 | $containerConfigurator->import(PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD); |
44 | 42 | $containerConfigurator->import(PHPUnitSetList::PHPUNIT_80); |
45 | 43 |
|
46 | 44 | $parameters = $containerConfigurator->parameters(); |
47 | 45 |
|
48 | | - // paths to refactor; solid alternative to CLI arguments |
49 | | - $parameters->set(Option::PATHS, [__DIR__ . '/app', __DIR__ . '/tests']); |
| 46 | + // The paths to refactor (can also be supplied with CLI arguments) |
| 47 | + $parameters->set(Option::PATHS, [ |
| 48 | + __DIR__ . '/app', |
| 49 | + __DIR__ . '/tests', |
| 50 | + ]); |
50 | 51 |
|
51 | | - // do you need to include constants, class aliases or custom autoloader? files listed will be executed |
| 52 | + // Do you need to include constants, class aliases, or a custom autoloader? |
52 | 53 | $parameters->set(Option::BOOTSTRAP_FILES, [ |
53 | | - realpath(getcwd()) . '/vendor/autoload.php', |
54 | 54 | realpath(getcwd()) . '/vendor/codeigniter4/framework/system/Test/bootstrap.php', |
55 | 55 | ]); |
56 | 56 |
|
57 | | - // is there a file you need to skip? |
| 57 | + // Set the target version for refactoring |
| 58 | + $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_73); |
| 59 | + |
| 60 | + // Auto-import fully qualified class names |
| 61 | + $parameters->set(Option::AUTO_IMPORT_NAMES, true); |
| 62 | + |
| 63 | + // Are there files or rules you need to skip? |
58 | 64 | $parameters->set(Option::SKIP, [ |
59 | 65 | __DIR__ . '/app/Views', |
60 | 66 |
|
61 | 67 | JsonThrowOnErrorRector::class, |
62 | 68 | StringifyStrNeedlesRector::class, |
63 | 69 |
|
64 | | - // requires php 8 |
| 70 | + // Note: requires php 8 |
65 | 71 | RemoveUnusedPromotedPropertyRector::class, |
66 | 72 |
|
67 | | - // call on purpose for nothing happen check |
| 73 | + // Ignore tests that might make calls without a result |
68 | 74 | RemoveEmptyMethodCallRector::class => [ |
69 | 75 | __DIR__ . '/tests', |
70 | 76 | ], |
71 | 77 |
|
72 | | - // may cause load view files directly when detecting class that |
73 | | - // make warning |
| 78 | + // May load view files directly when detecting classes |
74 | 79 | StringClassNameToClassConstantRector::class, |
75 | 80 |
|
76 | | - // sometime too detail |
77 | | - CountOnNullRector::class, |
78 | | - |
79 | | - // may not be unitialized on purpose |
| 81 | + // May be uninitialized on purpose |
80 | 82 | AddDefaultValueForUndefinedVariableRector::class, |
81 | | - |
82 | | - // use mt_rand instead of random_int on purpose on non-cryptographically random |
83 | | - RandomFunctionRector::class, |
84 | | - |
85 | | - // assertContains() to string can't be used in PHPUnit 9.1 |
86 | | - AssertFalseStrposToContainsRector::class, |
87 | 83 | ]); |
88 | 84 |
|
89 | | - // auto import fully qualified class names |
90 | | - $parameters->set(Option::AUTO_IMPORT_NAMES, true); |
91 | | - $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_73); |
92 | | - |
| 85 | + // Additional rules to apply |
93 | 86 | $services = $containerConfigurator->services(); |
94 | 87 | $services->set(SimplifyUselessVariableRector::class); |
95 | 88 | $services->set(RemoveAlwaysElseRector::class); |
|
0 commit comments