1--TEST--
2Test array_multisort() function : usage variation
3--FILE--
4<?php
5/* Prototype  : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]], ...])
6 * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
7 * Source code: ext/standard/array.c
8 * Alias to functions:
9 */
10
11echo "*** Testing array_multisort() : usage variation ***\n";
12
13// Define error handler
14function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
15	if (error_reporting() != 0) {
16		// report non-silenced errors
17		echo "Error: $err_no - $err_msg, $filename($linenum)\n";
18	}
19}
20set_error_handler('test_error_handler');
21
22$ar2 = array(1, 2);
23
24//get an unset variable
25$unset_var = 10;
26unset ($unset_var);
27
28// define some classes
29class classWithToString
30{
31	public function __toString() {
32		return "Class A object";
33	}
34}
35
36class classWithoutToString
37{
38}
39
40// heredoc string
41$heredoc = <<<EOT
42hello world
43EOT;
44
45// add arrays
46$index_array = array (1, 2, 3);
47$assoc_array = array ('one' => 1, 'two' => 2);
48
49//array of values to iterate over
50$inputs = array(
51
52      // int data
53      'int 0' => 0,
54      'int 1' => 1,
55      'int 12345' => 12345,
56      'int -12345' => -2345,
57
58      // float data
59      'float 10.5' => 10.5,
60      'float -10.5' => -10.5,
61      'float 12.3456789000e10' => 12.3456789000e10,
62      'float -12.3456789000e10' => -12.3456789000e10,
63      'float .5' => .5,
64
65      // null data
66      'uppercase NULL' => NULL,
67      'lowercase null' => null,
68
69      // boolean data
70      'lowercase true' => true,
71      'lowercase false' =>false,
72      'uppercase TRUE' =>TRUE,
73      'uppercase FALSE' =>FALSE,
74
75      // empty data
76      'empty string DQ' => "",
77      'empty string SQ' => '',
78
79      // string data
80      'string DQ' => "string",
81      'string SQ' => 'string',
82      'mixed case string' => "sTrInG",
83      'heredoc' => $heredoc,
84
85      // object data
86      'instance of classWithToString' => new classWithToString(),
87      'instance of classWithoutToString' => new classWithoutToString(),
88
89      // undefined data
90      'undefined var' => @$undefined_var,
91
92      // unset data
93      'unset var' => @$unset_var,
94);
95
96// loop through each element of the array for ar1
97
98foreach($inputs as $key =>$value) {
99      echo "\n--$key--\n";
100      var_dump( array_multisort($value));
101};
102
103?>
104===DONE===
105--EXPECTF--
106*** Testing array_multisort() : usage variation ***
107
108--int 0--
109Error: 2 - array_multisort(): Argument #1 is expected to be an array or sorting flag that has not already been specified, %sarray_multisort_variation1.php(%d)
110bool(false)
111
112--int 1--
113Error: 2 - array_multisort(): Argument #1 is expected to be an array or sorting flag that has not already been specified, %sarray_multisort_variation1.php(%d)
114bool(false)
115
116--int 12345--
117Error: 2 - array_multisort(): Argument #1 is an unknown sort flag, %sarray_multisort_variation1.php(%d)
118bool(false)
119
120--int -12345--
121Error: 2 - array_multisort(): Argument #1 is an unknown sort flag, %sarray_multisort_variation1.php(%d)
122bool(false)
123
124--float 10.5--
125Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
126bool(false)
127
128--float -10.5--
129Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
130bool(false)
131
132--float 12.3456789000e10--
133Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
134bool(false)
135
136--float -12.3456789000e10--
137Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
138bool(false)
139
140--float .5--
141Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
142bool(false)
143
144--uppercase NULL--
145Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
146bool(false)
147
148--lowercase null--
149Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
150bool(false)
151
152--lowercase true--
153Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
154bool(false)
155
156--lowercase false--
157Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
158bool(false)
159
160--uppercase TRUE--
161Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
162bool(false)
163
164--uppercase FALSE--
165Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
166bool(false)
167
168--empty string DQ--
169Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
170bool(false)
171
172--empty string SQ--
173Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
174bool(false)
175
176--string DQ--
177Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
178bool(false)
179
180--string SQ--
181Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
182bool(false)
183
184--mixed case string--
185Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
186bool(false)
187
188--heredoc--
189Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
190bool(false)
191
192--instance of classWithToString--
193Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
194bool(false)
195
196--instance of classWithoutToString--
197Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
198bool(false)
199
200--undefined var--
201Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
202bool(false)
203
204--unset var--
205Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
206bool(false)
207===DONE===
208