From 29d90f7d5ef4cde234e10f9231926bc0d67a7421 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 15 Dec 2022 09:46:14 +0900 Subject: [PATCH 1/3] chore: add rector.php to php-cs-fixer --- .php-cs-fixer.dist.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 = []; From 0bf0998756a9b6de7101ea0f69a1736a4d8d0b01 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 15 Dec 2022 09:50:26 +0900 Subject: [PATCH 2/3] Update rector version --- .github/workflows/rector.yml | 2 +- composer.json | 2 +- src/Template/.github/workflows/rector.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/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/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 From 786ef6918c05db1dca9923e94bd72f66664d7736 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 15 Dec 2022 09:49:19 +0900 Subject: [PATCH 3/3] Update rector.php From shield. --- rector.php | 20 ++++++++++++++++++-- src/Template/rector.php | 21 ++++++++++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) 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/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); };