diff --git a/src/Symfony/Component/VarDumper/Cloner/Stub.php b/src/Symfony/Component/VarDumper/Cloner/Stub.php index 08fba759301c6..ac69aa97e13b5 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Stub.php +++ b/src/Symfony/Component/VarDumper/Cloner/Stub.php @@ -39,22 +39,25 @@ class Stub public $position = 0; public $attr = []; + private static $defaults = []; + /** * @internal */ public function __sleep() { - $this->serialized = [$this->class, $this->position, $this->cut, $this->type, $this->value, $this->handle, $this->refCount, $this->attr]; + $properties = []; - return ['serialized']; - } + if (!isset(self::$defaults[$c = \get_class($this)])) { + self::$defaults[$c] = get_class_vars($c); + } - /** - * @internal - */ - public function __wakeup() - { - list($this->class, $this->position, $this->cut, $this->type, $this->value, $this->handle, $this->refCount, $this->attr) = $this->serialized; - unset($this->serialized); + foreach (self::$defaults[$c] as $k => $v) { + if ($this->$k !== $v) { + $properties[] = $k; + } + } + + return $properties; } }