From e97e1e6cfffa8f0192f5671679d340feb960abd3 Mon Sep 17 00:00:00 2001 From: Denis Sokolov Date: Sun, 19 Sep 2021 12:00:00 +0000 Subject: [PATCH] Implement __serialize in Exception/Frame --- src/Whoops/Exception/Frame.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Whoops/Exception/Frame.php b/src/Whoops/Exception/Frame.php index 8403209..2d7297b 100644 --- a/src/Whoops/Exception/Frame.php +++ b/src/Whoops/Exception/Frame.php @@ -241,6 +241,15 @@ class Frame implements Serializable return serialize($frame); } + public function __serialize() + { + $frame = $this->frame; + if (!empty($this->comments)) { + $frame['_comments'] = $this->comments; + } + return $frame; + } + /** * Unserializes the frame data, while also preserving * any existing comment data. @@ -260,6 +269,16 @@ class Frame implements Serializable $this->frame = $frame; } + public function __unserialize($frame) + { + if (!empty($frame['_comments'])) { + $this->comments = $frame['_comments']; + unset($frame['_comments']); + } + + $this->frame = $frame; + } + /** * Compares Frame against one another * @param Frame $frame