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