-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathissue181.phpt
More file actions
43 lines (40 loc) · 845 Bytes
/
issue181.phpt
File metadata and controls
43 lines (40 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--TEST--
Issue #181 (zend_mm_heap corrupted when serializing/unserializing Enum)
--SKIPIF--
<?php
if (!extension_loaded("msgpack")) {
exit('skip because msgpack extension is missing');
}
if (version_compare(PHP_VERSION, '8.1.0', '<')) {
exit('skip Enum tests in PHP older than 8.1.0');
}
?>
--FILE--
Test
<?php
enum TestEnum: string
{
case EITHER = 'either';
case OTHER = 'other';
}
$original = (object)[
'either' => TestEnum::EITHER,
'other' => TestEnum::OTHER,
];
for ($i = 0; $i < 10; $i++) {
$packed = msgpack_pack($original);
$unpacked = msgpack_unpack($packed);
if ($unpacked->either !== TestEnum::EITHER) {
echo 'either mismatch';
}
if ($original->other !== TestEnum::OTHER) {
echo 'other mismatch';
}
unset($packed);
unset($unpacked);
}
?>
OK
--EXPECT--
Test
OK