How to upgrade php version keeping backward compatibility ? #7520
|
I am currently using PHP 7.0 and would like to update to PHP 7.1. $rectorConfig->phpVersion(PhpVersion::PHP_70);
$rectorConfig->import(LevelSetList::UP_TO_PHP_71);When I run rector, it makes changes which are not backward compatible with php 7.0, for example it adds public visibility prefixes to the constants. Is there any way to tell Rector to update the code to php 7.1 but keep it compatible with php 7.0? |
Replies: 2 comments 10 replies
|
Hi, the 2nd line changes PHP version to PHP 7.1: $rectorConfig->phpVersion(PhpVersion::PHP_70);
$rectorConfig->import(LevelSetList::UP_TO_PHP_71);Change the order: $rectorConfig->import(LevelSetList::UP_TO_PHP_71);
$rectorConfig->phpVersion(PhpVersion::PHP_70); |
|
Hi Sorry to reopen this discussion. With last rector version, this answers doesn't look anymore accurate. What is the (new) correct way ? I've tried : ->withSets([LevelSetList::UP_TO_PHP_82])
->withPhpVersion(PhpVersion::PHP_74)or ->withPhpVersion(PhpVersion::PHP_74)
->withSets([LevelSetList::UP_TO_PHP_82])without success. I've tried also with If i add Looks working with ->withDowngradeSets(false, false, false, false, false,true)
->withPhpVersion(PhpVersion::PHP_74)But in this case it's a full downgrade until php7.4 , If I've understood correctly downgrade approach don't target interval compatibility. I'm wrong ? |
Hi,
the 2nd line changes PHP version to PHP 7.1:
Change the order: