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$autoload = true;
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      // object data
78      'instance of classWithToString' => new classWithToString(),
79      'instance of classWithoutToString' => new classWithoutToString(),
80
81      // undefined data
82      'undefined var' => @$undefined_var,
83
84      // unset data
85      'unset var' => @$unset_var,
86);
87
88// loop through each element of the array for classname
89
90foreach($inputs as $key =>$value) {
91      echo "\n--$key--\n";
92      var_dump( interface_exists($value, $autoload) );
93};
94
95?>
96===DONE===
97--EXPECTF--
98*** Testing interface_exists() : usage variation ***
99
100--int 0--
101bool(false)
102
103--int 1--
104bool(false)
105
106--int 12345--
107bool(false)
108
109--int -12345--
110bool(false)
111
112--float 10.5--
113bool(false)
114
115--float -10.5--
116bool(false)
117
118--float 12.3456789000e10--
119bool(false)
120
121--float -12.3456789000e10--
122bool(false)
123
124--float .5--
125bool(false)
126
127--empty array--
128
129Warning: interface_exists() expects parameter 1 to be string, array given in %sinterface_exists_variation1.php on line %d
130NULL
131
132--int indexed array--
133
134Warning: interface_exists() expects parameter 1 to be string, array given in %sinterface_exists_variation1.php on line %d
135NULL
136
137--associative array--
138
139Warning: interface_exists() expects parameter 1 to be string, array given in %sinterface_exists_variation1.php on line %d
140NULL
141
142--nested arrays--
143
144Warning: interface_exists() expects parameter 1 to be string, array given in %sinterface_exists_variation1.php on line %d
145NULL
146
147--uppercase NULL--
148bool(false)
149
150--lowercase null--
151bool(false)
152
153--lowercase true--
154bool(false)
155
156--lowercase false--
157bool(false)
158
159--uppercase TRUE--
160bool(false)
161
162--uppercase FALSE--
163bool(false)
164
165--empty string DQ--
166bool(false)
167
168--empty string SQ--
169bool(false)
170
171--instance of classWithToString--
172bool(false)
173
174--instance of classWithoutToString--
175
176Warning: interface_exists() expects parameter 1 to be string, object given in %sinterface_exists_variation1.php on line %d
177NULL
178
179--undefined var--
180bool(false)
181
182--unset var--
183bool(false)
184===DONE===
185