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