function LazyProxyTrait::__serialize
File
-
vendor/
symfony/ var-exporter/ LazyProxyTrait.php, line 293
Class
Namespace
Symfony\Component\VarExporterCode
public function __serialize() : array {
$class = self::class;
$state = $this->lazyObjectState ?? null;
if (!$state && (Registry::$parentMethods[$class] ??= Registry::getParentMethods($class))['serialize']) {
$properties = parent::__serialize();
}
else {
$properties = (array) $this;
if ($state) {
unset($properties["\x00{$class}\x00lazyObjectState"]);
$properties["\x00{$class}\x00lazyObjectReal"] = $state->realInstance ??= ($state->initializer)();
}
}
if ($state || Registry::$parentMethods[$class]['serialize'] || !Registry::$parentMethods[$class]['sleep']) {
return $properties;
}
$scope = get_parent_class($class);
$data = [];
foreach (parent::__sleep() as $name) {
$value = $properties[$k = $name] ?? $properties[$k = "\x00*\x00{$name}"] ?? $properties[$k = "\x00{$class}\x00{$name}"] ?? $properties[$k = "\x00{$scope}\x00{$name}"] ?? ($k = null);
if (null === $k) {
trigger_error(\sprintf('serialize(): "%s" returned as member variable from __sleep() but does not exist', $name), \E_USER_NOTICE);
}
else {
$data[$k] = $value;
}
}
return $data;
}