parentProperty = $parentProperty; $this->childProperty = $childProperty; $this->embeddedClass = (string) $embeddedClass; parent::__construct($childProperty->getDeclaringClass()->getName(), $childProperty->getName()); } /** * {@inheritDoc} * * @return mixed */ #[ReturnTypeWillChange] public function getValue($object = null) { $embeddedObject = $this->parentProperty->getValue($object); if ($embeddedObject === null) { return null; } return $this->childProperty->getValue($embeddedObject); } /** * {@inheritDoc} * * @return void */ #[ReturnTypeWillChange] public function setValue($object, $value = null) { $embeddedObject = $this->parentProperty->getValue($object); if ($embeddedObject === null) { $this->instantiator = $this->instantiator ?: new Instantiator(); $embeddedObject = $this->instantiator->instantiate($this->embeddedClass); $this->parentProperty->setValue($object, $embeddedObject); } $this->childProperty->setValue($embeddedObject, $value); } }