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