Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TYPO3 Upgrades with Rector

TYPO3 Upgrades with Rector

In this hands-on tutorial I want to show the whole process of setting up rector, creating the config file, adapting it to needs and finding cases that are not covered by it and how to change that.

Avatar for Simon Schaufelberger

Simon Schaufelberger

August 11, 2025
Tweet

Other Decks in Programming

Transcript

  1. The Pain ⇨ Manual refactoring is slow and expensive ⇨

    Reading Changelogs and understanding the migration path ⇨ Boring and Repetitive ⇨ Prone to Human Error ⇨ Small budget 5
  2. What TYPO3 Rector can do ⇨ TCA Changes ⇨ Class/Method

    refactorings ⇨ Backendmodul registration / PageTS config / UserTS config ⇾ Create new (non PHP) files ⇨ Detect the extension name for some rules 7
  3. What Rector can NOT do ⇨ Migrate Hooks to Events

    ⇨ Huge refactorings ⇨ Migrations that require adjustments in different files (e.g. PHP and SQL) ⇨ Migrate other file types than PHP 8
  4. 195 Rules 6 Rules for TYPO3 14 45 Rules for

    TYPO3 13 9 Our achievements:
  5. Rector can do even more! ⇨ The Rector core project

    has plenty of rules ⇾ PHP’s own migrations (PHP 7.4 to PHP 8) ⇾ PhpUnit Migrations (@test to #[TEST]) ⇾ Doctrine Migrations ⇨ Improve Code Quality & Code style ⇨ Remove dead code ⇨ And lots more… 👉 Import the RuleSets from Rector! 12
  6. Other Rector projects TYPO3 Rector is not the only one:

    ⇨ frosh/shopware-rector ⇨ sylius/sylius-rector ⇨ driftingly/rector-laravel ⇨ palantirnet/drupal-rector ⇨ neos/rector ⇨ … 13
  7. What Fractor can do Migrate: ⇨ TypoScript ⇨ composer.json files

    ⇨ Form definitions (yaml) ⇨ FlexForms (xml) ⇨ .htaccess files ⇨ Fluid templates And format the code according to your style! 15
  8. Run single rules Rector can execute single rules via CLI

    param: rector --only=”Namespaced\RuleName” You need to clear the cache afterwards with: rector --clear-cache --dry-run 19
  9. “There is a script for that... 20 "git commit" each

    applied Rule as a single commit with: github.com/mogic-le/rector-single-commit You need to create the commit message files 👉 Adjust the script and fix the code style after each commit
  10. PhpStorm Integration since 2022.2 21 Only works with the “old”

    config format! https://blog.jetbrains.com/phpstorm/2022/08/phpstorm-2022-2-is-now-available/
  11. Configurable rules TYPO3 Rector has some configurable rules: ⇨ ExtEmConfRector

    ⇨ GeneralUtilityMakeInstanceToConstructorPro pertyRector ⇨ All Rules in the Docs with: “🔧 configure it!” How do I configure them? 👉 Look in the Docs or Tests! 22
  12. Configurable rules 23 Adjust your Rector config file: // old

    format: $rectorConfig ->ruleWithConfiguration(ExtEmConfRector::class, [ ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.2.0-8.3.99', ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '13.4.0-13.4.99', ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [ 'createDirs', 'Uploadfolder' ], ]);
  13. Configurable rules 24 Adjust your Rector config file: // new

    format: return RectorConfig::configure() ->withConfiguredRule(MigrateRenderTypeInputLinkToTypeLinkRector::class, [ MigrateRenderTypeInputLinkToTypeLinkRector::ALLOWED_TYPES => ['page', 'file', 'folder', 'record', 'telephone'], ]);
  14. Configurable rules 25 Use existing rules from Rector and configure

    them: // new format: return RectorConfig::configure() ->withConfiguredRule(RenameMethodRector::class, [ new MethodCallRename('Doctrine\\DBAL\\Connection', 'getSchemaManager', 'createSchemaManager'), ]); ⇨ You don’t have to create new rules for each case.
  15. Exclude rules & files 26 // new format: return RectorConfig::configure()

    ->withSkip([ __DIR__ . ‘/path/to/file/to/skip.ext’, // by file path / directory RuleToSkip::class, // by rule AnotherRuleToSkip::class, [ // by combination __DIR__ . ‘/path/to/file/to/skip.ext’, ], ]); ⇨ Works the same in Fractor
  16. Code Style Rector can mess up your code style. Use

    a code style fixer! Our recommendation: “Easy Coding Standard” (ecs) ⇨ Based on PHP-CS-Fixer ⇨ Additional rules (for arrays) https://github.com/easy-coding-standard/easy-coding-standard 27
  17. Rector & Fractor test project We have a test project

    for you! github.com/helsner/typo3-rector-demo 29
  18. Thanks! 30 Any questions? You can find us at: ⇨

    my.typo3.org/u/helsner ⇨ my.typo3.org/u/simonschaufi