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$arr2 = array(1, 2);
15
16include('compare_function.inc');
17$data_compare_function = 'compare_function';
18
19//get an unset variable
20$unset_var = 10;
21unset ($unset_var);
22
23// define some classes
24class classWithToString
25{
26	public function __toString() {
27		return "Class A object";
28	}
29}
30
31class classWithoutToString
32{
33}
34
35// heredoc string
36$heredoc = <<<EOT
37hello world
38EOT;
39
40// add arrays
41$index_array = array (1, 2, 3);
42$assoc_array = array ('one' => 1, 'two' => 2);
43
44//array of values to iterate over
45$inputs = array(
46
47      // int data
48      'int 0' => 0,
49      'int 1' => 1,
50      'int 12345' => 12345,
51      'int -12345' => -2345,
52
53      // float data
54      'float 10.5' => 10.5,
55      'float -10.5' => -10.5,
56      'float 12.3456789000e10' => 12.3456789000e10,
57      'float -12.3456789000e10' => -12.3456789000e10,
58      'float .5' => .5,
59
60      // null data
61      'uppercase NULL' => NULL,
62      'lowercase null' => null,
63
64      // boolean data
65      'lowercase true' => true,
66      'lowercase false' =>false,
67      'uppercase TRUE' =>TRUE,
68      'uppercase FALSE' =>FALSE,
69
70      // empty data
71      'empty string DQ' => "",
72      'empty string SQ' => '',
73
74      // string data
75      'string DQ' => "string",
76      'string SQ' => 'string',
77      'mixed case string' => "sTrInG",
78      'heredoc' => $heredoc,
79
80      // object data
81      'instance of classWithToString' => new classWithToString(),
82      'instance of classWithoutToString' => new classWithoutToString(),
83
84      // undefined data
85      'undefined var' => @$undefined_var,
86
87      // unset data
88      'unset var' => @$unset_var,
89);
90
91// loop through each element of the array for arr1
92
93foreach($inputs as $key =>$value) {
94      echo "\n--$key--\n";
95      var_dump( array_uintersect($value, $arr2, $data_compare_function) );
96};
97
98?>
99===DONE===
100--EXPECTF--
101*** Testing array_uintersect() : usage variation ***
102
103--int 0--
104
105Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
106NULL
107
108--int 1--
109
110Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
111NULL
112
113--int 12345--
114
115Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
116NULL
117
118--int -12345--
119
120Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
121NULL
122
123--float 10.5--
124
125Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
126NULL
127
128--float -10.5--
129
130Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
131NULL
132
133--float 12.3456789000e10--
134
135Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
136NULL
137
138--float -12.3456789000e10--
139
140Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
141NULL
142
143--float .5--
144
145Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
146NULL
147
148--uppercase NULL--
149
150Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
151NULL
152
153--lowercase null--
154
155Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
156NULL
157
158--lowercase true--
159
160Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
161NULL
162
163--lowercase false--
164
165Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
166NULL
167
168--uppercase TRUE--
169
170Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
171NULL
172
173--uppercase FALSE--
174
175Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
176NULL
177
178--empty string DQ--
179
180Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
181NULL
182
183--empty string SQ--
184
185Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
186NULL
187
188--string DQ--
189
190Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
191NULL
192
193--string SQ--
194
195Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
196NULL
197
198--mixed case string--
199
200Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
201NULL
202
203--heredoc--
204
205Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
206NULL
207
208--instance of classWithToString--
209
210Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
211NULL
212
213--instance of classWithoutToString--
214
215Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
216NULL
217
218--undefined var--
219
220Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
221NULL
222
223--unset var--
224
225Warning: array_uintersect(): Argument #1 is not an array in %sarray_uintersect_variation1.php on line %d
226NULL
227===DONE===
228