Annotation of embedaddon/php/tests/lang/passByReference_005.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Pass uninitialised variables by reference and by value to test implicit initialisation.
3: --FILE--
4: <?php
5:
6: function v($val) {
7: $val = "Val changed";
8: }
9:
10: function r(&$ref) {
11: $ref = "Ref changed";
12: }
13:
14:
15: function vv($val1, $val2) {
16: $val1 = "Val1 changed";
17: $val2 = "Val2 changed";
18: }
19:
20: function vr($val, &$ref) {
21: $val = "Val changed";
22: $ref = "Ref changed";
23: }
24:
25: function rv(&$ref, $val) {
26: $val = "Val changed";
27: $ref = "Ref changed";
28: }
29:
30: function rr(&$ref1, &$ref2) {
31: $ref1 = "Ref1 changed";
32: $ref2 = "Ref2 changed";
33: }
34:
35:
36: class C {
37:
38: function __construct($val, &$ref) {
39: $val = "Val changed";
40: $ref = "Ref changed";
41: }
42:
43: function v($val) {
44: $val = "Val changed";
45: }
46:
47: function r(&$ref) {
48: $ref = "Ref changed";
49: }
50:
51: function vv($val1, $val2) {
52: $val1 = "Val1 changed";
53: $val2 = "Val2 changed";
54: }
55:
56: function vr($val, &$ref) {
57: $val = "Val changed";
58: $ref = "Ref changed";
59: }
60:
61: function rv(&$ref, $val) {
62: $val = "Val changed";
63: $ref = "Ref changed";
64: }
65:
66: function rr(&$ref1, &$ref2) {
67: $ref1 = "Ref1 changed";
68: $ref2 = "Ref2 changed";
69: }
70:
71: }
72:
73: echo "\n ---- Pass by ref / pass by val: functions ----\n";
74: unset($u1, $u2);
75: v($u1);
76: r($u2);
77: var_dump($u1, $u2);
78:
79: unset($u1, $u2);
80: vv($u1, $u2);
81: var_dump($u1, $u2);
82:
83: unset($u1, $u2);
84: vr($u1, $u2);
85: var_dump($u1, $u2);
86:
87: unset($u1, $u2);
88: rv($u1, $u2);
89: var_dump($u1, $u2);
90:
91: unset($u1, $u2);
92: rr($u1, $u2);
93: var_dump($u1, $u2);
94:
95:
96: echo "\n\n ---- Pass by ref / pass by val: static method calls ----\n";
97: unset($u1, $u2);
98: C::v($u1);
99: C::r($u2);
100: var_dump($u1, $u2);
101:
102: unset($u1, $u2);
103: C::vv($u1, $u2);
104: var_dump($u1, $u2);
105:
106: unset($u1, $u2);
107: C::vr($u1, $u2);
108: var_dump($u1, $u2);
109:
110: unset($u1, $u2);
111: C::rv($u1, $u2);
112: var_dump($u1, $u2);
113:
114: unset($u1, $u2);
115: C::rr($u1, $u2);
116: var_dump($u1, $u2);
117:
118: echo "\n\n ---- Pass by ref / pass by val: instance method calls ----\n";
119: unset($u1, $u2);
120: $c = new C($u1, $u2);
121: var_dump($u1, $u2);
122:
123: unset($u1, $u2);
124: $c->v($u1);
125: $c->r($u2);
126: var_dump($u1, $u2);
127:
128: unset($u1, $u2);
129: $c->vv($u1, $u2);
130: var_dump($u1, $u2);
131:
132: unset($u1, $u2);
133: $c->vr($u1, $u2);
134: var_dump($u1, $u2);
135:
136: unset($u1, $u2);
137: $c->rv($u1, $u2);
138: var_dump($u1, $u2);
139:
140: unset($u1, $u2);
141: $c->rr($u1, $u2);
142: var_dump($u1, $u2);
143:
144: ?>
145: --EXPECTF--
146:
147: ---- Pass by ref / pass by val: functions ----
148:
149: Notice: Undefined variable: u1 in %s on line 72
150:
151: Notice: Undefined variable: u1 in %s on line 74
152: NULL
153: string(11) "Ref changed"
154:
155: Notice: Undefined variable: u1 in %s on line 77
156:
157: Notice: Undefined variable: u2 in %s on line 77
158:
159: Notice: Undefined variable: u1 in %s on line 78
160:
161: Notice: Undefined variable: u2 in %s on line 78
162: NULL
163: NULL
164:
165: Notice: Undefined variable: u1 in %s on line 81
166:
167: Notice: Undefined variable: u1 in %s on line 82
168: NULL
169: string(11) "Ref changed"
170:
171: Notice: Undefined variable: u2 in %s on line 85
172:
173: Notice: Undefined variable: u2 in %s on line 86
174: string(11) "Ref changed"
175: NULL
176: string(12) "Ref1 changed"
177: string(12) "Ref2 changed"
178:
179:
180: ---- Pass by ref / pass by val: static method calls ----
181:
182: Notice: Undefined variable: u1 in %s on line 95
183:
184: Strict Standards: Non-static method C::v() should not be called statically in %s on line 95
185:
186: Strict Standards: Non-static method C::r() should not be called statically in %s on line 96
187:
188: Notice: Undefined variable: u1 in %s on line 97
189: NULL
190: string(11) "Ref changed"
191:
192: Notice: Undefined variable: u1 in %s on line 100
193:
194: Notice: Undefined variable: u2 in %s on line 100
195:
196: Strict Standards: Non-static method C::vv() should not be called statically in %s on line 100
197:
198: Notice: Undefined variable: u1 in %s on line 101
199:
200: Notice: Undefined variable: u2 in %s on line 101
201: NULL
202: NULL
203:
204: Notice: Undefined variable: u1 in %s on line 104
205:
206: Strict Standards: Non-static method C::vr() should not be called statically in %s on line 104
207:
208: Notice: Undefined variable: u1 in %s on line 105
209: NULL
210: string(11) "Ref changed"
211:
212: Notice: Undefined variable: u2 in %s on line 108
213:
214: Strict Standards: Non-static method C::rv() should not be called statically in %s on line 108
215:
216: Notice: Undefined variable: u2 in %s on line 109
217: string(11) "Ref changed"
218: NULL
219:
220: Strict Standards: Non-static method C::rr() should not be called statically in %s on line 112
221: string(12) "Ref1 changed"
222: string(12) "Ref2 changed"
223:
224:
225: ---- Pass by ref / pass by val: instance method calls ----
226:
227: Notice: Undefined variable: u1 in %s on line 117
228:
229: Notice: Undefined variable: u1 in %s on line 118
230: NULL
231: string(11) "Ref changed"
232:
233: Notice: Undefined variable: u1 in %s on line 121
234:
235: Notice: Undefined variable: u1 in %s on line 123
236: NULL
237: string(11) "Ref changed"
238:
239: Notice: Undefined variable: u1 in %s on line 126
240:
241: Notice: Undefined variable: u2 in %s on line 126
242:
243: Notice: Undefined variable: u1 in %s on line 127
244:
245: Notice: Undefined variable: u2 in %s on line 127
246: NULL
247: NULL
248:
249: Notice: Undefined variable: u1 in %s on line 130
250:
251: Notice: Undefined variable: u1 in %s on line 131
252: NULL
253: string(11) "Ref changed"
254:
255: Notice: Undefined variable: u2 in %s on line 134
256:
257: Notice: Undefined variable: u2 in %s on line 135
258: string(11) "Ref changed"
259: NULL
260: string(12) "Ref1 changed"
261: string(12) "Ref2 changed"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>