How do I set the current version of PHP in use at upgrade time? #7863
-
Hi! The current project code is running on PHP 7.1 and I plan to upgrade to PHP 8.1 I installed rector in PHP 7.1 CLI, composer installed
<?php
declare(strict_types=1);
use Rector\Core\Configuration\Option;
use Rector\Set\ValueObject\LevelSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
]);
$parameters->set(Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_81);
// Define what rule sets will be applied
$containerConfigurator->import(LevelSetList::UP_TO_PHP_81, null, true);
}; However, the process is too long due to the very large amount of code. And it uses too much memory, about 20G or so. Then I noticed that rector So I'm going to upgrade my code to PHP 7.2 first, then install the new rector, and then upgrade to PHP 7.4 or PHP 8.1. However, there is a problem if I upgrade to PHP 7.2 and then use the I find that these rule sets are recursive, i.e. it automatically contains PHP 7.4 rules, which in turn contain 7.3. Even more. I noticed that the upgrade_to_xx rule set 7.3 includes 7.2 So if the current code is already at PHP 7.1, then if I set upgrade_to_73, will the rector apply the rules below 7.1, such as PHP71, PHP70, PHP56...? Now I have some questions:
This way rector may no longer automatically apply the rules of PHP 7.1 and below
Thank you ☺ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can apply specific set list, one by one for that, see https://getrector.com/documentation/set-lists |
Beta Was this translation helpful? Give feedback.
You can apply specific set list, one by one for that, see https://getrector.com/documentation/set-lists