1--TEST--
2Test ctype_cntrl() function : usage variations - Different data types as $c arg
3--EXTENSIONS--
4ctype
5--FILE--
6<?php
7/*
8 * Pass different data types as $c argument to ctype_cntrl() to test behaviour
9 */
10
11echo "*** Testing ctype_cntrl() : usage variations ***\n";
12
13$orig = setlocale(LC_CTYPE, "C");
14
15//get an unset variable
16$unset_var = 10;
17unset ($unset_var);
18
19// get a class
20class classA
21{
22  public function __toString() {
23    return "\n\r\t";
24  }
25}
26
27// heredoc string
28$heredoc = <<<EOT
29\t\r\n
30EOT;
31
32// get a resource variable
33$fp = fopen(__FILE__, "r");
34
35// unexpected values to be passed to $c argument
36$inputs = array(
37
38       // int data
39/*1*/  0,
40       1,
41       12345,
42       -2345,
43
44       // float data
45/*5*/  10.5,
46       -10.5,
47       12.3456789000e10,
48       12.3456789000E-10,
49       .5,
50
51       // null data
52/*10*/ NULL,
53       null,
54
55       // boolean data
56/*12*/ true,
57       false,
58       TRUE,
59       FALSE,
60
61       // empty data
62/*16*/ "",
63       '',
64       array(),
65
66       // string data
67/*19*/ "\t\r\n",
68       '
69',
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 ctype_cntrl()
86$iterator = 1;
87foreach($inputs as $input) {
88  echo "\n-- Iteration $iterator --\n";
89  var_dump( ctype_cntrl($input) );
90  $iterator++;
91};
92
93fclose($fp);
94
95setlocale(LC_CTYPE, $orig);
96?>
97--EXPECTF--
98*** Testing ctype_cntrl() : usage variations ***
99
100-- Iteration 1 --
101
102Deprecated: ctype_cntrl(): Argument of type int will be interpreted as string in the future in %s on line %d
103bool(true)
104
105-- Iteration 2 --
106
107Deprecated: ctype_cntrl(): Argument of type int will be interpreted as string in the future in %s on line %d
108bool(true)
109
110-- Iteration 3 --
111
112Deprecated: ctype_cntrl(): Argument of type int will be interpreted as string in the future in %s on line %d
113bool(false)
114
115-- Iteration 4 --
116
117Deprecated: ctype_cntrl(): Argument of type int will be interpreted as string in the future in %s on line %d
118bool(false)
119
120-- Iteration 5 --
121
122Deprecated: ctype_cntrl(): Argument of type float will be interpreted as string in the future in %s on line %d
123bool(false)
124
125-- Iteration 6 --
126
127Deprecated: ctype_cntrl(): Argument of type float will be interpreted as string in the future in %s on line %d
128bool(false)
129
130-- Iteration 7 --
131
132Deprecated: ctype_cntrl(): Argument of type float will be interpreted as string in the future in %s on line %d
133bool(false)
134
135-- Iteration 8 --
136
137Deprecated: ctype_cntrl(): Argument of type float will be interpreted as string in the future in %s on line %d
138bool(false)
139
140-- Iteration 9 --
141
142Deprecated: ctype_cntrl(): Argument of type float will be interpreted as string in the future in %s on line %d
143bool(false)
144
145-- Iteration 10 --
146
147Deprecated: ctype_cntrl(): Argument of type null will be interpreted as string in the future in %s on line %d
148bool(false)
149
150-- Iteration 11 --
151
152Deprecated: ctype_cntrl(): Argument of type null will be interpreted as string in the future in %s on line %d
153bool(false)
154
155-- Iteration 12 --
156
157Deprecated: ctype_cntrl(): Argument of type bool will be interpreted as string in the future in %s on line %d
158bool(false)
159
160-- Iteration 13 --
161
162Deprecated: ctype_cntrl(): Argument of type bool will be interpreted as string in the future in %s on line %d
163bool(false)
164
165-- Iteration 14 --
166
167Deprecated: ctype_cntrl(): Argument of type bool will be interpreted as string in the future in %s on line %d
168bool(false)
169
170-- Iteration 15 --
171
172Deprecated: ctype_cntrl(): Argument of type bool will be interpreted as string in the future in %s on line %d
173bool(false)
174
175-- Iteration 16 --
176bool(false)
177
178-- Iteration 17 --
179bool(false)
180
181-- Iteration 18 --
182
183Deprecated: ctype_cntrl(): Argument of type array will be interpreted as string in the future in %s on line %d
184bool(false)
185
186-- Iteration 19 --
187bool(true)
188
189-- Iteration 20 --
190bool(true)
191
192-- Iteration 21 --
193bool(true)
194
195-- Iteration 22 --
196
197Deprecated: ctype_cntrl(): Argument of type classA will be interpreted as string in the future in %s on line %d
198bool(false)
199
200-- Iteration 23 --
201
202Deprecated: ctype_cntrl(): Argument of type null will be interpreted as string in the future in %s on line %d
203bool(false)
204
205-- Iteration 24 --
206
207Deprecated: ctype_cntrl(): Argument of type null will be interpreted as string in the future in %s on line %d
208bool(false)
209
210-- Iteration 25 --
211
212Deprecated: ctype_cntrl(): Argument of type resource will be interpreted as string in the future in %s on line %d
213bool(false)
214