mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Non-nullable typed property for Embeddable should be ignored when hydrating #6397
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 @sneakyvv on GitHub (Feb 6, 2020).
Bug Report
Summary
Required typed properties of nullable embeddables can not be hydrated in PHP 7.4.
Current behavior
Take this example:
and the Embeddable
So, the
$barproperty onFoocan be null, but when it is provided it should have a$startDate. However, since it's part of the Embeddable, it could benullin the database for the tablefoo.But, when it's hydrated it should not set that null value, otherwise you get this error:
How to reproduce
See example above, create an instance of Foo, save it and load/hydrate it again.
Expected behavior
IMO, a null value, for non-nullable typed properties should be ignored in Embeddables.
PS: Kinda related to #4568, because when all properties of the Embeddable are null, the parent property should also be null (which I fix now post-hydrating), but that occurs even later obviously, after all properties of the Embeddable are set.
@beberlei commented on GitHub (Feb 12, 2020):
@sneakyvv which version of doctrine/persistence and doctrine/reflection are you on? The latest ones contain fixes for typed propreties, I hoped they work on embeddables as well.
@sneakyvv commented on GitHub (Feb 12, 2020):
@beberlei, I saw the ticket handling that, and upgrade my packages, but the mentioned bug still happened.
My current versions are:
doctrine/persistence: 1.3.6
doctrine/reflection: 1.1.0
@sneakyvv commented on GitHub (Feb 12, 2020):
@beberlei I've made the test work (or be skipped) for older PHP versions.
Travis is now passing, since I've conditionally included a file containing the php7.4-style classes.
Is there a better, more elegant way to include such conditional code in the test file itself? The purpose is to avoid syntax errors for older versions.