[dx] Deprecate SetList::PHP_* constants in favor of withPhpSets()/withPhpLevel(), introduce ruleWithConfigurationPhpVersionBound() - #8405
Merged
Conversation
TomasVotruba
force-pushed
the
deprecate-php-set-constants
branch
from
August 29, 2026 17:49
2aacc52 to
e936ba0
Compare
…evel() The per-version PHP set constants are superseded by withPhpSets() and withPhpLevel(), which resolve the target PHP version automatically. Mark them @deprecated to steer users toward the version-driven API. Internal resolution (PhpLevelSetResolver, config/set/level, their tests) still fetches the constants until the single version-driven set replaces them, so those paths are excluded from the deprecation check. Claude-Session: https://claude.ai/code/session_014Q25TQ4b7b13UQQXScu3Fg
… PhpLevelSetResolver withPhpSets() and withPhpLevel() now load one config/set/php-version-based.php set that lists every PHP version rule. The runtime PhpVersionedFilter already gates each rule by MinPhpVersionInterface, so cumulative per-version file selection is redundant - PhpLevelSetResolver is removed. An explicitly picked withPhpSets(phpXX: true) version still caps the set: the ceiling now applies to all rules in PhpVersionedFilter (previously only to polyfilled ones, the rest were capped by file selection), preserving behavior. Claude-Session: https://claude.ai/code/session_014Q25TQ4b7b13UQQXScu3Fg
…rationPhpVersionBound() The single set now enumerates every PHP version rule in one rules() call with per-version comment separators, mirroring rector-symfony composer-based.php. Configured rules that span multiple versions (RenameFunctionRector, RemoveFuncCallArgRector, RenameCastRector) are registered via the new RectorConfig::ruleWithConfigurationPhpVersionBound(), which applies a configuration only when the target PHP version is high enough - mirroring ruleWithConfigurationComposerVersionBound() for package versions. An explicitly picked withPhpSets(phpXX) version is the target, otherwise the project composer.json PHP version is used. Claude-Session: https://claude.ai/code/session_014Q25TQ4b7b13UQQXScu3Fg
TomasVotruba
force-pushed
the
deprecate-php-set-constants
branch
from
August 29, 2026 20:09
6a792b5 to
97661ab
Compare
TomasVotruba
marked this pull request as ready for review
August 29, 2026 20:25
TomasVotruba
force-pushed
the
deprecate-php-set-constants
branch
from
August 29, 2026 20:29
1f4b1c8 to
130af89
Compare
addPhpLevelSets() takes the picked PHP version again (nullable): an explicit withPhpSets(phpXX) version acts as a ceiling, null keeps composer.json gating and polyfill package support. Also fix SetList::PHP_VERSION_BASED_SET path depth - it sits three levels deep in src/Set/ValueObject, so it needs ../../../ to reach config/set. Claude-Session: https://claude.ai/code/session_014Q25TQ4b7b13UQQXScu3Fg
Restore the original non-nullable int signature. The picked-version ceiling is set in the explicit-pick branch only, so the no-arg case keeps composer.json gating and polyfill package support. Claude-Session: https://claude.ai/code/session_014Q25TQ4b7b13UQQXScu3Fg
…lSets() version arg withSets() emits an E_USER_DEPRECATED notice when a SetList::PHP_* set file is passed, pointing to withPhpSets()/withPhpLevel(). Detected by file path, so the deprecated constants are not referenced internally. addPhpLevelSets() keeps the non-nullable picked version and stores it; an explicit withPhpSets(phpXX) version acts as a ceiling via isPhpSetsVersionPicked, while the composer.json fallback does not, preserving polyfill package support. Storing the version also keeps the argument used, so it is not stripped as dead. Claude-Session: https://claude.ai/code/session_014Q25TQ4b7b13UQQXScu3Fg
TomasVotruba
force-pushed
the
deprecate-php-set-constants
branch
from
August 29, 2026 20:58
8c4cd3b to
33fa2f9
Compare
Replace the trigger_error() deprecation with a SymfonyStyle ->warning() via a new Notifier::notifyDeprecatedPhpSet(), matching the other withSets/withPhpSets notifications. Drop the console-output unit test, in line with the untested Notifier notifications. Claude-Session: https://claude.ai/code/session_014Q25TQ4b7b13UQQXScu3Fg
Member
Author
|
/cc @calebdw I came up with this one today :) the PHP rules are resolve by php-version, not by sets anymore. |
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.
The per-version PHP set constants
SetList::PHP_52…SetList::PHP_86are superseded bywithPhpSets()andwithPhpLevel(), which resolve the target PHP version automatically. The runtimePhpVersionedFilteralready gates every rule by itsMinPhpVersionInterface, so the cumulative per-version set selection is redundant.Changes
SetList::PHP_*constants marked@deprecated, pointing towithPhpSets()/withPhpLevel(). The constants and theirconfig/set/php*.phpfiles stay in place, so this is backward compatible.config/set/php-version-based.phplists every PHP version rule directly - onerules()call with// PHP x.xcomment separators, modeled on rector-symfonycomposer-based.php.withPhpSets()andwithPhpLevel()now load this single set; each rule self-gates by PHP version at runtime.RectorConfig::ruleWithConfigurationPhpVersionBound($rectorClass, $configuration, $phpVersion), the PHP-version analog ofruleWithConfigurationComposerVersionBound(). Configured rules that span versions (RenameFunctionRector,RemoveFuncCallArgRector,RenameCastRector) register each version's configuration only when the target PHP version is high enough. An explicitly pickedwithPhpSets(phpXX: true)version is the target, otherwise the projectcomposer.jsonPHP version.PhpLevelSetResolverremoved - the runtime filter does the version gating.PhpVersionedFilter: an explicitly pickedwithPhpSets(phpXX: true)version now caps all rules at that ceiling (previously only polyfilled rules; the rest were capped by file selection), preserving behavior.Note
withPhpLevel()uses rule position as its level knob. Collapsing to one set dedups rules that were listed in multiple version files (149 -> 141) and groups configured rules at the end, so a given level number can map to a slightly different rule than before. The runtime filter still prevents any rule above the project PHP version from applying.