1--TEST--
2Test array_values() function : usage variations - Pass different data types as $input arg
3--FILE--
4<?php
5/* Prototype  : array array_values(array $input)
6 * Description: Return just the values from the input array
7 * Source code: ext/standard/array.c
8 */
9
10/*
11 * Pass different data types as $input argument to array_values() to test behaviour
12 */
13
14echo "*** Testing array_values() : usage variations ***\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 $input 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 array_values()
86$iterator = 1;
87foreach($inputs as $input) {
88  echo "\n-- Iteration $iterator --\n";
89  var_dump( array_values($input) );
90  $iterator++;
91};
92
93fclose($fp);
94
95echo "Done";
96?>
97--EXPECTF--
98*** Testing array_values() : usage variations ***
99
100-- Iteration 1 --
101
102Warning: array_values() expects parameter 1 to be array, integer given in %s on line %d
103NULL
104
105-- Iteration 2 --
106
107Warning: array_values() expects parameter 1 to be array, integer given in %s on line %d
108NULL
109
110-- Iteration 3 --
111
112Warning: array_values() expects parameter 1 to be array, integer given in %s on line %d
113NULL
114
115-- Iteration 4 --
116
117Warning: array_values() expects parameter 1 to be array, integer given in %s on line %d
118NULL
119
120-- Iteration 5 --
121
122Warning: array_values() expects parameter 1 to be array, float given in %s on line %d
123NULL
124
125-- Iteration 6 --
126
127Warning: array_values() expects parameter 1 to be array, float given in %s on line %d
128NULL
129
130-- Iteration 7 --
131
132Warning: array_values() expects parameter 1 to be array, float given in %s on line %d
133NULL
134
135-- Iteration 8 --
136
137Warning: array_values() expects parameter 1 to be array, float given in %s on line %d
138NULL
139
140-- Iteration 9 --
141
142Warning: array_values() expects parameter 1 to be array, float given in %s on line %d
143NULL
144
145-- Iteration 10 --
146
147Warning: array_values() expects parameter 1 to be array, null given in %s on line %d
148NULL
149
150-- Iteration 11 --
151
152Warning: array_values() expects parameter 1 to be array, null given in %s on line %d
153NULL
154
155-- Iteration 12 --
156
157Warning: array_values() expects parameter 1 to be array, boolean given in %s on line %d
158NULL
159
160-- Iteration 13 --
161
162Warning: array_values() expects parameter 1 to be array, boolean given in %s on line %d
163NULL
164
165-- Iteration 14 --
166
167Warning: array_values() expects parameter 1 to be array, boolean given in %s on line %d
168NULL
169
170-- Iteration 15 --
171
172Warning: array_values() expects parameter 1 to be array, boolean given in %s on line %d
173NULL
174
175-- Iteration 16 --
176
177Warning: array_values() expects parameter 1 to be array, string given in %s on line %d
178NULL
179
180-- Iteration 17 --
181
182Warning: array_values() expects parameter 1 to be array, string given in %s on line %d
183NULL
184
185-- Iteration 18 --
186array(0) {
187}
188
189-- Iteration 19 --
190
191Warning: array_values() expects parameter 1 to be array, string given in %s on line %d
192NULL
193
194-- Iteration 20 --
195
196Warning: array_values() expects parameter 1 to be array, string given in %s on line %d
197NULL
198
199-- Iteration 21 --
200
201Warning: array_values() expects parameter 1 to be array, string given in %s on line %d
202NULL
203
204-- Iteration 22 --
205
206Warning: array_values() expects parameter 1 to be array, object given in %s on line %d
207NULL
208
209-- Iteration 23 --
210
211Warning: array_values() expects parameter 1 to be array, null given in %s on line %d
212NULL
213
214-- Iteration 24 --
215
216Warning: array_values() expects parameter 1 to be array, null given in %s on line %d
217NULL
218
219-- Iteration 25 --
220
221Warning: array_values() expects parameter 1 to be array, resource given in %s on line %d
222NULL
223Done
224