Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca06211

Browse files
[VarDumper] fix serializing Stub instances
1 parent eb32993 commit ca06211

File tree

1 file changed

+21
-10
lines changed
  • src/Symfony/Component/VarDumper/Cloner

1 file changed

+21
-10
lines changed

src/Symfony/Component/VarDumper/Cloner/Stub.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,33 @@ class Stub
3939
public $position = 0;
4040
public $attr = [];
4141

42+
private static $defaultProperties = [];
43+
4244
/**
4345
* @internal
4446
*/
4547
public function __sleep()
4648
{
47-
$this->serialized = [$this->class, $this->position, $this->cut, $this->type, $this->value, $this->handle, $this->refCount, $this->attr];
49+
$properties = [];
4850

49-
return ['serialized'];
50-
}
51+
if (!isset(self::$defaultProperties[$c = \get_class($this)])) {
52+
self::$defaultProperties[$c] = get_class_vars($c);
5153

52-
/**
53-
* @internal
54-
*/
55-
public function __wakeup()
56-
{
57-
list($this->class, $this->position, $this->cut, $this->type, $this->value, $this->handle, $this->refCount, $this->attr) = $this->serialized;
58-
unset($this->serialized);
54+
$r = new \ReflectionClass($c);
55+
56+
foreach ($r->getProperties() as $v) {
57+
if ($v->isStatic()) {
58+
unset(self::$defaultProperties[$c][$v->name]);
59+
}
60+
}
61+
}
62+
63+
foreach (self::$defaultProperties[$c] as $k => $v) {
64+
if ($this->$k !== $v) {
65+
$properties[] = $k;
66+
}
67+
}
68+
69+
return $properties;
5970
}
6071
}

0 commit comments

Comments
 (0)