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