1--TEST--
2Test array_diff_ukey() function : usage variation - Passing unexpected values to third optional argument
3--FILE--
4<?php
5/* Prototype  : array array_diff_ukey(array arr1, array arr2 [, array ...], callback key_comp_func)
6 * Description: Returns the entries of arr1 that have keys which are not present in any of the others arguments.
7 * Source code: ext/standard/array.c
8 */
9
10echo "*** Testing array_diff_ukey() : usage variation ***\n";
11
12// Initialise function arguments not being substituted (if any)
13$array1 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'   => 8);
14$array2 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
15
16function key_compare_func($key1, $key2)
17{
18    if ($key1 == $key2) {
19        return 0;
20    }
21    return ($key1 > $key2)? 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//array of values to iterate over
49$inputs = array(
50
51      // int data
52      'int 0' => 0,
53      'int 1' => 1,
54      'int 12345' => 12345,
55      'int -12345' => -2345,
56
57      // float data
58      'float 10.5' => 10.5,
59      'float -10.5' => -10.5,
60      'float 12.3456789000e10' => 12.3456789000e10,
61      'float -12.3456789000e10' => -12.3456789000e10,
62      'float .5' => .5,
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      // resource data
95      'resource' => $fp,
96);
97
98// loop through each element of the array for key_comp_func
99
100foreach($inputs as $key =>$value) {
101      echo "\n--$key--\n";
102      var_dump( array_diff_ukey($array1, $array2, $value, 'key_compare_func') );
103};
104
105fclose($fp);
106?>
107===DONE===
108--EXPECTF--
109*** Testing array_diff_ukey() : usage variation ***
110
111--int 0--
112
113Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
114NULL
115
116--int 1--
117
118Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
119NULL
120
121--int 12345--
122
123Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
124NULL
125
126--int -12345--
127
128Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
129NULL
130
131--float 10.5--
132
133Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
134NULL
135
136--float -10.5--
137
138Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
139NULL
140
141--float 12.3456789000e10--
142
143Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
144NULL
145
146--float -12.3456789000e10--
147
148Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
149NULL
150
151--float .5--
152
153Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
154NULL
155
156--uppercase NULL--
157
158Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
159NULL
160
161--lowercase null--
162
163Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
164NULL
165
166--lowercase true--
167
168Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
169NULL
170
171--lowercase false--
172
173Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
174NULL
175
176--uppercase TRUE--
177
178Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
179NULL
180
181--uppercase FALSE--
182
183Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
184NULL
185
186--empty string DQ--
187
188Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
189NULL
190
191--empty string SQ--
192
193Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
194NULL
195
196--string DQ--
197
198Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
199NULL
200
201--string SQ--
202
203Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
204NULL
205
206--mixed case string--
207
208Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
209NULL
210
211--heredoc--
212
213Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
214NULL
215
216--instance of classWithToString--
217
218Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
219NULL
220
221--instance of classWithoutToString--
222
223Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
224NULL
225
226--undefined var--
227
228Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
229NULL
230
231--unset var--
232
233Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
234NULL
235
236--resource--
237
238Warning: array_diff_ukey(): Argument #3 is not an array in %s on line %d
239NULL
240===DONE===
241