1--TEST--
2Test array_reverse() function : usage variations - unexpected values for 'array' argument
3--FILE--
4<?php
5/* Prototype  : array array_reverse(array $array [, bool $preserve_keys])
6 * Description: Return input as a new array with the order of the entries reversed
7 * Source code: ext/standard/array.c
8*/
9
10echo "*** Testing array_reverse() : usage variations - unexpected values for 'array' argument ***\n";
11
12//get an unset variable
13$unset_var = 10;
14unset ($unset_var);
15
16//get a resource variable
17$fp = fopen(__FILE__, "r");
18
19//get a class
20class classA
21{
22  public function __toString(){
23    return "Class A object";
24  }
25}
26
27//get a heredoc string
28$heredoc_string = <<<EOT
29Hello world\t\n
30EOT;
31
32//array of values to iterate over
33$arrays = array (
34
35       // int data
36/*1*/  0,
37       1,
38       12345,
39       -2345,
40
41       // float data
42/*5*/  10.5,
43       -10.5,
44       10.5e10,
45       10.6E-10,
46       .5,
47
48       // null data
49/*10*/ NULL,
50       null,
51
52       // boolean data
53       true,
54       false,
55       TRUE,
56       FALSE,
57
58       // empty data
59/*16*/ "",
60       '',
61
62       // string data
63       'Hello world',
64       "Hello world",
65       $heredoc_string,
66
67       // object data
68/*21*/ new classA(),
69
70       // undefined data
71       @$undefined_var,
72
73       // unset data
74       @$unset_var,
75
76       // resource variable
77/*24*/ $fp
78
79);
80
81// loop through each element of the array $arrays to check the behavior of array_reverse()
82$iterator = 1;
83foreach($arrays as $array) {
84  echo "\n-- Iteration $iterator --";
85  // with default argument
86  var_dump( array_reverse($array) );
87  // with all possible arguments
88  var_dump( array_reverse($array, true) );
89  var_dump( array_reverse($array, false) );
90  $iterator++;
91};
92
93// close the file resource used
94fclose($fp);
95
96echo "Done";
97?>
98--EXPECTF--
99*** Testing array_reverse() : usage variations - unexpected values for 'array' argument ***
100
101-- Iteration 1 --
102Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
103NULL
104
105Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
106NULL
107
108Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
109NULL
110
111-- Iteration 2 --
112Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
113NULL
114
115Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
116NULL
117
118Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
119NULL
120
121-- Iteration 3 --
122Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
123NULL
124
125Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
126NULL
127
128Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
129NULL
130
131-- Iteration 4 --
132Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
133NULL
134
135Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
136NULL
137
138Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d
139NULL
140
141-- Iteration 5 --
142Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
143NULL
144
145Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
146NULL
147
148Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
149NULL
150
151-- Iteration 6 --
152Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
153NULL
154
155Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
156NULL
157
158Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
159NULL
160
161-- Iteration 7 --
162Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
163NULL
164
165Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
166NULL
167
168Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
169NULL
170
171-- Iteration 8 --
172Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
173NULL
174
175Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
176NULL
177
178Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
179NULL
180
181-- Iteration 9 --
182Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
183NULL
184
185Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
186NULL
187
188Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d
189NULL
190
191-- Iteration 10 --
192Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
193NULL
194
195Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
196NULL
197
198Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
199NULL
200
201-- Iteration 11 --
202Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
203NULL
204
205Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
206NULL
207
208Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
209NULL
210
211-- Iteration 12 --
212Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
213NULL
214
215Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
216NULL
217
218Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
219NULL
220
221-- Iteration 13 --
222Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
223NULL
224
225Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
226NULL
227
228Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
229NULL
230
231-- Iteration 14 --
232Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
233NULL
234
235Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
236NULL
237
238Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
239NULL
240
241-- Iteration 15 --
242Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
243NULL
244
245Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
246NULL
247
248Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d
249NULL
250
251-- Iteration 16 --
252Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
253NULL
254
255Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
256NULL
257
258Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
259NULL
260
261-- Iteration 17 --
262Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
263NULL
264
265Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
266NULL
267
268Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
269NULL
270
271-- Iteration 18 --
272Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
273NULL
274
275Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
276NULL
277
278Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
279NULL
280
281-- Iteration 19 --
282Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
283NULL
284
285Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
286NULL
287
288Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
289NULL
290
291-- Iteration 20 --
292Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
293NULL
294
295Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
296NULL
297
298Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d
299NULL
300
301-- Iteration 21 --
302Warning: array_reverse() expects parameter 1 to be array, object given in %s on line %d
303NULL
304
305Warning: array_reverse() expects parameter 1 to be array, object given in %s on line %d
306NULL
307
308Warning: array_reverse() expects parameter 1 to be array, object given in %s on line %d
309NULL
310
311-- Iteration 22 --
312Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
313NULL
314
315Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
316NULL
317
318Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
319NULL
320
321-- Iteration 23 --
322Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
323NULL
324
325Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
326NULL
327
328Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d
329NULL
330
331-- Iteration 24 --
332Warning: array_reverse() expects parameter 1 to be array, resource given in %s on line %d
333NULL
334
335Warning: array_reverse() expects parameter 1 to be array, resource given in %s on line %d
336NULL
337
338Warning: array_reverse() expects parameter 1 to be array, resource given in %s on line %d
339NULL
340Done
341