1--TEST--
2Test array_uintersect() function : usage variation
3--FILE--
4<?php
5/* Prototype  : array array_uintersect(array arr1, array arr2 [, array ...], callback data_compare_func)
6 * Description: Returns the entries of arr1 that have values which are present in all the other arguments. Data is compared by using an user-supplied callback.
7 * Source code: ext/standard/array.c
8 * Alias to functions:
9 */
10
11echo "*** Testing array_uintersect() : usage variation ***\n";
12
13// Initialise function arguments not being substituted (if any)
14$arr1 = array(1, 2);
15$arr2 = array(1, 2);
16
17//get an unset variable
18$unset_var = 10;
19unset ($unset_var);
20
21// define some classes
22class classWithToString
23{
24	public function __toString() {
25		return "Class A object";
26	}
27}
28
29class classWithoutToString
30{
31}
32
33// heredoc string
34$heredoc = <<<EOT
35hello world
36EOT;
37
38// add arrays
39$index_array = array (1, 2, 3);
40$assoc_array = array ('one' => 1, 'two' => 2);
41
42//array of values to iterate over
43$inputs = array(
44
45      // int data
46      'int 0' => 0,
47      'int 1' => 1,
48      'int 12345' => 12345,
49      'int -12345' => -2345,
50
51      // float data
52      'float 10.5' => 10.5,
53      'float -10.5' => -10.5,
54      'float 12.3456789000e10' => 12.3456789000e10,
55      'float -12.3456789000e10' => -12.3456789000e10,
56      'float .5' => .5,
57
58      // array data
59      'empty array' => array(),
60      'int indexed array' => $index_array,
61      'associative array' => $assoc_array,
62      'nested arrays' => array('foo', $index_array, $assoc_array),
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
95// loop through each element of the array for data_compare_func
96
97foreach($inputs as $key =>$value) {
98      echo "\n--$key--\n";
99      var_dump( array_uintersect($arr1, $arr2, $value) );
100};
101
102?>
103===DONE===
104--EXPECTF--
105*** Testing array_uintersect() : usage variation ***
106
107--int 0--
108
109Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
110NULL
111
112--int 1--
113
114Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
115NULL
116
117--int 12345--
118
119Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
120NULL
121
122--int -12345--
123
124Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
125NULL
126
127--float 10.5--
128
129Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
130NULL
131
132--float -10.5--
133
134Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
135NULL
136
137--float 12.3456789000e10--
138
139Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
140NULL
141
142--float -12.3456789000e10--
143
144Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
145NULL
146
147--float .5--
148
149Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
150NULL
151
152--empty array--
153
154Warning: array_uintersect() expects parameter 3 to be a valid callback, array must have exactly two members in %sarray_uintersect_variation3.php on line %d
155NULL
156
157--int indexed array--
158
159Warning: array_uintersect() expects parameter 3 to be a valid callback, array must have exactly two members in %sarray_uintersect_variation3.php on line %d
160NULL
161
162--associative array--
163
164Warning: array_uintersect() expects parameter 3 to be a valid callback, first array member is not a valid class name or object in %sarray_uintersect_variation3.php on line %d
165NULL
166
167--nested arrays--
168
169Warning: array_uintersect() expects parameter 3 to be a valid callback, array must have exactly two members in %sarray_uintersect_variation3.php on line %d
170NULL
171
172--uppercase NULL--
173
174Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
175NULL
176
177--lowercase null--
178
179Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
180NULL
181
182--lowercase true--
183
184Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
185NULL
186
187--lowercase false--
188
189Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
190NULL
191
192--uppercase TRUE--
193
194Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
195NULL
196
197--uppercase FALSE--
198
199Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
200NULL
201
202--empty string DQ--
203
204Warning: array_uintersect() expects parameter 3 to be a valid callback, function '' not found or invalid function name in %sarray_uintersect_variation3.php on line %d
205NULL
206
207--empty string SQ--
208
209Warning: array_uintersect() expects parameter 3 to be a valid callback, function '' not found or invalid function name in %sarray_uintersect_variation3.php on line %d
210NULL
211
212--string DQ--
213
214Warning: array_uintersect() expects parameter 3 to be a valid callback, function 'string' not found or invalid function name in %sarray_uintersect_variation3.php on line %d
215NULL
216
217--string SQ--
218
219Warning: array_uintersect() expects parameter 3 to be a valid callback, function 'string' not found or invalid function name in %sarray_uintersect_variation3.php on line %d
220NULL
221
222--mixed case string--
223
224Warning: array_uintersect() expects parameter 3 to be a valid callback, function 'sTrInG' not found or invalid function name in %sarray_uintersect_variation3.php on line %d
225NULL
226
227--heredoc--
228
229Warning: array_uintersect() expects parameter 3 to be a valid callback, function 'hello world' not found or invalid function name in %sarray_uintersect_variation3.php on line %d
230NULL
231
232--instance of classWithToString--
233
234Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
235NULL
236
237--instance of classWithoutToString--
238
239Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
240NULL
241
242--undefined var--
243
244Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
245NULL
246
247--unset var--
248
249Warning: array_uintersect() expects parameter 3 to be a valid callback, no array or string given in %sarray_uintersect_variation3.php on line %d
250NULL
251===DONE===
252