[Experiment] Use composer.json as priority, fallback to php version features on when parameter exists on ComposerJsonPhpVersionResolver
Ref https://github.com/rectorphp/rector-src/pull/6261#pullrequestreview-2371088505
implemented :tada:, here the summary:
This PR provide a way to set withPhpVersion() even composer.json not exists or doesn't define "php" config, so it fallback php version feature defined, with priority:
- read composer.json, if exists and define
"php"config, then use it - verify if it has
Option::PHP_VERSION_FEATURESviawithPhpVersion(), if exists, then use it as fallback - throw error because nothing to rely
The config can be:
use Rector\Config\RectorConfig;
use Rector\ValueObject\PhpVersionFeature;
return RectorConfig::configure()
->withPaths([__DIR__ . '/src'])
->withPhpVersion(PhpVersionFeature::ATTRIBUTES)
->withPhpLevel(2);
I add e2e test on this PR for proof that it works for apply on level 2, but current php version is php 8, which only apply php 5.2 change:
-ldap_first_attribute($ldap, $entry, $more);
+ldap_first_attribute($ldap, $entry);
By this PR, I found a bug duplicated ContinueToBreakInSwitchRector register which registered in php52 and php73 config https://github.com/rectorphp/rector-src/pull/6384/commits/06026a06605cb1a37f420772e722019f66d4ccf0
I will create separate PR to remove duplicated register ContinueToBreakInSwitchRector
I created separate PR to remove duplicated register ContinueToBreakInSwitchRector that exists in both php52 and php73 config
- https://github.com/rectorphp/rector-src/pull/6385
All checks have passed 🎉 @TomasVotruba it is ready for review.
I don't rebase cherry-pick patch https://github.com/rectorphp/rector-src/pull/6385 so you can see the process and how it found a bug with e2e test :)
Closing for now