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