Annotation of embedaddon/php/ext/standard/tests/array/array_walk_recursive_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_walk_recursive() function : usage variations - unexpected values for 'input' argument
3: --FILE--
4: <?php
5: /* Prototype : bool array_walk_recursive(array $input, string $funcname [, mixed $userdata])
6: * Description: Apply a user function to every member of an array
7: * Source code: ext/standard/array.c
8: */
9:
10: /*
11: * Passing different scalar/nonscalar values in place of 'input' argument
12: */
13:
14: echo "*** Testing array_walk_recursive() : unexpected values for 'input' argument ***\n";
15:
16: // callback function
17: /* Prototype : callback(mixed $value, mixed $key)
18: * Parameters : $value - values given in input array
19: * $key - keys given in input array
20: * Description : Function prints each element of an array with key
21: */
22: function callback($value, $key)
23: {
24: echo "key : ";
25: var_dump($key);
26: echo "value : ";
27: var_dump($value);
28: }
29:
30: // extra parameter passed to array_walk_recursive()
31: $user_data = 10;
32:
33: // get an unset variable
34: $unset_var = 10;
35: unset ($unset_var);
36:
37: // get resource variable
38: $fp = fopen(__FILE__, 'r');
39:
40: // different scalar/nonscalar values to be used in place of an 'input' argument
41: $input_values = array(
42:
43: // int data
44: /* 1*/ 0,
45: 1,
46: 12345,
47: -2345,
48:
49: // float data
50: /* 5*/ 10.5,
51: -10.5,
52: 10.1234567e8,
53: 10.7654321E-8,
54: .5,
55:
56: // null data
57: /* 10*/ NULL,
58: null,
59:
60: // boolean data
61: /* 12*/ true,
62: false,
63: TRUE,
64: FALSE,
65:
66: // empty data
67: /* 16*/ "",
68: '',
69:
70: // string data
71: /* 18*/ "string",
72: 'string',
73:
74: // resource data
75: $fp,
76:
77: // undefined data
78: @$undefined_var,
79:
80: // unset data
81: /* 22*/ @$unset_var,
82: );
83:
84:
85: for($count = 0; $count < count($input_values); $count++) {
86: echo "-- Iteration ".($count + 1)." --\n";
87: var_dump( array_walk_recursive($input_values[$count], "callback") );
88: var_dump( array_walk_recursive($input_values[$count], "callback", $user_data) );
89: }
90:
91: fclose($fp);
92: echo "Done"
93: ?>
94: --EXPECTF--
95: *** Testing array_walk_recursive() : unexpected values for 'input' argument ***
96: -- Iteration 1 --
97:
98: Warning: array_walk_recursive() expects parameter 1 to be array, integer given in %s on line %d
99: NULL
100:
101: Warning: array_walk_recursive() expects parameter 1 to be array, integer given in %s on line %d
102: NULL
103: -- Iteration 2 --
104:
105: Warning: array_walk_recursive() expects parameter 1 to be array, integer given in %s on line %d
106: NULL
107:
108: Warning: array_walk_recursive() expects parameter 1 to be array, integer given in %s on line %d
109: NULL
110: -- Iteration 3 --
111:
112: Warning: array_walk_recursive() expects parameter 1 to be array, integer given in %s on line %d
113: NULL
114:
115: Warning: array_walk_recursive() expects parameter 1 to be array, integer given in %s on line %d
116: NULL
117: -- Iteration 4 --
118:
119: Warning: array_walk_recursive() expects parameter 1 to be array, integer given in %s on line %d
120: NULL
121:
122: Warning: array_walk_recursive() expects parameter 1 to be array, integer given in %s on line %d
123: NULL
124: -- Iteration 5 --
125:
126: Warning: array_walk_recursive() expects parameter 1 to be array, double given in %s on line %d
127: NULL
128:
129: Warning: array_walk_recursive() expects parameter 1 to be array, double given in %s on line %d
130: NULL
131: -- Iteration 6 --
132:
133: Warning: array_walk_recursive() expects parameter 1 to be array, double given in %s on line %d
134: NULL
135:
136: Warning: array_walk_recursive() expects parameter 1 to be array, double given in %s on line %d
137: NULL
138: -- Iteration 7 --
139:
140: Warning: array_walk_recursive() expects parameter 1 to be array, double given in %s on line %d
141: NULL
142:
143: Warning: array_walk_recursive() expects parameter 1 to be array, double given in %s on line %d
144: NULL
145: -- Iteration 8 --
146:
147: Warning: array_walk_recursive() expects parameter 1 to be array, double given in %s on line %d
148: NULL
149:
150: Warning: array_walk_recursive() expects parameter 1 to be array, double given in %s on line %d
151: NULL
152: -- Iteration 9 --
153:
154: Warning: array_walk_recursive() expects parameter 1 to be array, double given in %s on line %d
155: NULL
156:
157: Warning: array_walk_recursive() expects parameter 1 to be array, double given in %s on line %d
158: NULL
159: -- Iteration 10 --
160:
161: Warning: array_walk_recursive() expects parameter 1 to be array, null given in %s on line %d
162: NULL
163:
164: Warning: array_walk_recursive() expects parameter 1 to be array, null given in %s on line %d
165: NULL
166: -- Iteration 11 --
167:
168: Warning: array_walk_recursive() expects parameter 1 to be array, null given in %s on line %d
169: NULL
170:
171: Warning: array_walk_recursive() expects parameter 1 to be array, null given in %s on line %d
172: NULL
173: -- Iteration 12 --
174:
175: Warning: array_walk_recursive() expects parameter 1 to be array, boolean given in %s on line %d
176: NULL
177:
178: Warning: array_walk_recursive() expects parameter 1 to be array, boolean given in %s on line %d
179: NULL
180: -- Iteration 13 --
181:
182: Warning: array_walk_recursive() expects parameter 1 to be array, boolean given in %s on line %d
183: NULL
184:
185: Warning: array_walk_recursive() expects parameter 1 to be array, boolean given in %s on line %d
186: NULL
187: -- Iteration 14 --
188:
189: Warning: array_walk_recursive() expects parameter 1 to be array, boolean given in %s on line %d
190: NULL
191:
192: Warning: array_walk_recursive() expects parameter 1 to be array, boolean given in %s on line %d
193: NULL
194: -- Iteration 15 --
195:
196: Warning: array_walk_recursive() expects parameter 1 to be array, boolean given in %s on line %d
197: NULL
198:
199: Warning: array_walk_recursive() expects parameter 1 to be array, boolean given in %s on line %d
200: NULL
201: -- Iteration 16 --
202:
203: Warning: array_walk_recursive() expects parameter 1 to be array, string given in %s on line %d
204: NULL
205:
206: Warning: array_walk_recursive() expects parameter 1 to be array, string given in %s on line %d
207: NULL
208: -- Iteration 17 --
209:
210: Warning: array_walk_recursive() expects parameter 1 to be array, string given in %s on line %d
211: NULL
212:
213: Warning: array_walk_recursive() expects parameter 1 to be array, string given in %s on line %d
214: NULL
215: -- Iteration 18 --
216:
217: Warning: array_walk_recursive() expects parameter 1 to be array, string given in %s on line %d
218: NULL
219:
220: Warning: array_walk_recursive() expects parameter 1 to be array, string given in %s on line %d
221: NULL
222: -- Iteration 19 --
223:
224: Warning: array_walk_recursive() expects parameter 1 to be array, string given in %s on line %d
225: NULL
226:
227: Warning: array_walk_recursive() expects parameter 1 to be array, string given in %s on line %d
228: NULL
229: -- Iteration 20 --
230:
231: Warning: array_walk_recursive() expects parameter 1 to be array, resource given in %s on line %d
232: NULL
233:
234: Warning: array_walk_recursive() expects parameter 1 to be array, resource given in %s on line %d
235: NULL
236: -- Iteration 21 --
237:
238: Warning: array_walk_recursive() expects parameter 1 to be array, null given in %s on line %d
239: NULL
240:
241: Warning: array_walk_recursive() expects parameter 1 to be array, null given in %s on line %d
242: NULL
243: -- Iteration 22 --
244:
245: Warning: array_walk_recursive() expects parameter 1 to be array, null given in %s on line %d
246: NULL
247:
248: Warning: array_walk_recursive() expects parameter 1 to be array, null given in %s on line %d
249: NULL
250: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>