Repository navigation
Decide the Metadata entity mapping at compile time - #25
Merged
Merged
Conversation
The bundle registers two XML mappings of its Metadata class, an entity and a mapped superclass, each with its own DoctrineOrmMappingsPass enabled by a parameter. SetonoClientExtension sets exactly one: the entity mapping when Metadata is the configured metadata_class, the mapped superclass for any other class. ConvertToEntityListener, its service, its test and its Infection exclusion are gone. A metadata_class that only implements MetadataInterface no longer leaves the unused setono_client__metadata table in the schema. The new interface_only_metadata test environment runs MetadataTest against such a class. Closes #22
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.
Summary
Whether the bundle's
Metadatais an entity is now decided once, when the container compiles. Before, it was decided at runtime by a Doctrine listener.metadata_classMetadatasetono_client__metadatain the schemaMetadata(default)MetadataMetadataInterfaceDoctrineOrmMappingsPasschecks only that its parameter exists, not the parameter's value. Its unit test compiles a container and loads the mapping through Doctrine's driver chain. A newinterface_only_metadatatest environment runs all ofMetadataTestwith an entity that only implements the interface.Closes #22
Evidence
Before: in the new
interface_only_metadataenvironmentInfection ignored one equivalent mutant (
instanceof ClassMetadatain the listener).After:
OK (135 tests, 923 assertions). Infection: 107 mutants, 107 killed, 0 ignored, MSI 100%. PHPStan, ECS and composer-dependency-analyser pass. The CI "lowest" job also passes locally (PHP 8.1, Symfony 6.4.0, DoctrineBundle 2.11.3, ORM 3.1.0, DBAL 3.8.2).Merge Danger
Door: two-way
2.x is unreleased, so reverting this PR restores the listener with no migration.
Blast Radius: schema
An application whose
metadata_classonly implementsMetadataInterfaceno longer getssetono_client__metadatafrom the bundle. Its nextdoctrine:migrations:diffdrops that table. With a custom metadata class configured, the bundle never wrote to it.UPGRADE-2.0.mdcovers this and the removedConvertToEntityListenerand its service.composer-dependency-analyser.phpnow ignoresdoctrine/ormas "prod dependency only in dev":src/no longer imports an ORM class, but the XML mapping and the entity manager still need it at runtime.