Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LazyProxyTrait.php

function LazyProxyTrait::__serialize

File

vendor/symfony/var-exporter/LazyProxyTrait.php, line 293

Class

LazyProxyTrait

Namespace

Symfony\Component\VarExporter

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal