forked from krakjoe/pthreads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvolatile-arrays.phpt
87 lines (79 loc) · 1.72 KB
/
volatile-arrays.phpt
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
--TEST--
Test Volatile Arrays
--DESCRIPTION--
Arrays were difficult to use in pthreads, their behaviour was strange and inconsistent with Zend arrays.
pthreads v3 will coerce arrays to Volatile objects when they are set as members of Threaded objects.
Threaded objects have been made consistent with PHP arrays, so there should be no noticable difference between an array
and a volatile object.
--FILE--
<?php
$threaded = new Threaded();
$threaded->test = [
"greeting" => "Hello World",
"child" => [
"of" => "mine",
"grandchild" => [
"of" => "parents"
]
]
];
/*
This looks strange, but needs to be consistent with zend, so we'll test here ...
*/
$threaded["0"] = [];
$threaded[1] = [];
var_dump($threaded);
/*
This kind of thing would simply fail before, creating really unexpected results
*/
$threaded->test["child"]["of"] = "yours";
$threaded->test["child"]["grandchild"]["of"] = "devil";
var_dump($threaded);
?>
--EXPECTF--
object(Threaded)#%d (%d) {
["test"]=>
object(Volatile)#%d (%d) {
["greeting"]=>
string(11) "Hello World"
["child"]=>
object(Volatile)#%d (%d) {
["of"]=>
string(4) "mine"
["grandchild"]=>
object(Volatile)#%d (%d) {
["of"]=>
string(7) "parents"
}
}
}
[0]=>
object(Volatile)#%d (%d) {
}
[1]=>
object(Volatile)#%d (%d) {
}
}
object(Threaded)#%d (%d) {
["test"]=>
object(Volatile)#%d (%d) {
["greeting"]=>
string(11) "Hello World"
["child"]=>
object(Volatile)#%d (%d) {
["of"]=>
string(5) "yours"
["grandchild"]=>
object(Volatile)#%d (%d) {
["of"]=>
string(5) "devil"
}
}
}
[0]=>
object(Volatile)#%d (%d) {
}
[1]=>
object(Volatile)#%d (%d) {
}
}