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