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