8000 [VarDumper] fix serializing Stub instances by nicolas-grekas · Pull Request #30274 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[VarDumper] fix serializing Stub instances #30274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions src/Symfony/Component/VarDumper/Cloner/Stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,29 @@ 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);
foreach ((new \ReflectionClass($c))->getStaticProperties() as $k => $v) {
unset(self::$defaultProperties[$c][$k]);
}
}

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

return $properties;
}
}
0