File: igbinary_025.phpt

package info (click to toggle)
php-igbinary 3.2.16-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,024 kB
  • sloc: ansic: 3,373; xml: 1,106; pascal: 10; makefile: 2; php: 2; sh: 1
file content (120 lines) | stat: -rw-r--r-- 2,053 bytes parent folder | download | duplicates (5)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
--TEST--
Object test, array of objects with __sleep
--SKIPIF--
--FILE--
<?php
if(!extension_loaded('igbinary')) {
	dl('igbinary.' . PHP_SHLIB_SUFFIX);
}

function test($type, $variable, $test) {
	$serialized = igbinary_serialize($variable);
	$unserialized = igbinary_unserialize($serialized);

	var_dump($variable);
	var_dump($unserialized);
}

class Obj {
	public $a;
	protected $b;
	private $c;
	var $d;

	function __construct($a, $b, $c, $d) {
		$this->a = $a;
		$this->b = $b;
		$this->c = $c;
		$this->d = $d;
	}

	function __sleep() {
		return array('a', 'b', 'c');
	}

#	function __wakeup() {
#		$this->d = $this->a + $this->b + $this->c;
#	}
}

$array = array(
	new Obj("aa", "bb", "cc", "dd"),
	new Obj("ee", "ff", "gg", "hh"),
	new Obj(1, 2, 3, 4),
);


test('array', $array, true);

?>
--EXPECTREGEX--
array\(3\) {
  \[0\]=>
  object\(Obj\)#1 \(4\) {
    \["a"\]=>
    string\(2\) "aa"
    \[("b":protected|"b:protected")\]=>
    string\(2\) "bb"
    \["?c"?:("Obj":)?private"?\]=>
    string\(2\) "cc"
    \["d"\]=>
    string\(2\) "dd"
  }
  \[1\]=>
  object\(Obj\)#2 \(4\) {
    \["a"\]=>
    string\(2\) "ee"
    \["?b"?:protected"?\]=>
    string\(2\) "ff"
    \["?c"?:("Obj":)?private"?\]=>
    string\(2\) "gg"
    \["d"\]=>
    string\(2\) "hh"
  }
  \[2\]=>
  object\(Obj\)#3 \(4\) {
    \["a"\]=>
    int\(1\)
    \["?b"?:protected"?\]=>
    int\(2\)
    \["?c"?:("Obj":)?private"?\]=>
    int\(3\)
    \["d"\]=>
    int\(4\)
  }
}
array\(3\) {
  \[0\]=>
  object\(Obj\)#4 \(4\) {
    \["a"\]=>
    string\(2\) "aa"
    \["?b"?:protected"?\]=>
    string\(2\) "bb"
    \["?c"?:("Obj":)?private"?\]=>
    string\(2\) "cc"
    \["d"\]=>
    NULL
  }
  \[1\]=>
  object\(Obj\)#5 \(4\) {
    \["a"\]=>
    string\(2\) "ee"
    \["?b"?:protected"?\]=>
    string\(2\) "ff"
    \["?c"?:("Obj":)?private"?\]=>
    string\(2\) "gg"
    \["d"\]=>
    NULL
  }
  \[2\]=>
  object\(Obj\)#6 \(4\) {
    \["a"\]=>
    int\(1\)
    \["?b"?:protected"?\]=>
    int\(2\)
    \["?c"?:("Obj":)?private"?\]=>
    int\(3\)
    \["d"\]=>
    NULL
  }
}