Automatically upgrade your PHP code from 5.3 to PHP 7.4 with Rector

Written by / Original link on Dec. 2, 2019


Rector is a reconstructor tool – it does instant upgrades and instant refactoring of your code. Why refactor manually if Rector can handle 80% for you?

Installation per Composer:

composer require rector/rector --dev

For example, to upgrade the contents of the ./src folder:

vendor/bin/rector process src --set php74

The cool thing is that Rector uses sets, of which it has many. Upgrading from SwiftMailer 5 to 6 or from Twig 1 to Twig 2.4.0 for example? There are sets available for those.

Configuration through a rector.yaml is also possible.

Rector →
rectorphp/rector on GitHub →

elsewhere link calevans bram

« Building a Website Screenshot API with Puppeteer and Google Cloud Functions - Master VSCode File Editing Multi Cursor Workflows »