1--TEST--
2Evaluation order during assignments.
3--FILE--
4<?php
5
6function f() {
7	echo "in f()\n";
8	return "name";
9}
10
11function g() {
12	echo "in g()\n";
13	return "assigned value";
14}
15
16
17echo "\n\nOrder with local assignment:\n";
18${f()} = g();
19var_dump($name);
20
21echo "\n\nOrder with array assignment:\n";
22$a[f()] = g();
23var_dump($a);
24
25echo "\n\nOrder with object property assignment:\n";
26$oa = new stdClass;
27$oa->${f()} = g();
28var_dump($oa);
29
30echo "\n\nOrder with nested object property assignment:\n";
31$ob = new stdClass;
32$ob->o1 = new stdClass;
33$ob->o1->o2 = new stdClass;
34$ob->o1->o2->${f()} = g();
35var_dump($ob);
36
37echo "\n\nOrder with dim_list property assignment:\n";
38$oc = new stdClass;
39$oc->a[${f()}] = g();
40var_dump($oc);
41
42
43class C {
44	public static $name = "original";
45	public static $a = array();
46	public static $string = "hello";
47}
48echo "\n\nOrder with static property assignment:\n";
49C::${f()} = g();
50var_dump(C::$name);
51
52echo "\n\nOrder with static array property assignment:\n";
53C::$a[f()] = g();
54var_dump(C::$a);
55
56echo "\n\nOrder with indexed string assignment:\n";
57$string = "hello";
58function getOffset() {
59	echo "in getOffset()\n";
60	return 0;
61}
62function newChar() {
63	echo "in newChar()\n";
64	return 'j';
65}
66$string[getOffset()] = newChar();
67var_dump($string);
68
69echo "\n\nOrder with static string property assignment:\n";
70C::$string[getOffset()] = newChar();
71var_dump(C::$string);
72
73?>
74--EXPECTF--
75Order with local assignment:
76in f()
77in g()
78string(14) "assigned value"
79
80
81Order with array assignment:
82in f()
83in g()
84array(1) {
85  ["name"]=>
86  string(14) "assigned value"
87}
88
89
90Order with object property assignment:
91in f()
92in g()
93object(stdClass)#%d (1) {
94  ["assigned value"]=>
95  string(14) "assigned value"
96}
97
98
99Order with nested object property assignment:
100in f()
101in g()
102object(stdClass)#%d (1) {
103  ["o1"]=>
104  object(stdClass)#%d (1) {
105    ["o2"]=>
106    object(stdClass)#%d (1) {
107      ["assigned value"]=>
108      string(14) "assigned value"
109    }
110  }
111}
112
113
114Order with dim_list property assignment:
115in f()
116in g()
117object(stdClass)#%d (1) {
118  ["a"]=>
119  array(1) {
120    ["assigned value"]=>
121    string(14) "assigned value"
122  }
123}
124
125
126Order with static property assignment:
127in f()
128in g()
129string(14) "assigned value"
130
131
132Order with static array property assignment:
133in f()
134in g()
135array(1) {
136  ["name"]=>
137  string(14) "assigned value"
138}
139
140
141Order with indexed string assignment:
142in getOffset()
143in newChar()
144string(5) "jello"
145
146
147Order with static string property assignment:
148in getOffset()
149in newChar()
150string(5) "jello"
151