Closed
Description
Symfony version(s) affected: 4.2.3
Description
Assuming I have classes like this:
class Inner {
public $freshInstance = true;
public $name;
}
class Outer {
/** @var Inner */
public $inner;
}
and instance like
$inner = new Inner;
$inner->freshInstance = false;
$outer = new Outer;
$outer->inner = $inner;
When deserializing:
{
"inner": {"name": "Inner Name"}
}
I'd expect the pre-existing Inner
instance to be used, but a new one is created.
How to reproduce
https://github.com/dkarlovi/reproducer-symfony-31208
Possible Solution
Pre-populate OBJECT_TO_POPULATE
with the pre-existing object if not-null?