1--TEST--
2Test array_intersect_ukey() function : usage variation - Passing unexpected values to callback argument
3--FILE--
4<?php
5/* Prototype  : array array_intersect_ukey(array arr1, array arr2 [, array ...], callback key_compare_func)
6 * Description: Computes the intersection of arrays using a callback function on the keys for comparison.
7 * Source code: ext/standard/array.c
8 */
9
10echo "*** Testing array_intersect_ukey() : usage variation ***\n";
11
12//Initialise arguments
13$array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
14$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'   => 8);
15$array3 = array('green' => 5, 'cyan'   => 8);
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// add arrays
37$index_array = array (1, 2, 3);
38$assoc_array = array ('one' => 1, 'two' => 2);
39
40//array of values to iterate over
41$inputs = array(
42
43      // int data
44      'int 0' => 0,
45      'int 1' => 1,
46      'int 12345' => 12345,
47      'int -12345' => -12345,
48
49      // float data
50      'float 10.5' => 10.5,
51      'float -10.5' => -10.5,
52      'float 12.3456789000e10' => 12.3456789000e10,
53      'float -12.3456789000e10' => -12.3456789000e10,
54      'float .5' => .5,
55
56      // array data
57      'empty array' => array(),
58      'int indexed array' => $index_array,
59      'associative array' => $assoc_array,
60      'nested arrays' => array('foo', $index_array, $assoc_array),
61
62      // null data
63      'uppercase NULL' => NULL,
64      'lowercase null' => null,
65
66      // boolean data
67      'lowercase true' => true,
68      'lowercase false' =>false,
69      'uppercase TRUE' =>TRUE,
70      'uppercase FALSE' =>FALSE,
71
72      // object data
73      'instance of classWithToString' => new classWithToString(),
74      'instance of classWithoutToString' => new classWithoutToString(),
75
76      // undefined data
77      'undefined var' => @$undefined_var,
78
79      // unset data
80      'unset var' => @$unset_var,
81
82      // resource data
83      'resource var' => $fp,
84);
85
86// loop through each element of the array for key_compare_func
87foreach($inputs as $key =>$value) {
88      echo "\n--$key--\n";
89      var_dump( array_intersect_ukey($array1, $array2, $value) );
90      var_dump( array_intersect_ukey($array1, $array2, $array3, $value) );
91};
92
93fclose($fp);
94?>
95===DONE===
96--EXPECTF--
97*** Testing array_intersect_ukey() : usage variation ***
98
99--int 0--
100
101Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
102NULL
103
104Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
105NULL
106
107--int 1--
108
109Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
110NULL
111
112Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
113NULL
114
115--int 12345--
116
117Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
118NULL
119
120Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
121NULL
122
123--int -12345--
124
125Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
126NULL
127
128Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
129NULL
130
131--float 10.5--
132
133Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
134NULL
135
136Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
137NULL
138
139--float -10.5--
140
141Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
142NULL
143
144Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
145NULL
146
147--float 12.3456789000e10--
148
149Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
150NULL
151
152Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
153NULL
154
155--float -12.3456789000e10--
156
157Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
158NULL
159
160Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
161NULL
162
163--float .5--
164
165Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
166NULL
167
168Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
169NULL
170
171--empty array--
172
173Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, array must have exactly two members in %s on line %d
174NULL
175
176Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, array must have exactly two members in %s on line %d
177NULL
178
179--int indexed array--
180
181Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, array must have exactly two members in %s on line %d
182NULL
183
184Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, array must have exactly two members in %s on line %d
185NULL
186
187--associative array--
188
189Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, first array member is not a valid class name or object in %s on line %d
190NULL
191
192Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, first array member is not a valid class name or object in %s on line %d
193NULL
194
195--nested arrays--
196
197Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, array must have exactly two members in %s on line %d
198NULL
199
200Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, array must have exactly two members in %s on line %d
201NULL
202
203--uppercase NULL--
204
205Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
206NULL
207
208Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
209NULL
210
211--lowercase null--
212
213Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
214NULL
215
216Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
217NULL
218
219--lowercase true--
220
221Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
222NULL
223
224Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
225NULL
226
227--lowercase false--
228
229Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
230NULL
231
232Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
233NULL
234
235--uppercase TRUE--
236
237Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
238NULL
239
240Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
241NULL
242
243--uppercase FALSE--
244
245Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
246NULL
247
248Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
249NULL
250
251--instance of classWithToString--
252
253Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
254NULL
255
256Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
257NULL
258
259--instance of classWithoutToString--
260
261Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
262NULL
263
264Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
265NULL
266
267--undefined var--
268
269Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
270NULL
271
272Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
273NULL
274
275--unset var--
276
277Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
278NULL
279
280Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
281NULL
282
283--resource var--
284
285Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
286NULL
287
288Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
289NULL
290===DONE===
291