From c2572593d9fa02239fcbe02f5efa31085098ccde Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:43:11 +0000 Subject: [PATCH 1/2] [TASK] Update ssch/typo3-rector to v2 | datasource | package | from | to | | ---------- | ----------------- | ----- | ----- | | packagist | ssch/typo3-rector | 1.8.0 | 2.0.0 | --- templates/src/composer.json.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/src/composer.json.twig b/templates/src/composer.json.twig index fd999b2..1fd9b98 100644 --- a/templates/src/composer.json.twig +++ b/templates/src/composer.json.twig @@ -62,7 +62,7 @@ "saschaegerer/phpstan-typo3": "^1.8", {% endif %} {% if features.rector %} - "ssch/typo3-rector": "^1.0", + "ssch/typo3-rector": "^2.0", {% endif %} "typo3/coding-standards": "^0.7.1", "typo3/testing-framework": "{{ packages.typo3_testing_framework }}" From 25bdf16f012a52c272b852d315e79e2f54843673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Wed, 14 Feb 2024 17:07:35 +0100 Subject: [PATCH 2/2] [TASK] Migrate Rector config template --- templates/src/rector.php.twig | 90 +++++++++++------------------------ 1 file changed, 29 insertions(+), 61 deletions(-) diff --git a/templates/src/rector.php.twig b/templates/src/rector.php.twig index 9c2af3b..b25942f 100644 --- a/templates/src/rector.php.twig +++ b/templates/src/rector.php.twig @@ -3,55 +3,37 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Core\ValueObject\PhpVersion; -use Rector\Set\ValueObject\LevelSetList; +use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector; +use Rector\PostRector\Rector\NameImportingPostRector; +use Rector\ValueObject\PhpVersion; +use Ssch\TYPO3Rector\CodeQuality\General\ConvertImplicitVariablesToExplicitGlobalsRector; +use Ssch\TYPO3Rector\CodeQuality\General\ExtEmConfRector; use Ssch\TYPO3Rector\Configuration\Typo3Option; -use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v10\v0\ExtbasePersistenceTypoScriptRector; -use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v9\v0\FileIncludeToImportStatementTypoScriptRector; -use Ssch\TYPO3Rector\Rector\General\ConvertImplicitVariablesToExplicitGlobalsRector; -use Ssch\TYPO3Rector\Rector\General\ExtEmConfRector; use Ssch\TYPO3Rector\Set\Typo3LevelSetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->sets([ - Typo3LevelSetList::UP_TO_TYPO3_{{ packages.typo3_cms|split('.')|first }}, - LevelSetList::UP_TO_PHP_{{ packages.php|replace({'.': ''}) }}, - ]); - - // In order to have a better analysis from phpstan we teach it here some more things - $rectorConfig->phpstanConfig(Typo3Option::PHPSTAN_FOR_RECTOR_PATH); - - // Disable parallel otherwise non php file processing is not working i.e. typoscript - $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_{{ packages.php|replace({'.': ''}) }}); - - // 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([ +return RectorConfig::configure() + ->withConfiguredRule(ExtEmConfRector::class, [ + ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [], + ]) + ->withPaths([ __DIR__ . '/packages/*', - ]); - - // If you use importNames(), you should consider excluding some TYPO3 files. - $rectorConfig->skip([ + ]) + ->withPhpSets(php{{ packages.php|replace({'.': ''}) }}: true) + ->withSets([ + Typo3LevelSetList::UP_TO_TYPO3_{{ packages.typo3_cms|split('.')|first }}, + ]) + ->withPHPStanConfigs([ + Typo3Option::PHPSTAN_FOR_RECTOR_PATH, + ]) + ->withPhpVersion(PhpVersion::PHP_{{ packages.php|replace({'.': ''}) }}) + ->withImportNames(importShortClasses: false) + ->withRules([ + ConvertImplicitVariablesToExplicitGlobalsRector::class, + ]) + ->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', @@ -61,21 +43,7 @@ return static function (RectorConfig $rectorConfig): void { ], // We skip this rector rule as it interferes with TYPO3 coding standards - \Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class, - ]); - - // 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(ExtbasePersistenceTypoScriptRector::class, [ - ExtbasePersistenceTypoScriptRector::FILENAME => __DIR__ . '/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(FileIncludeToImportStatementTypoScriptRector::class); -}; + AddLiteralSeparatorToNumberRector::class, + ]) + ->withoutParallel() +;