From 00a37644b264539fa957acb2e4d7ff17d3a1a99b Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 7 Jan 2021 08:46:46 +0100 Subject: [PATCH] Add rector to auto migrate to TYPO3 v10 --- composer.json | 3 +++ rector.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 rector.php diff --git a/composer.json b/composer.json index 555803a..ef21bb7 100644 --- a/composer.json +++ b/composer.json @@ -27,5 +27,8 @@ "typo3/cms": { "extension-key": "events" } + }, + "require-dev": { + "ssch/typo3-rector": "^0.8.0" } } diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..c29079c --- /dev/null +++ b/rector.php @@ -0,0 +1,60 @@ +parameters(); + + // Define what rule sets will be applied + $parameters->set(Option::SETS, [ + Typo3SetList::TYPO3_104, + ]); + + // FQN classes are not imported by default. If you don't do it manually after every Rector run, enable it by: + $parameters->set(Typo3Option::AUTO_IMPORT_NAMES, true); + + // this will not import root namespace classes, like \DateTime or \Exception + $parameters->set(Option::IMPORT_SHORT_CLASSES, false); + + // this will not import classes used in PHP DocBlocks, like in /** @var \Some\Class */ + $parameters->set(Option::IMPORT_DOC_BLOCKS, false); + + // Define your target version which you want to support + $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_73); + + // If you would like to see the changelog url when a rector is applied + $parameters->set(Typo3Option::OUTPUT_CHANGELOG, true); + + // If you set option Typo3Option::AUTO_IMPORT_NAMES to true, you should consider excluding some TYPO3 files. + $parameters->set(Option::SKIP, [ + NameImportingPostRector::class => [ + 'ClassAliasMap.php', + 'class.ext_update.php', + 'ext_localconf.php', + 'ext_emconf.php', + 'ext_tables.php', + __DIR__ . '/**/TCA/*', + ], + ]); + + // If you have trouble that rector cannot run because some TYPO3 constants are not defined add an additional constants file + // Have a look at https://github.com/sabbelasichon/typo3-rector/blob/master/typo3.constants.php + // $parameters->set(Option::AUTOLOAD_PATHS, [ + // __DIR__ . '/typo3.constants.php' + // ]); + + // get services (needed for register a single rule) + // $services = $containerConfigurator->services(); + + // register a single rule + // $services->set(InjectAnnotationRector::class); +};