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

Breadcrumb

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

function LazyGhostTrait::__serialize

File

vendor/symfony/var-exporter/LazyGhostTrait.php, line 311

Class

LazyGhostTrait

Namespace

Symfony\Component\VarExporter

Code

public function __serialize() : array {
    $class = self::class;
    if ((Registry::$parentMethods[$class] ??= Registry::getParentMethods($class))['serialize']) {
        $properties = parent::__serialize();
    }
    else {
        $this->initializeLazyObject();
        $properties = (array) $this;
    }
    unset($properties["\x00{$class}\x00lazyObjectState"]);
    if (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