[PR #10288] Allow enum discriminator columns #12246

Closed
opened 2026-01-22 16:13:26 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/10288

State: closed
Merged: Yes


In all hydrators, discriminator columns are for all purposes converted to string using explicit (string) conversion. This is not allowed with PHP enums. Therefore, I added code which checks whether the variable is a BackedEnum instance and if so, instead its ->value is used (which can be cast to string without issues as its a scalar)

The test builds upon https://github.com/doctrine/orm/pull/6141 which allowed objects to be discriminator column values. This fix further extends the use-case to allow PHP enums also.

**Original Pull Request:** https://github.com/doctrine/orm/pull/10288 **State:** closed **Merged:** Yes --- In all hydrators, discriminator columns are for all purposes converted to string using explicit (string) conversion. This is not allowed with PHP enums. Therefore, I added code which checks whether the variable is a BackedEnum instance and if so, instead its ->value is used (which can be cast to string without issues as its a scalar) The test builds upon https://github.com/doctrine/orm/pull/6141 which allowed objects to be discriminator column values. This fix further extends the use-case to allow PHP enums also.
admin added the pull-request label 2026-01-22 16:13:26 +01:00
admin closed this issue 2026-01-22 16:13:26 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#12246