Skip to content

Commit

Permalink
[VarDumper] fix serializing Stub instances
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Feb 16, 2019
1 parent eb32993 commit ca06211
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/Symfony/Component/VarDumper/Cloner/Stub.php
Expand Up @@ -39,22 +39,33 @@ class Stub
public $position = 0;
public $attr = [];

private static $defaultProperties = [];

/**
* @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::$defaultProperties[$c = \get_class($this)])) {
self::$defaultProperties[$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);
$r = new \ReflectionClass($c);

foreach ($r->getProperties() as $v) {
if ($v->isStatic()) {
unset(self::$defaultProperties[$c][$v->name]);
}
}
}

foreach (self::$defaultProperties[$c] as $k => $v) {
if ($this->$k !== $v) {
$properties[] = $k;
}
}

return $properties;
}
}

0 comments on commit ca06211

Please sign in to comment.