Skip to content

Commit 519190c

Browse files
authored
Merge pull request #33 from bestit/add-php8.-support
Add support for php 8.1
2 parents a6d6b93 + 64068f3 commit 519190c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/Model/Context.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,14 @@ public function unserialize($serialized)
101101
{
102102
$this->storage = unserialize($serialized);
103103
}
104+
105+
public function __serialize()
106+
{
107+
return [$this->serialize()];
108+
}
109+
110+
public function __unserialize(array $data)
111+
{
112+
$this->unserialize($data[0]);
113+
}
104114
}

tests/Model/ContextTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,8 @@ public function testSerializable()
151151
$context->add('test_2', 'bazzfoo');
152152
$context->add('test_3', ['key' => 'value']);
153153

154-
$data = serialize($context);
155-
156-
$hash = sha1($data);
157-
static::assertEquals('7d06bb0e2174031f1c16bf4f304978ad3d9664ed', $hash);
158-
159154
/** @var Context $context2 */
160-
$context2 = unserialize($data);
161-
static::assertEquals('foobar', $context2->get('test_1'));
155+
$context2 = unserialize(serialize($context)); static::assertEquals('foobar', $context2->get('test_1'));
162156
static::assertEquals('bazzfoo', $context2->get('test_2'));
163157
static::assertEquals(['key' => 'value'], $context2->get('test_3'));
164158
}

0 commit comments

Comments
 (0)