mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
[3.4.0, PHP <8.4] Cannot hydrate readonly properties from superclass of embeddable #7518
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @udavka on GitHub (Jun 15, 2025).
Bug Report
Summary
For embeddables that have superclasses, the hydrator cannot set readonly properties that are inherited from a superclass (for PHP <8.4).
Current behavior
Inherited readonly properties cannot be set and an exception is thrown:
Error: Cannot initialize readonly property <super-class>::$<prop-name> from scope <derived-class>. The entity hydration is terminated.The problem is introduced in 3.4.0 with new property accessors. The previous reflection property-based code still works, but it is not used in the hydration code anymore.
Expected behavior
The hydration is successful.
How to reproduce
Just use an embeddable with a superclass that has a readonly ORM column.
@greg0ire commented on GitHub (Jun 16, 2025):
Can you please provide a stack trace?
@udavka commented on GitHub (Jun 16, 2025):
Error: Cannot initialize readonly property
<super-class>::$<prop-name>from scope<derived-class>@beberlei commented on GitHub (Jun 22, 2025):
@udavka did this work in 3.3?
@udavka commented on GitHub (Jun 22, 2025):
Yes, that's why I wrote: The problem is introduced in 3.4.0 with new property accessors. The previous reflection property-based code still works, but it is not used in the hydration code anymore.
@beberlei commented on GitHub (Jun 22, 2025):
Oh, overread that. Thanks
@udavka commented on GitHub (Jun 22, 2025):
I have finally found how to fix it.
This line:
src/Mapping/ClassMetadata.php:857 must be not
but
I'm sorry, I have no idea how to create a proper pull request. Anyway, I hope that this can help.
@greg0ire commented on GitHub (Jun 22, 2025):
@udavka we have a guide, in case you want to give it a try.