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