diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 3aef723..d91db3c 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -62,5 +62,5 @@ jobs: - name: Analyze for refactoring run: | - composer global require --dev rector/rector:^0.15.0 + composer global require --dev rector/rector:^0.15.1 rector process --dry-run --no-progress-bar diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index ac7cd76..d5b03cb 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -10,7 +10,10 @@ __DIR__ . '/src/', ]) ->exclude('build') - ->append([__FILE__]); + ->append([ + __FILE__, + __DIR__ . '/rector.php', + ]); $overrides = []; diff --git a/composer.json b/composer.json index e7c4e8c..2596b47 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "require-dev": { "codeigniter4/framework": "^4.1", "icanhazstring/composer-unused": "^0.8.2", - "rector/rector": "0.15.0" + "rector/rector": "0.15.1" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/rector.php b/rector.php index 19e4b3a..356660e 100644 --- a/rector.php +++ b/rector.php @@ -1,6 +1,7 @@ sets([SetList::DEAD_CODE, LevelSetList::UP_TO_PHP_74, PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, PHPUnitSetList::PHPUNIT_80]); + $rectorConfig->sets([ + SetList::DEAD_CODE, + LevelSetList::UP_TO_PHP_74, + PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, + PHPUnitSetList::PHPUNIT_100, + ]); + $rectorConfig->parallel(); + // The paths to refactor (can also be supplied with CLI arguments) $rectorConfig->paths([ __DIR__ . '/src/', @@ -78,7 +87,7 @@ __DIR__ . '/tests', ], - // Ignore files that should not be namespaced + // Ignore files that should not be namespaced to their folder NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [ __DIR__ . '/src/Helpers', ], @@ -89,6 +98,10 @@ // May be uninitialized on purpose AddDefaultValueForUndefinedVariableRector::class, ]); + + // auto import fully qualified class names + $rectorConfig->importNames(); + $rectorConfig->rule(SimplifyUselessVariableRector::class); $rectorConfig->rule(RemoveAlwaysElseRector::class); $rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class); @@ -116,4 +129,7 @@ // Set to false if you use in libraries, or it does create breaking changes. TypedPropertyFromAssignsRector::INLINE_PUBLIC => true, ]); + $rectorConfig->rule(StringClassNameToClassConstantRector::class); + $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); + $rectorConfig->rule(CompleteDynamicPropertiesRector::class); }; diff --git a/src/Template/.github/workflows/rector.yml b/src/Template/.github/workflows/rector.yml index b15bfcb..d91db3c 100644 --- a/src/Template/.github/workflows/rector.yml +++ b/src/Template/.github/workflows/rector.yml @@ -62,5 +62,5 @@ jobs: - name: Analyze for refactoring run: | - composer global require --dev rector/rector:^0.14 + composer global require --dev rector/rector:^0.15.1 rector process --dry-run --no-progress-bar diff --git a/src/Template/rector.php b/src/Template/rector.php index e11a68b..3c85e50 100644 --- a/src/Template/rector.php +++ b/src/Template/rector.php @@ -1,6 +1,7 @@ sets([SetList::DEAD_CODE, LevelSetList::UP_TO_PHP_74, PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, PHPUnitLevelSetList::UP_TO_PHPUNIT_100]); + $rectorConfig->sets([ + SetList::DEAD_CODE, + LevelSetList::UP_TO_PHP_74, + PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, + PHPUnitSetList::PHPUNIT_100, + ]); + $rectorConfig->parallel(); + // The paths to refactor (can also be supplied with CLI arguments) $rectorConfig->paths([ __DIR__ . '/app/', @@ -80,7 +88,7 @@ __DIR__ . '/tests', ], - // Ignore files that should not be namespaced + // Ignore files that should not be namespaced to their folder NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [ __DIR__ . '/app/Helpers', ], @@ -91,6 +99,10 @@ // May be uninitialized on purpose AddDefaultValueForUndefinedVariableRector::class, ]); + + // auto import fully qualified class names + $rectorConfig->importNames(); + $rectorConfig->rule(SimplifyUselessVariableRector::class); $rectorConfig->rule(RemoveAlwaysElseRector::class); $rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class); @@ -118,4 +130,7 @@ // Set to false if you use in libraries, or it does create breaking changes. TypedPropertyFromAssignsRector::INLINE_PUBLIC => true, ]); + $rectorConfig->rule(StringClassNameToClassConstantRector::class); + $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); + $rectorConfig->rule(CompleteDynamicPropertiesRector::class); };