Skip to content

Commit a676c62

Browse files
authored
Merge pull request #105 from skaut/2-serialize
implmenet __serialize and __unserialize
2 parents 60cf2c6 + 4273576 commit a676c62

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/SkautisQuery.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,15 @@ public function __construct($fname, array $args = [], array $trace = [])
7070
$this->time = -microtime(true);
7171
}
7272

73+
/**
74+
* @deprecated use __serialize
75+
*/
7376
public function serialize()
77+
{
78+
return serialize($this->__serialize());
79+
}
80+
81+
public function __serialize(): array
7482
{
7583
$data = [
7684
'fname' => $this->fname,
@@ -81,12 +89,19 @@ public function serialize()
8189
'exception_class' => is_null($this->exception) ? "" : get_class($this->exception),
8290
'exception_string' => is_null($this->exception) ? "" : (string)$this->exception,
8391
];
84-
return serialize($data);
92+
return $data;
8593
}
8694

95+
/**
96+
* @deprecated use __unserialize
97+
*/
8798
public function unserialize($data)
8899
{
89-
$data = unserialize($data);
100+
$this->__unserialize(unserialize($data));
101+
}
102+
103+
public function __unserialize(array $data): void
104+
{
90105
$this->fname = $data['fname'];
91106
$this->args = $data['args'];
92107
$this->trace = $data['trace'];

0 commit comments

Comments
 (0)