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