1--TEST--
2Test array_multisort() function : usage variation
3--FILE--
4<?php
5echo "*** Testing array_multisort() : usage variation ***\n";
6
7// Define error handler
8function test_error_handler($err_no, $err_msg, $filename, $linenum) {
9    if (error_reporting() & $err_no) {
10        // report non-silenced errors
11        echo "Error: $err_no - $err_msg, $filename($linenum)\n";
12    }
13}
14set_error_handler('test_error_handler');
15
16$ar2 = array(1, 2);
17
18//get an unset variable
19$unset_var = 10;
20unset ($unset_var);
21
22// define some classes
23class classWithToString
24{
25    public function __toString() {
26        return "Class A object";
27    }
28}
29
30class classWithoutToString
31{
32}
33
34// heredoc string
35$heredoc = <<<EOT
36hello world
37EOT;
38
39// add arrays
40$index_array = array (1, 2, 3);
41$assoc_array = array ('one' => 1, 'two' => 2);
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
90// loop through each element of the array for ar1
91
92foreach($inputs as $key =>$value) {
93      echo "\n--$key--\n";
94      try {
95          var_dump( array_multisort($value));
96      } catch (\ValueError | \TypeError $e) {
97          echo $e->getMessage() . "\n";
98      }
99};
100
101?>
102--EXPECT--
103*** Testing array_multisort() : usage variation ***
104
105--int 0--
106array_multisort(): Argument #1 ($array) must be an array or a sort flag that has not already been specified
107
108--int 1--
109array_multisort(): Argument #1 ($array) must be an array or a sort flag that has not already been specified
110
111--int 12345--
112array_multisort(): Argument #1 ($array) must be a valid sort flag
113
114--int -12345--
115array_multisort(): Argument #1 ($array) must be a valid sort flag
116
117--float 10.5--
118array_multisort(): Argument #1 ($array) must be an array or a sort flag
119
120--float -10.5--
121array_multisort(): Argument #1 ($array) must be an array or a sort flag
122
123--float 12.3456789000e10--
124array_multisort(): Argument #1 ($array) must be an array or a sort flag
125
126--float -12.3456789000e10--
127array_multisort(): Argument #1 ($array) must be an array or a sort flag
128
129--float .5--
130array_multisort(): Argument #1 ($array) must be an array or a sort flag
131
132--uppercase NULL--
133array_multisort(): Argument #1 ($array) must be an array or a sort flag
134
135--lowercase null--
136array_multisort(): Argument #1 ($array) must be an array or a sort flag
137
138--lowercase true--
139array_multisort(): Argument #1 ($array) must be an array or a sort flag
140
141--lowercase false--
142array_multisort(): Argument #1 ($array) must be an array or a sort flag
143
144--uppercase TRUE--
145array_multisort(): Argument #1 ($array) must be an array or a sort flag
146
147--uppercase FALSE--
148array_multisort(): Argument #1 ($array) must be an array or a sort flag
149
150--empty string DQ--
151array_multisort(): Argument #1 ($array) must be an array or a sort flag
152
153--empty string SQ--
154array_multisort(): Argument #1 ($array) must be an array or a sort flag
155
156--string DQ--
157array_multisort(): Argument #1 ($array) must be an array or a sort flag
158
159--string SQ--
160array_multisort(): Argument #1 ($array) must be an array or a sort flag
161
162--mixed case string--
163array_multisort(): Argument #1 ($array) must be an array or a sort flag
164
165--heredoc--
166array_multisort(): Argument #1 ($array) must be an array or a sort flag
167
168--instance of classWithToString--
169array_multisort(): Argument #1 ($array) must be an array or a sort flag
170
171--instance of classWithoutToString--
172array_multisort(): Argument #1 ($array) must be an array or a sort flag
173
174--undefined var--
175array_multisort(): Argument #1 ($array) must be an array or a sort flag
176
177--unset var--
178array_multisort(): Argument #1 ($array) must be an array or a sort flag
179