[composer-based] Bond version-specific rules and configuration to composer package constraints - #495
Merged
Merged
Conversation
…poser package constraints Add config/sets/composer-based.php, a single set holding the rules and configuration bound to the exact Doctrine package version their target API was added in, mirroring the rector-phpunit and rector-symfony composer-based sets. Rules declare their constraint via ComposerPackageConstraintInterface, the configuration of the version sets is registered through ruleWithConfigurationComposerVersionBound(). Both apply to any project with that package version installed, no matter which version the upgrade started from. Doctrine has no single package to trigger on, so every package used inside the set registers it as a ComposerTriggeredSet. Existing sets and composer.json stay untouched.
TomasVotruba
force-pushed
the
composer-based-version-bound-rules
branch
from
August 1, 2026 19:22
f5c95a6 to
51be8f4
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.
Same shape as rector-phpunit #754 and rector-symfony #979 / #980, applied to Doctrine.
What
A single new set,
config/sets/composer-based.php, holding everything bound to the exact Doctrine package version its target API was added in.13 rules declare their own constraint:
And the 20 configurations of the version sets are registered version bound:
Effect
A project on
doctrine/dbal4.4 gets both renames in one run, without picking thedoctrine-dbal-40set and no matter which DBAL version the upgrade started from:public function run(Connection $connection, Index $index) { - $schemaManager = $connection->getSchemaManager(); - $isFulfilled = $index->isFullfilledBy([]); + $schemaManager = $connection->createSchemaManager(); + $isFulfilled = $index->isFulfilledBy([]); }And the same rules are skipped on a project still on DBAL 3, where those methods do not exist yet.
Notes
composer.jsontoo - only therector/rector-srclock entry moved, as the older one never assignedInstalledPackageResolver::$projectDirectoryand every constrained rule died on "installed package json not found".doctrine-orm-28.php,doctrine-orm-219.phpanddoctrine-bundle-210.phphave no composer trigger of their own, their version comes from the file name.doctrine/data-fixtures,doctrine/commonanddoctrine/mongodb-odmare not bonded: those packages are not dev dependencies, so the constraint would filter the rule out and its test would silently stop transforming. Their configuration is included, as it needs no test package. Follow-up once the dev deps allow it.doctrine-collection-22.phpondoctrine/collection, but the package isdoctrine/collections, so that set never matches. The rule inside is bonded todoctrine/collectionshere.rectorCI job also reports a docblock change inCaseStringHelper- that one is already on main, untouched by this PR.