[composer-based] Bond data-fixtures rule and annotation-to-attribute sets to composer package constraints - #497
Merged
Conversation
…sets to composer package constraints
TomasVotruba
force-pushed
the
composer-based-fixtures-attributes
branch
from
August 3, 2026 15:56
381035c to
d28f66a
Compare
…, drop the dev dependency
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.
Follow-up to #495. Two gaps remained after the composer-based bonding.
1.
AddGetReferenceTypeRectorhad no composer constraintThe rule fills the second
getReference()argument, which only exists from doctrine/data-fixtures 1.6 (data-fixtures#409). The set provider already knew the version — it registersdata-fixtures-16.phpas aComposerTriggeredSetat1.6— but the rule itself carried noComposerPackageConstraintInterface, and unlike itsdata-fixtures-17sibling it was never added tocomposer-based.php.What the rule does, now only on data-fixtures >= 1.6:
final class SomeFixture extends AbstractFixture { public function run(SomeEntity $someEntity) { - $someEntity->setSomePassedEntity($this->getReference('some-id')); + $someEntity->setSomePassedEntity($this->getReference('some-id', SomePassedEntity::class)); } }doctrine/data-fixturesis added torequire-devso the rule test actually exercises the constraint instead of silently skipping.2. Annotation-to-attribute sets are now composer-bound too
ANNOTATIONS_TO_ATTRIBUTES,GEDMO_ANNOTATIONS_TO_ATTRIBUTESandMONGODB_ANNOTATIONS_TO_ATTRIBUTESconvert annotations to attribute classes that only exist from a specific package version. Each config block moves intocomposer-based.phpbound to the version that first shipped those classes as PHP 8 attributes:doctrine/orm>=2.9#[Attribute]onMapping\Entityabsent in 2.8.0, present in 2.9.0doctrine/mongodb-odm>=2.3doctrine/mongodb-odm-bundle>=4.4Validator\Constraints\Uniqueabsent in 4.3.0, present in 4.4.0gedmo/doctrine-extensions>=3.5Mapping\Annotation\Slugabsent in v3.4.0, present in v3.5.0The
Uniqueconstraint previously travelled inside the MongoDB set but belongs to a different package, so it gets its own bound.Result on an ORM >= 2.9 project using
withComposerBased():The standalone set files stay in place, same as the version sets in #495 — the
DoctrineSetListconstants remain usable.Heads-up on scope
This makes annotation-to-attribute conversion part of
withComposerBased()rather than an explicit opt-in set. Any project on ORM >= 2.9 and PHP 8 (AnnotationToAttributeRectoris still gated on PHP 8.0 by its own min-version) will now get its mapping annotations rewritten to attributes. That is a deliberate migration rather than a version-compat fix, so it is worth a conscious call before merging.Trigger packages
COMPOSER_BASED_TRIGGER_PACKAGESgainsdoctrine/mongodb-odm-bundleandgedmo/doctrine-extensions, lowersdoctrine/mongodb-odmto>=2.3anddoctrine/data-fixturesto>=1.6, so the set is picked up for projects on those versions.New
tests/ComposerBasedfixture covers the ORM annotation-to-attribute path end to end through the composer-based set.