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