[VersionBonding] Cap polyfill rules by explicitly picked withPhpSets() version - #8315
Merged
Conversation
…) version When a PHP version is explicitly picked, e.g. withPhpSets(php82: true), the SetList::PHP_POLYFILLS set is still loaded. A rule bound to a higher polyfill package, e.g. AddOverrideAttributeToOverriddenMethodsRector with symfony/polyfill-php83, was then active regardless of the picked version. The explicitly picked version is an intended ceiling, so polyfilled rules above it are now skipped.
TomasVotruba
force-pushed
the
polyfill-ceiling-php-sets
branch
from
August 7, 2026 23:00
91eef62 to
77ef434
Compare
TomasVotruba
force-pushed
the
polyfill-ceiling-php-sets
branch
from
August 8, 2026 04:30
926986e to
ae8373d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a PHP version is picked explicitly, the
SetList::PHP_POLYFILLSset is still loaded on top of the picked level sets.PhpVersionedFilterthen activated anyRelatedPolyfillInterfacerule whose polyfill package sits in rootcomposer.json, ignoring the picked version entirely.So this config:
with
symfony/polyfill-php83required, still ranAddOverrideAttributeToOverriddenMethodsRector(andJsonValidateRector), producing PHP 8.3 code from a PHP 8.2 target:final class SomeClass extends ParentClass { + #[\Override] public function run() { } }An explicitly picked version is an intended ceiling, so polyfilled rules above it are now skipped.
Unchanged behaviour when no version is picked —
withPhpSets()resolving fromcomposer.jsonkeeps the full ahead-of-version polyfill activation, which is the point of the set:Implementation
withPhpSets()stores the explicitly picked version,RectorConfigBuilder::__invoke()passes it asOption::POLYFILL_CEILING_PHP_VERSION.PhpVersionedFilterskips the polyfill-package bypass when a ceiling is set, and gatesRelatedPolyfillInterfacerules on the ceiling instead of the project PHP version. The latter matters whencomposer.jsonallows a higher PHP than the picked set, e.g."php": "^8.4"withwithPhpSets(php82: true).