[ObjectMapper] do not require mapping a target's required promoted property when not on source #2
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.
This PR fixes a regression that was introduced by https://github.com/symfony/symfony/pull/61151/files#diff-f159a30ba80133f23e1d36531531f6af7a6ce4ae11aae49480d95e6895d6010cR159-R165 for ObjectMapper that was released on 7.3.2 related to "too eagerly" mapping a constructor's promoted property, without checking whether source actually requires mapping that property. Before 7.3.2 the promoted properties were not checked at all and thus were ignored.
What changed
targethas a required promoted property, which was set already and thus should not be written when not onsource.getSourceReflectionClass, to solely get the reflection class of the source. Made falling back to thetargetReflinstance the responsibility of the callee.Side note
mapmethod do, especially as in situations wheresourcedoes not have any mapping metadata set the target's reflection class gets used. Given the component still is marked experimental; what about extracting several key methods and naming them to what they do?