1--TEST--
2Test array_diff_ukey() function : usage variation - Passing unexpected values to first argument
3--FILE--
4<?php
5echo "*** Testing array_diff_ukey() : usage variation ***\n";
6
7// Initialise function arguments not being substituted (if any)
8$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'   => 8);
9$array3 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
10
11function key_compare_func($key1, $key2)
12{
13    if ($key1 == $key2) {
14        return 0;
15    }
16    return ($key1 > $key2)? 1:-1;
17}
18
19//get an unset variable
20$unset_var = 10;
21unset ($unset_var);
22
23//resource variable
24$fp = fopen(__FILE__, "r");
25
26// define some classes
27class classWithToString
28{
29    public function __toString() {
30        return "Class A object";
31    }
32}
33
34class classWithoutToString
35{
36}
37
38// heredoc string
39$heredoc = <<<EOT
40hello world
41EOT;
42
43//array of values to iterate over
44$inputs = array(
45
46      // int data
47      'int 0' => 0,
48      'int 1' => 1,
49      'int 12345' => 12345,
50      'int -12345' => -2345,
51
52      // float data
53      'float 10.5' => 10.5,
54      'float -10.5' => -10.5,
55      'float 12.3456789000e10' => 12.3456789000e10,
56      'float -12.3456789000e10' => -12.3456789000e10,
57      'float .5' => .5,
58
59      // null data
60      'uppercase NULL' => NULL,
61      'lowercase null' => null,
62
63      // boolean data
64      'lowercase true' => true,
65      'lowercase false' =>false,
66      'uppercase TRUE' =>TRUE,
67      'uppercase FALSE' =>FALSE,
68
69      // empty data
70      'empty string DQ' => "",
71      'empty string SQ' => '',
72
73      // string data
74      'string DQ' => "string",
75      'string SQ' => 'string',
76      'mixed case string' => "sTrInG",
77      'heredoc' => $heredoc,
78
79      // object data
80      'instance of classWithToString' => new classWithToString(),
81      'instance of classWithoutToString' => new classWithoutToString(),
82
83      // undefined data
84      'undefined var' => @$undefined_var,
85
86      // unset data
87      'unset var' => @$unset_var,
88
89      // resource data
90      'resource' => $fp,
91);
92
93// loop through each element of the array for array1
94foreach($inputs as $key =>$value) {
95    echo "\n--$key--\n";
96    try {
97        var_dump( array_diff_ukey($value, $array2, 'key_compare_func') );
98    } catch (TypeError $e) {
99        echo $e->getMessage(), "\n";
100    }
101    try {
102        var_dump( array_diff_ukey($value, $array2, $array3, 'key_compare_func') );
103    } catch (TypeError $e) {
104        echo $e->getMessage(), "\n";
105    }
106};
107
108fclose($fp);
109?>
110--EXPECT--
111*** Testing array_diff_ukey() : usage variation ***
112
113--int 0--
114array_diff_ukey(): Argument #1 ($array) must be of type array, int given
115array_diff_ukey(): Argument #1 ($array) must be of type array, int given
116
117--int 1--
118array_diff_ukey(): Argument #1 ($array) must be of type array, int given
119array_diff_ukey(): Argument #1 ($array) must be of type array, int given
120
121--int 12345--
122array_diff_ukey(): Argument #1 ($array) must be of type array, int given
123array_diff_ukey(): Argument #1 ($array) must be of type array, int given
124
125--int -12345--
126array_diff_ukey(): Argument #1 ($array) must be of type array, int given
127array_diff_ukey(): Argument #1 ($array) must be of type array, int given
128
129--float 10.5--
130array_diff_ukey(): Argument #1 ($array) must be of type array, float given
131array_diff_ukey(): Argument #1 ($array) must be of type array, float given
132
133--float -10.5--
134array_diff_ukey(): Argument #1 ($array) must be of type array, float given
135array_diff_ukey(): Argument #1 ($array) must be of type array, float given
136
137--float 12.3456789000e10--
138array_diff_ukey(): Argument #1 ($array) must be of type array, float given
139array_diff_ukey(): Argument #1 ($array) must be of type array, float given
140
141--float -12.3456789000e10--
142array_diff_ukey(): Argument #1 ($array) must be of type array, float given
143array_diff_ukey(): Argument #1 ($array) must be of type array, float given
144
145--float .5--
146array_diff_ukey(): Argument #1 ($array) must be of type array, float given
147array_diff_ukey(): Argument #1 ($array) must be of type array, float given
148
149--uppercase NULL--
150array_diff_ukey(): Argument #1 ($array) must be of type array, null given
151array_diff_ukey(): Argument #1 ($array) must be of type array, null given
152
153--lowercase null--
154array_diff_ukey(): Argument #1 ($array) must be of type array, null given
155array_diff_ukey(): Argument #1 ($array) must be of type array, null given
156
157--lowercase true--
158array_diff_ukey(): Argument #1 ($array) must be of type array, true given
159array_diff_ukey(): Argument #1 ($array) must be of type array, true given
160
161--lowercase false--
162array_diff_ukey(): Argument #1 ($array) must be of type array, false given
163array_diff_ukey(): Argument #1 ($array) must be of type array, false given
164
165--uppercase TRUE--
166array_diff_ukey(): Argument #1 ($array) must be of type array, true given
167array_diff_ukey(): Argument #1 ($array) must be of type array, true given
168
169--uppercase FALSE--
170array_diff_ukey(): Argument #1 ($array) must be of type array, false given
171array_diff_ukey(): Argument #1 ($array) must be of type array, false given
172
173--empty string DQ--
174array_diff_ukey(): Argument #1 ($array) must be of type array, string given
175array_diff_ukey(): Argument #1 ($array) must be of type array, string given
176
177--empty string SQ--
178array_diff_ukey(): Argument #1 ($array) must be of type array, string given
179array_diff_ukey(): Argument #1 ($array) must be of type array, string given
180
181--string DQ--
182array_diff_ukey(): Argument #1 ($array) must be of type array, string given
183array_diff_ukey(): Argument #1 ($array) must be of type array, string given
184
185--string SQ--
186array_diff_ukey(): Argument #1 ($array) must be of type array, string given
187array_diff_ukey(): Argument #1 ($array) must be of type array, string given
188
189--mixed case string--
190array_diff_ukey(): Argument #1 ($array) must be of type array, string given
191array_diff_ukey(): Argument #1 ($array) must be of type array, string given
192
193--heredoc--
194array_diff_ukey(): Argument #1 ($array) must be of type array, string given
195array_diff_ukey(): Argument #1 ($array) must be of type array, string given
196
197--instance of classWithToString--
198array_diff_ukey(): Argument #1 ($array) must be of type array, classWithToString given
199array_diff_ukey(): Argument #1 ($array) must be of type array, classWithToString given
200
201--instance of classWithoutToString--
202array_diff_ukey(): Argument #1 ($array) must be of type array, classWithoutToString given
203array_diff_ukey(): Argument #1 ($array) must be of type array, classWithoutToString given
204
205--undefined var--
206array_diff_ukey(): Argument #1 ($array) must be of type array, null given
207array_diff_ukey(): Argument #1 ($array) must be of type array, null given
208
209--unset var--
210array_diff_ukey(): Argument #1 ($array) must be of type array, null given
211array_diff_ukey(): Argument #1 ($array) must be of type array, null given
212
213--resource--
214array_diff_ukey(): Argument #1 ($array) must be of type array, resource given
215array_diff_ukey(): Argument #1 ($array) must be of type array, resource given
216