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