From 860fd5fb1e49ae721e7e831537eff79de6032075 Mon Sep 17 00:00:00 2001 From: Eike Starkmann Date: Mon, 27 Nov 2023 16:34:06 +0100 Subject: [PATCH 1/8] [FEATURE] Add Rector Part of #851 --- composer.json | 1 + rector.php | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 rector.php diff --git a/composer.json b/composer.json index 09cfb95a..842c3932 100644 --- a/composer.json +++ b/composer.json @@ -60,6 +60,7 @@ "seld/jsonlint": "^1.10.2", "spaze/phpstan-disallowed-calls": "^3.3", "squizlabs/php_codesniffer": "^3.9.2", + "ssch/typo3-rector": "^1.3", "symfony/console": "^5.4 || ^6.4 || ^7.0", "symfony/translation": "^5.4 || ^6.4 || ^7.0", "symfony/yaml": "^5.4 || ^6.4 || ^7.0", diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..fffdd621 --- /dev/null +++ b/rector.php @@ -0,0 +1,110 @@ +parameters(); + // $parameters->set(Typo3Option::TYPOSCRIPT_INDENT_SIZE, 2); + + $rectorConfig->sets([ + Typo3LevelSetList::UP_TO_TYPO3_11, + // https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/Configuration/Icons.html + // Typo3SetList::REGISTER_ICONS_TO_ICON, + ]); + + // Register a single rule. Single rules don't load the main config file, therefore the config file needs to be loaded manually. + // $rectorConfig->import(__DIR__ . '/vendor/ssch/typo3-rector/config/config.php'); + // $rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v0\InjectAnnotationRector::class); + + // To have a better analysis from phpstan, we teach it here some more things + $rectorConfig->phpstanConfig(Typo3Option::PHPSTAN_FOR_RECTOR_PATH); + + // FQN classes are not imported by default. If you don't do it manually after every Rector run, enable it by: + $rectorConfig->importNames(); + + // Disable parallel otherwise non php file processing is not working i.e. typoscript or flexform + $rectorConfig->disableParallel(); + + // this will not import root namespace classes, like \DateTime or \Exception + $rectorConfig->importShortClasses(false); + + // Define your target version which you want to support + $rectorConfig->phpVersion(PhpVersion::PHP_74); + + // If you only want to process one/some TYPO3 extension(s), you can specify its path(s) here. + // If you use the option --config change __DIR__ to getcwd() + // $rectorConfig->paths([ + // __DIR__ . '/packages/acme_demo/', + // ]); + + // When you use rector there are rules that require some more actions like creating UpgradeWizards for outdated TCA types. + // To fully support you we added some warnings. So watch out for them. + + // If you use importNames(), you should consider excluding some TYPO3 files. + $rectorConfig->skip([ + // @see https://github.com/sabbelasichon/typo3-rector/issues/2536 + __DIR__ . '/**/Configuration/ExtensionBuilder/*', + // We skip those directories on purpose as there might be node_modules or similar + // that include typescript which would result in false positive processing + __DIR__ . '/**/Resources/**/node_modules/*', + __DIR__ . '/**/Resources/**/NodeModules/*', + __DIR__ . '/**/Resources/**/BowerComponents/*', + __DIR__ . '/**/Resources/**/bower_components/*', + __DIR__ . '/**/Resources/**/build/*', + __DIR__ . '/vendor/*', + __DIR__ . '/Build/*', + __DIR__ . '/public/*', + __DIR__ . '/.github/*', + __DIR__ . '/.Build/*', + NameImportingPostRector::class => [ + 'ext_localconf.php', + 'ext_tables.php', + 'ClassAliasMap.php', + __DIR__ . '/**/Configuration/*.php', + __DIR__ . '/**/Configuration/**/*.php', + ] + ]); + + // If you have trouble that rector cannot run because some TYPO3 constants are not defined add an additional constants file + // @see https://github.com/sabbelasichon/typo3-rector/blob/main/typo3.constants.php + // @see https://getrector.com/documentation/static-reflection-and-autoload#include-files + // $rectorConfig->bootstrapFiles([ + // __DIR__ . '/typo3.constants.php' + // ]); + + /** + * Useful rule from RectorPHP itself to transform i.e. GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager') + * to GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class) calls. + * But be warned, sometimes it produces false positives (edge cases), so watch out + */ + // $rectorConfig->rule(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class); + + // Optional non-php file functionalities: + // @see https://github.com/sabbelasichon/typo3-rector/blob/main/docs/beyond_php_file_processors.md + + // Rewrite your extbase persistence class mapping from typoscript into php according to official docs. + // This processor will create a summarized file with all the typoscript rewrites combined into a single file. + /* $rectorConfig->ruleWithConfiguration(\Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v10\v0\ExtbasePersistenceTypoScriptRector::class, [ + \Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v10\v0\ExtbasePersistenceTypoScriptRector::FILENAME => __DIR__ . '/packages/acme_demo/Configuration/Extbase/Persistence/Classes.php', + ]); */ + // Add some general TYPO3 rules + $rectorConfig->rule(ConvertImplicitVariablesToExplicitGlobalsRector::class); + $rectorConfig->ruleWithConfiguration(ExtEmConfRector::class, [ + ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [] + ]); + + // Modernize your TypoScript include statements for files and move from to @import use the FileIncludeToImportStatementVisitor (introduced with TYPO3 9.0) + // $rectorConfig->rule(\Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v9\v0\FileIncludeToImportStatementTypoScriptRector::class); +}; From 8263657195063acc9c779f5a47c3383280349e4a Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 7 May 2024 14:23:18 +0200 Subject: [PATCH 2/8] Update Rector --- composer.json | 2 +- rector.php | 169 +++++++++++++++++++++++--------------------------- 2 files changed, 78 insertions(+), 93 deletions(-) diff --git a/composer.json b/composer.json index 842c3932..2d2d3e57 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,7 @@ "seld/jsonlint": "^1.10.2", "spaze/phpstan-disallowed-calls": "^3.3", "squizlabs/php_codesniffer": "^3.9.2", - "ssch/typo3-rector": "^1.3", + "ssch/typo3-rector": "^2.5.0", "symfony/console": "^5.4 || ^6.4 || ^7.0", "symfony/translation": "^5.4 || ^6.4 || ^7.0", "symfony/yaml": "^5.4 || ^6.4 || ^7.0", diff --git a/rector.php b/rector.php index fffdd621..6976a887 100644 --- a/rector.php +++ b/rector.php @@ -3,108 +3,93 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Core\Configuration\Option; -use Rector\Core\ValueObject\PhpVersion; +use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\PostRector\Rector\NameImportingPostRector; +use Rector\Set\ValueObject\LevelSetList; +use Rector\Set\ValueObject\SetList; +use Rector\ValueObject\PhpVersion; +use Ssch\TYPO3Rector\CodeQuality\General\ConvertImplicitVariablesToExplicitGlobalsRector; +use Ssch\TYPO3Rector\CodeQuality\General\ExtEmConfRector; use Ssch\TYPO3Rector\Configuration\Typo3Option; -use Ssch\TYPO3Rector\Rector\General\ConvertImplicitVariablesToExplicitGlobalsRector; -use Ssch\TYPO3Rector\Rector\General\ExtEmConfRector; use Ssch\TYPO3Rector\Set\Typo3LevelSetList; use Ssch\TYPO3Rector\Set\Typo3SetList; - -return static function (RectorConfig $rectorConfig): void { - - // If you want to override the number of spaces for your typoscript files you can define it here, the default value is 4 - // $parameters = $rectorConfig->parameters(); - // $parameters->set(Typo3Option::TYPOSCRIPT_INDENT_SIZE, 2); - - $rectorConfig->sets([ - Typo3LevelSetList::UP_TO_TYPO3_11, - // https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/Configuration/Icons.html - // Typo3SetList::REGISTER_ICONS_TO_ICON, - ]); - - // Register a single rule. Single rules don't load the main config file, therefore the config file needs to be loaded manually. - // $rectorConfig->import(__DIR__ . '/vendor/ssch/typo3-rector/config/config.php'); - // $rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v0\InjectAnnotationRector::class); - - // To have a better analysis from phpstan, we teach it here some more things - $rectorConfig->phpstanConfig(Typo3Option::PHPSTAN_FOR_RECTOR_PATH); - - // FQN classes are not imported by default. If you don't do it manually after every Rector run, enable it by: - $rectorConfig->importNames(); - - // Disable parallel otherwise non php file processing is not working i.e. typoscript or flexform - $rectorConfig->disableParallel(); - - // this will not import root namespace classes, like \DateTime or \Exception - $rectorConfig->importShortClasses(false); - - // Define your target version which you want to support - $rectorConfig->phpVersion(PhpVersion::PHP_74); - - // If you only want to process one/some TYPO3 extension(s), you can specify its path(s) here. - // If you use the option --config change __DIR__ to getcwd() - // $rectorConfig->paths([ - // __DIR__ . '/packages/acme_demo/', - // ]); - - // When you use rector there are rules that require some more actions like creating UpgradeWizards for outdated TCA types. - // To fully support you we added some warnings. So watch out for them. - +use Ssch\Typo3RectorTestingFramework\Set\TYPO3TestingFrameworkSetList; + +return RectorConfig::configure() + ->withConfiguredRule(ExtEmConfRector::class, [ + ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [], + ]) + ->withPaths([ + __DIR__ . '/Classes/', + __DIR__ . '/Configuration/', + __DIR__ . '/Tests/', + ]) + ->withPhpSets( + true + ) + ->withSets([ + // Typo3LevelSetList::UP_TO_TYPO3_10, + // Typo3LevelSetList::UP_TO_TYPO3_11, + // Typo3LevelSetList::UP_TO_TYPO3_12, + + Typo3SetList::TYPO3_11, + + // Typo3SetList::CODE_QUALITY, + // Typo3SetList::GENERAL, + + // TYPO3TestingFrameworkSetList::TYPO3_TESTING_FRAMEWORK_7, + + // LevelSetList::UP_TO_PHP_53, + // LevelSetList::UP_TO_PHP_54, + // LevelSetList::UP_TO_PHP_55, + // LevelSetList::UP_TO_PHP_56, + // LevelSetList::UP_TO_PHP_70, + // LevelSetList::UP_TO_PHP_71, + // LevelSetList::UP_TO_PHP_72, + // LevelSetList::UP_TO_PHP_73, + // LevelSetList::UP_TO_PHP_74, + // LevelSetList::UP_TO_PHP_80, + // LevelSetList::UP_TO_PHP_81, + // LevelSetList::UP_TO_PHP_82, + // LevelSetList::UP_TO_PHP_83, + + // https://github.com/sabbelasichon/typo3-rector/blob/main/src/Set/Typo3LevelSetList.php + // https://github.com/sabbelasichon/typo3-rector/blob/main/src/Set/Typo3SetList.php + + // SetList::CODE_QUALITY, + // SetList::CODING_STYLE, + // SetList::DEAD_CODE, + // SetList::TYPE_DECLARATION, + // SetList::EARLY_RETURN, + + // PHPUnitSetList::PHPUNIT80_DMS, + // PHPUnitSetList::PHPUNIT_40, + // PHPUnitSetList::PHPUNIT_50, + // PHPUnitSetList::PHPUNIT_60, + // PHPUnitSetList::PHPUNIT_70, + // PHPUnitSetList::PHPUNIT_80, + // PHPUnitSetList::PHPUNIT_90, + // PHPUnitSetList::PHPUNIT_100, + // PHPUnitSetList::PHPUNIT_CODE_QUALITY, + ]) + // To have a better analysis from PHPStan, we teach it here some more things + ->withPHPStanConfigs([ + Typo3Option::PHPSTAN_FOR_RECTOR_PATH, + ]) + ->withPhpVersion(PhpVersion::PHP_74) + ->withRules([ + ConvertImplicitVariablesToExplicitGlobalsRector::class, + ]) // If you use importNames(), you should consider excluding some TYPO3 files. - $rectorConfig->skip([ + ->withSkip([ // @see https://github.com/sabbelasichon/typo3-rector/issues/2536 - __DIR__ . '/**/Configuration/ExtensionBuilder/*', - // We skip those directories on purpose as there might be node_modules or similar - // that include typescript which would result in false positive processing - __DIR__ . '/**/Resources/**/node_modules/*', - __DIR__ . '/**/Resources/**/NodeModules/*', - __DIR__ . '/**/Resources/**/BowerComponents/*', - __DIR__ . '/**/Resources/**/bower_components/*', - __DIR__ . '/**/Resources/**/build/*', - __DIR__ . '/vendor/*', - __DIR__ . '/Build/*', - __DIR__ . '/public/*', __DIR__ . '/.github/*', __DIR__ . '/.Build/*', NameImportingPostRector::class => [ 'ext_localconf.php', 'ext_tables.php', 'ClassAliasMap.php', - __DIR__ . '/**/Configuration/*.php', - __DIR__ . '/**/Configuration/**/*.php', - ] + __DIR__ . '/Configuration/*.php', + __DIR__ . '/Configuration/**/*.php', + ], ]); - - // If you have trouble that rector cannot run because some TYPO3 constants are not defined add an additional constants file - // @see https://github.com/sabbelasichon/typo3-rector/blob/main/typo3.constants.php - // @see https://getrector.com/documentation/static-reflection-and-autoload#include-files - // $rectorConfig->bootstrapFiles([ - // __DIR__ . '/typo3.constants.php' - // ]); - - /** - * Useful rule from RectorPHP itself to transform i.e. GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager') - * to GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class) calls. - * But be warned, sometimes it produces false positives (edge cases), so watch out - */ - // $rectorConfig->rule(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class); - - // Optional non-php file functionalities: - // @see https://github.com/sabbelasichon/typo3-rector/blob/main/docs/beyond_php_file_processors.md - - // Rewrite your extbase persistence class mapping from typoscript into php according to official docs. - // This processor will create a summarized file with all the typoscript rewrites combined into a single file. - /* $rectorConfig->ruleWithConfiguration(\Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v10\v0\ExtbasePersistenceTypoScriptRector::class, [ - \Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v10\v0\ExtbasePersistenceTypoScriptRector::FILENAME => __DIR__ . '/packages/acme_demo/Configuration/Extbase/Persistence/Classes.php', - ]); */ - // Add some general TYPO3 rules - $rectorConfig->rule(ConvertImplicitVariablesToExplicitGlobalsRector::class); - $rectorConfig->ruleWithConfiguration(ExtEmConfRector::class, [ - ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [] - ]); - - // Modernize your TypoScript include statements for files and move from to @import use the FileIncludeToImportStatementVisitor (introduced with TYPO3 9.0) - // $rectorConfig->rule(\Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v9\v0\FileIncludeToImportStatementTypoScriptRector::class); -}; From 2ba78a3bb3ba3d4c9bcb757604199d24ecb8ba46 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 7 May 2024 14:23:42 +0200 Subject: [PATCH 3/8] Add `ssch/typo3-rector-testing-framework` --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 2d2d3e57..b50d6304 100644 --- a/composer.json +++ b/composer.json @@ -61,6 +61,7 @@ "spaze/phpstan-disallowed-calls": "^3.3", "squizlabs/php_codesniffer": "^3.9.2", "ssch/typo3-rector": "^2.5.0", + "ssch/typo3-rector-testing-framework": "^2.0.1", "symfony/console": "^5.4 || ^6.4 || ^7.0", "symfony/translation": "^5.4 || ^6.4 || ^7.0", "symfony/yaml": "^5.4 || ^6.4 || ^7.0", From b0a02b134f98768f4424b303b2cdc96bd14ac138 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 7 May 2024 14:27:27 +0200 Subject: [PATCH 4/8] Do not skip `NameImportingPostRector` for some files anymore --- rector.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/rector.php b/rector.php index 6976a887..e21b2761 100644 --- a/rector.php +++ b/rector.php @@ -4,7 +4,6 @@ use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitSetList; -use Rector\PostRector\Rector\NameImportingPostRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; use Rector\ValueObject\PhpVersion; @@ -85,11 +84,4 @@ // @see https://github.com/sabbelasichon/typo3-rector/issues/2536 __DIR__ . '/.github/*', __DIR__ . '/.Build/*', - NameImportingPostRector::class => [ - 'ext_localconf.php', - 'ext_tables.php', - 'ClassAliasMap.php', - __DIR__ . '/Configuration/*.php', - __DIR__ . '/Configuration/**/*.php', - ], ]); From 7d58c2382ae33b6a10c703b89bf5d20fe20f50d3 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 7 May 2024 15:11:12 +0200 Subject: [PATCH 5/8] Rework the Rector configuration --- rector.php | 65 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/rector.php b/rector.php index e21b2761..ab8df001 100644 --- a/rector.php +++ b/rector.php @@ -2,10 +2,14 @@ declare(strict_types=1); +use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector; +use Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector; use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; +use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; +use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector; use Rector\ValueObject\PhpVersion; use Ssch\TYPO3Rector\CodeQuality\General\ConvertImplicitVariablesToExplicitGlobalsRector; use Ssch\TYPO3Rector\CodeQuality\General\ExtEmConfRector; @@ -15,28 +19,21 @@ use Ssch\Typo3RectorTestingFramework\Set\TYPO3TestingFrameworkSetList; return RectorConfig::configure() - ->withConfiguredRule(ExtEmConfRector::class, [ - ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [], - ]) ->withPaths([ __DIR__ . '/Classes/', __DIR__ . '/Configuration/', __DIR__ . '/Tests/', ]) + ->withPhpVersion(PhpVersion::PHP_74) ->withPhpSets( true ) + // Note: We're only enabling a single set by default to improve performance. (Rector needs at least a single set to + // run.) + // + // You can temporarily enable more sets as needed. ->withSets([ - // Typo3LevelSetList::UP_TO_TYPO3_10, - // Typo3LevelSetList::UP_TO_TYPO3_11, - // Typo3LevelSetList::UP_TO_TYPO3_12, - - Typo3SetList::TYPO3_11, - - // Typo3SetList::CODE_QUALITY, - // Typo3SetList::GENERAL, - - // TYPO3TestingFrameworkSetList::TYPO3_TESTING_FRAMEWORK_7, + // Rector sets // LevelSetList::UP_TO_PHP_53, // LevelSetList::UP_TO_PHP_54, @@ -52,14 +49,17 @@ // LevelSetList::UP_TO_PHP_82, // LevelSetList::UP_TO_PHP_83, - // https://github.com/sabbelasichon/typo3-rector/blob/main/src/Set/Typo3LevelSetList.php - // https://github.com/sabbelasichon/typo3-rector/blob/main/src/Set/Typo3SetList.php - // SetList::CODE_QUALITY, // SetList::CODING_STYLE, // SetList::DEAD_CODE, - // SetList::TYPE_DECLARATION, // SetList::EARLY_RETURN, + // SetList::INSTANCEOF, + // SetList::NAMING, + // SetList::PRIVATIZATION, + // SetList::STRICT_BOOLEANS, + // SetList::TYPE_DECLARATION, + + // PHPUnit sets // PHPUnitSetList::PHPUNIT80_DMS, // PHPUnitSetList::PHPUNIT_40, @@ -70,18 +70,39 @@ // PHPUnitSetList::PHPUNIT_90, // PHPUnitSetList::PHPUNIT_100, // PHPUnitSetList::PHPUNIT_CODE_QUALITY, + + // TYPO3 Sets + // https://github.com/sabbelasichon/typo3-rector/blob/main/src/Set/Typo3LevelSetList.php + // https://github.com/sabbelasichon/typo3-rector/blob/main/src/Set/Typo3SetList.php + + Typo3SetList::TYPO3_11, + + // Typo3SetList::CODE_QUALITY, + // Typo3SetList::GENERAL, + + // Typo3LevelSetList::UP_TO_TYPO3_10, + // Typo3LevelSetList::UP_TO_TYPO3_11, + // Typo3LevelSetList::UP_TO_TYPO3_12, + + // TYPO3TestingFrameworkSetList::TYPO3_TESTING_FRAMEWORK_7, ]) // To have a better analysis from PHPStan, we teach it here some more things ->withPHPStanConfigs([ Typo3Option::PHPSTAN_FOR_RECTOR_PATH, ]) - ->withPhpVersion(PhpVersion::PHP_74) ->withRules([ + AddVoidReturnTypeWhereNoReturnRector::class, ConvertImplicitVariablesToExplicitGlobalsRector::class, ]) - // If you use importNames(), you should consider excluding some TYPO3 files. + ->withConfiguredRule(ExtEmConfRector::class, [ + ExtEmConfRector::PHP_VERSION_CONSTRAINT => '7.4.0-8.3.99', + ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '11.5.4-12.4.99', + ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [], + ]) ->withSkip([ - // @see https://github.com/sabbelasichon/typo3-rector/issues/2536 - __DIR__ . '/.github/*', - __DIR__ . '/.Build/*', + // CodeQuality + ExplicitBoolCompareRector::class, + SwitchNegatedTernaryRector::class, + // Strict + DisallowedEmptyRuleFixerRector::class, ]); From 8dffbad64fb492c23482bcb70dca9e99997edc9a Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 7 May 2024 15:41:51 +0200 Subject: [PATCH 6/8] Avoid packaging the Rector configuration file --- .gitattributes | 3 ++- composer.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index f262cbb3..0f05078c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,6 @@ /.Build/ export-ignore /.editorconfig export-ignore /.eslintignore export-ignore -/eslint.config.json export-ignore /.gitattributes export-ignore /.github/ export-ignore /.gitignore export-ignore @@ -13,10 +12,12 @@ /Configuration/FunctionalTests.xml export-ignore /Configuration/UnitTests.xml export-ignore /Tests/ export-ignore +/eslint.config.json export-ignore /package.json export-ignore /phive.xml export-ignore /phpcs.xml export-ignore /phpstan-baseline.neon export-ignore /phpstan.neon export-ignore +/rector.php export-ignore /stylelint.config.js export-ignore /tools/ export-ignore binary diff --git a/composer.json b/composer.json index b50d6304..22b41196 100644 --- a/composer.json +++ b/composer.json @@ -197,6 +197,7 @@ "rm phpcs.xml", "rm phpstan-baseline.neon", "rm phpstan.neon", + "rm rector.php", "rm stylelint.config.js" ] }, From fefcc54a642e26955ac5d730e6a432659caa7f2a Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 7 May 2024 15:52:36 +0200 Subject: [PATCH 7/8] Import class names, but not short classes --- rector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/rector.php b/rector.php index ab8df001..19678540 100644 --- a/rector.php +++ b/rector.php @@ -94,6 +94,7 @@ AddVoidReturnTypeWhereNoReturnRector::class, ConvertImplicitVariablesToExplicitGlobalsRector::class, ]) + ->withImportNames(true, true, false) ->withConfiguredRule(ExtEmConfRector::class, [ ExtEmConfRector::PHP_VERSION_CONSTRAINT => '7.4.0-8.3.99', ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '11.5.4-12.4.99', From 8d174cdd859b7470672e11d13e207c2953beb879 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 7 May 2024 16:21:49 +0200 Subject: [PATCH 8/8] Changes according to the review comments --- rector.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/rector.php b/rector.php index 19678540..ea323713 100644 --- a/rector.php +++ b/rector.php @@ -23,6 +23,8 @@ __DIR__ . '/Classes/', __DIR__ . '/Configuration/', __DIR__ . '/Tests/', + __DIR__ . '/ext_emconf.php', + __DIR__ . '/ext_localconf.php', ]) ->withPhpVersion(PhpVersion::PHP_74) ->withPhpSets( @@ -75,13 +77,10 @@ // https://github.com/sabbelasichon/typo3-rector/blob/main/src/Set/Typo3LevelSetList.php // https://github.com/sabbelasichon/typo3-rector/blob/main/src/Set/Typo3SetList.php - Typo3SetList::TYPO3_11, + Typo3SetList::CODE_QUALITY, + Typo3SetList::GENERAL, - // Typo3SetList::CODE_QUALITY, - // Typo3SetList::GENERAL, - - // Typo3LevelSetList::UP_TO_TYPO3_10, - // Typo3LevelSetList::UP_TO_TYPO3_11, + Typo3LevelSetList::UP_TO_TYPO3_11, // Typo3LevelSetList::UP_TO_TYPO3_12, // TYPO3TestingFrameworkSetList::TYPO3_TESTING_FRAMEWORK_7, @@ -101,9 +100,4 @@ ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [], ]) ->withSkip([ - // CodeQuality - ExplicitBoolCompareRector::class, - SwitchNegatedTernaryRector::class, - // Strict - DisallowedEmptyRuleFixerRector::class, ]);