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