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