Skip to content

Commit f991e7e

Browse files
committed
Merge pull request #647
2 parents 013c9c4 + b80ff1e commit f991e7e

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

tests/bson/bug1006-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
PHPC-1005: Do not modify memory of Persistable::bsonSerialize() return value
2+
PHPC-1006: Do not modify memory of Persistable::bsonSerialize() return value
33
--FILE--
44
<?php
55

tests/bson/bug1006-002.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
PHPC-1006: Do not skip __pclass in Serializable::bsonSerialize() return value
3+
--FILE--
4+
<?php
5+
6+
require_once __DIR__ . '/../utils/tools.php';
7+
8+
class MyClass implements MongoDB\BSON\Serializable
9+
{
10+
function bsonSerialize()
11+
{
12+
return [
13+
'__pclass' => 'baz',
14+
'foo' => 'bar',
15+
];
16+
}
17+
}
18+
19+
hex_dump(fromPHP(new MyClass));
20+
21+
?>
22+
===DONE===
23+
<?php exit(0); ?>
24+
--EXPECT--
25+
0 : 24 00 00 00 02 5f 5f 70 63 6c 61 73 73 00 04 00 [$....__pclass...]
26+
10 : 00 00 62 61 7a 00 02 66 6f 6f 00 04 00 00 00 62 [..baz..foo.....b]
27+
20 : 61 72 00 00 [ar..]
28+
===DONE===

0 commit comments

Comments
 (0)