isInitialized($object) ? parent::getValue($object) : null; } /** * {@inheritDoc} * * Works around the problem with setting typed no default properties to * NULL which is not supported, instead unset() to uninitialize. * * @link https://github.com/doctrine/orm/issues/7999 * * @param object $object * * @return void */ #[ReturnTypeWillChange] public function setValue($object, $value = null) { if ($value === null && $this->hasType() && ! $this->getType()->allowsNull()) { $propertyName = $this->getName(); $unsetter = function () use ($propertyName): void { unset($this->$propertyName); }; $unsetter = $unsetter->bindTo($object, $this->getDeclaringClass()->getName()); assert($unsetter instanceof Closure); $unsetter(); return; } parent::setValue($object, $value); } }