1--TEST--
2Test array_walk() function : usage variations - unexpected values in place of 'funcname' argument
3--FILE--
4<?php
5/* Prototype  : bool array_walk(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 'funcname' argument
12*/
13
14echo "*** Testing array_walk() : unexpected values for 'funcname' argument ***\n";
15
16$input = array(1, 2);
17
18//get an unset variable
19$unset_var = 10;
20unset ($unset_var);
21
22$user_data = 20;
23
24// class definition
25class MyClass
26{
27  public function __toString()
28  {
29    return 'object';
30  }
31}
32
33// different scalar/nonscalar values to be used in place of callback function
34$funcname_values = array(
35
36         // int data
37/* 1*/   0,
38         1,
39         12345,
40         -2345,
41
42         // float data
43/* 5*/   10.5,
44         -10.5,
45         10.1234567e8,
46         10.7654321E-8,
47         .5,
48
49         // array data
50/* 10*/  array(),
51         array(0),
52         array(1),
53         array('color' => 'red', 'item' => 'pen'),
54
55         // null data
56/* 14*/  NULL,
57         null,
58
59         // boolean data
60/* 16*/  true,
61         false,
62         TRUE,
63         FALSE,
64
65         // empty data
66/* 20*/  "",
67         '',
68
69         // object data
70         new MyClass(),
71
72         // resource data
73/* 23*/  $fp = fopen(__FILE__, 'r'),
74
75         // undefined data
76         @$undefined_var,
77
78         // unset data
79/* 25*/  @$unset_var,
80);
81
82for($count = 0; $count < count($funcname_values); $count++) {
83  echo "-- Iteration ".($count + 1)." --\n";
84  var_dump( array_walk($input, $funcname_values[$count]) );
85  var_dump( array_walk($input, $funcname_values[$count], $user_data ));
86}
87
88fclose($fp);
89echo "Done"
90?>
91--EXPECTF--
92*** Testing array_walk() : unexpected values for 'funcname' argument ***
93-- Iteration 1 --
94
95Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
96NULL
97
98Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
99NULL
100-- Iteration 2 --
101
102Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
103NULL
104
105Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
106NULL
107-- Iteration 3 --
108
109Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
110NULL
111
112Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
113NULL
114-- Iteration 4 --
115
116Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
117NULL
118
119Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
120NULL
121-- Iteration 5 --
122
123Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
124NULL
125
126Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
127NULL
128-- Iteration 6 --
129
130Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
131NULL
132
133Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
134NULL
135-- Iteration 7 --
136
137Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
138NULL
139
140Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
141NULL
142-- Iteration 8 --
143
144Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
145NULL
146
147Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
148NULL
149-- Iteration 9 --
150
151Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
152NULL
153
154Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
155NULL
156-- Iteration 10 --
157
158Warning: array_walk() expects parameter 2 to be a valid callback, array must have exactly two members in %s on line %d
159NULL
160
161Warning: array_walk() expects parameter 2 to be a valid callback, array must have exactly two members in %s on line %d
162NULL
163-- Iteration 11 --
164
165Warning: array_walk() expects parameter 2 to be a valid callback, array must have exactly two members in %s on line %d
166NULL
167
168Warning: array_walk() expects parameter 2 to be a valid callback, array must have exactly two members in %s on line %d
169NULL
170-- Iteration 12 --
171
172Warning: array_walk() expects parameter 2 to be a valid callback, array must have exactly two members in %s on line %d
173NULL
174
175Warning: array_walk() expects parameter 2 to be a valid callback, array must have exactly two members in %s on line %d
176NULL
177-- Iteration 13 --
178
179Warning: array_walk() expects parameter 2 to be a valid callback, first array member is not a valid class name or object in %s on line %d
180NULL
181
182Warning: array_walk() expects parameter 2 to be a valid callback, first array member is not a valid class name or object in %s on line %d
183NULL
184-- Iteration 14 --
185
186Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
187NULL
188
189Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
190NULL
191-- Iteration 15 --
192
193Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
194NULL
195
196Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
197NULL
198-- Iteration 16 --
199
200Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
201NULL
202
203Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
204NULL
205-- Iteration 17 --
206
207Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
208NULL
209
210Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
211NULL
212-- Iteration 18 --
213
214Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
215NULL
216
217Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
218NULL
219-- Iteration 19 --
220
221Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
222NULL
223
224Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
225NULL
226-- Iteration 20 --
227
228Warning: array_walk() expects parameter 2 to be a valid callback, function '' not found or invalid function name in %s on line %d
229NULL
230
231Warning: array_walk() expects parameter 2 to be a valid callback, function '' not found or invalid function name in %s on line %d
232NULL
233-- Iteration 21 --
234
235Warning: array_walk() expects parameter 2 to be a valid callback, function '' not found or invalid function name in %s on line %d
236NULL
237
238Warning: array_walk() expects parameter 2 to be a valid callback, function '' not found or invalid function name in %s on line %d
239NULL
240-- Iteration 22 --
241
242Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
243NULL
244
245Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
246NULL
247-- Iteration 23 --
248
249Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
250NULL
251
252Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
253NULL
254-- Iteration 24 --
255
256Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
257NULL
258
259Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
260NULL
261-- Iteration 25 --
262
263Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
264NULL
265
266Warning: array_walk() expects parameter 2 to be a valid callback, no array or string given in %s on line %d
267NULL
268Done
269