1--TEST--
2Test array_diff_ukey() function : usage variation - Passing unexpected values to callback 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$array1 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'   => 8);
14$array2 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
15$array3 = array(1, 2, 3, 4, 5);
16
17//get an unset variable
18$unset_var = 10;
19unset ($unset_var);
20
21//resource variable
22$fp = fopen(__FILE__, "r");
23
24// define some classes
25class classWithToString
26{
27	public function __toString() {
28		return "Class A object";
29	}
30}
31
32class classWithoutToString
33{
34}
35
36// heredoc string
37$heredoc = <<<EOT
38hello world
39EOT;
40
41//array of values to iterate over
42$inputs = array(
43
44      // int data
45      'int 0' => 0,
46      'int 1' => 1,
47      'int 12345' => 12345,
48      'int -12345' => -12345,
49
50      // float data
51      'float 10.5' => 10.5,
52      'float -10.5' => -10.5,
53      'float 12.3456789000e10' => 12.3456789000e10,
54      'float -12.3456789000e10' => -12.3456789000e10,
55      'float .5' => .5,
56
57      // null data
58      'uppercase NULL' => NULL,
59      'lowercase null' => null,
60
61      // boolean data
62      'lowercase true' => true,
63      'lowercase false' =>false,
64      'uppercase TRUE' =>TRUE,
65      'uppercase FALSE' =>FALSE,
66
67      // object data
68      'instance of classWithToString' => new classWithToString(),
69	  'instance of classWithoutToString' => new classWithoutToString(),
70
71      // undefined data
72      'undefined var' => @$undefined_var,
73
74      // unset data
75      'unset var' => @$unset_var,
76
77      // resource data
78      'resource' => $fp,
79);
80
81// loop through each element of the array for ...
82
83foreach($inputs as $key =>$value) {
84      echo "\n--$key--\n";
85      var_dump( array_diff_ukey($array1, $array2, $value) );
86      var_dump( array_diff_ukey($array1, $array2, $array3, $value) );
87};
88
89fclose($fp);
90?>
91===DONE===
92--EXPECTF--
93*** Testing array_diff_ukey() : usage variation ***
94
95--int 0--
96
97Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
98NULL
99
100Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
101NULL
102
103--int 1--
104
105Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
106NULL
107
108Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
109NULL
110
111--int 12345--
112
113Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
114NULL
115
116Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
117NULL
118
119--int -12345--
120
121Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
122NULL
123
124Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
125NULL
126
127--float 10.5--
128
129Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
130NULL
131
132Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
133NULL
134
135--float -10.5--
136
137Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
138NULL
139
140Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
141NULL
142
143--float 12.3456789000e10--
144
145Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
146NULL
147
148Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
149NULL
150
151--float -12.3456789000e10--
152
153Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
154NULL
155
156Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
157NULL
158
159--float .5--
160
161Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
162NULL
163
164Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
165NULL
166
167--uppercase NULL--
168
169Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
170NULL
171
172Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
173NULL
174
175--lowercase null--
176
177Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
178NULL
179
180Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
181NULL
182
183--lowercase true--
184
185Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
186NULL
187
188Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
189NULL
190
191--lowercase false--
192
193Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
194NULL
195
196Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
197NULL
198
199--uppercase TRUE--
200
201Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
202NULL
203
204Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
205NULL
206
207--uppercase FALSE--
208
209Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
210NULL
211
212Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
213NULL
214
215--instance of classWithToString--
216
217Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
218NULL
219
220Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
221NULL
222
223--instance of classWithoutToString--
224
225Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
226NULL
227
228Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
229NULL
230
231--undefined var--
232
233Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
234NULL
235
236Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
237NULL
238
239--unset var--
240
241Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
242NULL
243
244Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
245NULL
246
247--resource--
248
249Warning: array_diff_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
250NULL
251
252Warning: array_diff_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
253NULL
254===DONE===
255