forked from phadej/igbinary
-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathigbinary_062.phpt
More file actions
56 lines (50 loc) · 1.22 KB
/
Copy pathigbinary_062.phpt
File metadata and controls
56 lines (50 loc) · 1.22 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
--TEST--
igbinary should not call __wakeup() if Serializable::unserialize was used to unserialize the object data (like `unserialize`)
--INI--
; Note that php 8.1 deprecates using Serializable without __serialize/__unserialize but we are testing Serialize for igbinary. Suppress deprecations.
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
class A implements Serializable {
public $prop = 'value';
public function serialize() {
echo "In serialize " . $this->prop . "\n";
return $this->prop;
}
public function unserialize($data) {
echo "In unserialize $data\n";
$this->prop = $data;
}
public function __wakeup() {
echo "In __wakeup, unexpectedly\n";
}
}
function testA() {
$a = new A();
$a->prop = 'other';
$ser = serialize($a);
$b = unserialize($ser);
var_dump($b);
$c = new A();
$c->prop = 'igprop';
$serC = igbinary_serialize($c);
echo bin2hex($serC) . "\n";
$d = igbinary_unserialize($serC);
var_dump($d);
}
testA();
?>
--EXPECTF--
In serialize other
In unserialize other
object(A)#%d (1) {
["prop"]=>
string(5) "other"
}
In serialize igprop
000000021701411d06696770726f70
In unserialize igprop
object(A)#%d (1) {
["prop"]=>
string(6) "igprop"
}