1--TEST--
2Test ob_implicit_flush() function : usage variation
3--SKIPIF--
4<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64-bit only");
5--FILE--
6<?php
7/* Prototype  : void ob_implicit_flush([int flag])
8 * Description: Turn implicit flush on/off and is equivalent to calling flush() after every output call
9 * Source code: main/output.c
10 * Alias to functions:
11 */
12
13echo "*** Testing ob_implicit_flush() : usage variation ***\n";
14
15// Define error handler
16function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
17	if (error_reporting() != 0) {
18		// report non-silenced errors
19		echo "Error: $err_no - $err_msg, $filename($linenum)\n";
20	}
21}
22set_error_handler('test_error_handler');
23
24// Initialise function arguments not being substituted (if any)
25
26//get an unset variable
27$unset_var = 10;
28unset ($unset_var);
29
30// define some classes
31class classWithToString
32{
33	public function __toString() {
34		return "Class A object";
35	}
36}
37
38class classWithoutToString
39{
40}
41
42// heredoc string
43$heredoc = <<<EOT
44hello world
45EOT;
46
47// add arrays
48$index_array = array (1, 2, 3);
49$assoc_array = array ('one' => 1, 'two' => 2);
50
51//array of values to iterate over
52$inputs = array(
53
54      // float data
55      'float 10.5' => 10.5,
56      'float -10.5' => -10.5,
57      'float 12.3456789000e10' => 12.3456789000e10,
58      'float -12.3456789000e10' => -12.3456789000e10,
59      'float .5' => .5,
60
61      // array data
62      'empty array' => array(),
63      'int indexed array' => $index_array,
64      'associative array' => $assoc_array,
65      'nested arrays' => array('foo', $index_array, $assoc_array),
66
67      // null data
68      'uppercase NULL' => NULL,
69      'lowercase null' => null,
70
71      // boolean data
72      'lowercase true' => true,
73      'lowercase false' =>false,
74      'uppercase TRUE' =>TRUE,
75      'uppercase FALSE' =>FALSE,
76
77      // empty data
78      'empty string DQ' => "",
79      'empty string SQ' => '',
80
81      // string data
82      'string DQ' => "string",
83      'string SQ' => 'string',
84      'mixed case string' => "sTrInG",
85      'heredoc' => $heredoc,
86
87      // object data
88      'instance of classWithToString' => new classWithToString(),
89      'instance of classWithoutToString' => new classWithoutToString(),
90
91      // undefined data
92      'undefined var' => @$undefined_var,
93
94      // unset data
95      'unset var' => @$unset_var,
96);
97
98// loop through each element of the array for flag
99
100foreach($inputs as $key =>$value) {
101      echo "\n--$key--\n";
102      var_dump( ob_implicit_flush($value) );
103};
104
105?>
106--EXPECTF--
107*** Testing ob_implicit_flush() : usage variation ***
108
109--float 10.5--
110NULL
111
112--float -10.5--
113NULL
114
115--float 12.3456789000e10--
116NULL
117
118--float -12.3456789000e10--
119NULL
120
121--float .5--
122NULL
123
124--empty array--
125Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, array given, %s(97)
126NULL
127
128--int indexed array--
129Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, array given, %s(97)
130NULL
131
132--associative array--
133Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, array given, %s(97)
134NULL
135
136--nested arrays--
137Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, array given, %s(97)
138NULL
139
140--uppercase NULL--
141NULL
142
143--lowercase null--
144NULL
145
146--lowercase true--
147NULL
148
149--lowercase false--
150NULL
151
152--uppercase TRUE--
153NULL
154
155--uppercase FALSE--
156NULL
157
158--empty string DQ--
159Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, string given, %s(97)
160NULL
161
162--empty string SQ--
163Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, string given, %s(97)
164NULL
165
166--string DQ--
167Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, string given, %s(97)
168NULL
169
170--string SQ--
171Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, string given, %s(97)
172NULL
173
174--mixed case string--
175Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, string given, %s(97)
176NULL
177
178--heredoc--
179Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, string given, %s(97)
180NULL
181
182--instance of classWithToString--
183Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, object given, %s(97)
184NULL
185
186--instance of classWithoutToString--
187Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, object given, %s(97)
188NULL
189
190--undefined var--
191NULL
192
193--unset var--
194NULL
195