Skip to content

feat: map arrays into properties typed with a union of classes - #371

Merged
joelwurtz merged 2 commits into
mainfrom
feat/union-array-denormalization
Dec 3, 2026
Merged

joelwurtz merged 2 commits into
mainfrom
feat/union-array-denormalization

Conversation

@joelwurtz

@joelwurtz joelwurtz commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Mapping an array into a property typed with a union of classes (Foo|Bar, array<Foo|Bar>) always builds the same class, failing when the data is meant for another one. With the new unionTriesEachClass configuration option (union_tries_each_class in the bundle), each class is tried in turn, in the same order as the Symfony 8.2 Serializer, and the first class whose constructor arguments are present in the array is built. When none matches, the error of the first class is thrown.

The option defaults to false (current behavior). Not setting it is deprecated, it will default to true in 11.0.

Depends on #359.

Base automatically changed from build/symfony-8.2 to main December 3, 2026 15:26
@joelwurtz
joelwurtz deleted the branch build/symfony-8.2 December 3, 2026 15:26
@joelwurtz joelwurtz closed this Dec 3, 2026
@joelwurtz joelwurtz reopened this Dec 3, 2026
@joelwurtz
joelwurtz force-pushed the feat/union-array-denormalization branch from b2902a3 to 41356ad Compare December 3, 2026 15:39
@joelwurtz
joelwurtz merged commit b3b23dd into main Dec 3, 2026
6 checks passed
@joelwurtz
joelwurtz deleted the feat/union-array-denormalization branch December 3, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant