1ee0f7bc0SRobin Fernandes--TEST--
204145dc2SVeres LajosTest class_exists() function : usage variations  - unexpected types for argument 2
3ee0f7bc0SRobin Fernandes--FILE--
4ee0f7bc0SRobin Fernandes<?php
5ee0f7bc0SRobin Fernandes/* Prototype  : proto bool class_exists(string classname [, bool autoload])
6782352c5SPeter Kokot * Description: Checks if the class exists
7ee0f7bc0SRobin Fernandes * Source code: Zend/zend_builtin_functions.c
8782352c5SPeter Kokot * Alias to functions:
9ee0f7bc0SRobin Fernandes */
10ee0f7bc0SRobin Fernandes
11162aa1a5SNikita Popovspl_autoload_register(function ($className) {
12162aa1a5SNikita Popov	echo "In autoload($className)\n";
13162aa1a5SNikita Popov});
14ee0f7bc0SRobin Fernandes
15ee0f7bc0SRobin Fernandesfunction test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
16ee0f7bc0SRobin Fernandes	echo "Error: $err_no - $err_msg, $filename($linenum)\n";
17ee0f7bc0SRobin Fernandes}
18ee0f7bc0SRobin Fernandesset_error_handler('test_error_handler');
19ee0f7bc0SRobin Fernandes
20ee0f7bc0SRobin Fernandesecho "*** Testing class_exists() : usage variations ***\n";
21ee0f7bc0SRobin Fernandes
22ee0f7bc0SRobin Fernandes// Initialise function arguments not being substituted (if any)
23ee0f7bc0SRobin Fernandes$classname = 'string_val';
24ee0f7bc0SRobin Fernandes
25ee0f7bc0SRobin Fernandes//get an unset variable
26ee0f7bc0SRobin Fernandes$unset_var = 10;
27ee0f7bc0SRobin Fernandesunset ($unset_var);
28ee0f7bc0SRobin Fernandes
29ee0f7bc0SRobin Fernandes//array of values to iterate over
30ee0f7bc0SRobin Fernandes$values = array(
31ee0f7bc0SRobin Fernandes
32ee0f7bc0SRobin Fernandes      // int data
33ee0f7bc0SRobin Fernandes      0,
34ee0f7bc0SRobin Fernandes      1,
35ee0f7bc0SRobin Fernandes      12345,
36ee0f7bc0SRobin Fernandes      -2345,
37ee0f7bc0SRobin Fernandes
38ee0f7bc0SRobin Fernandes      // float data
39ee0f7bc0SRobin Fernandes      10.5,
40ee0f7bc0SRobin Fernandes      -10.5,
41ee0f7bc0SRobin Fernandes      10.1234567e10,
42ee0f7bc0SRobin Fernandes      10.7654321E-10,
43ee0f7bc0SRobin Fernandes      .5,
44ee0f7bc0SRobin Fernandes
45ee0f7bc0SRobin Fernandes      // array data
46ee0f7bc0SRobin Fernandes      array(),
47ee0f7bc0SRobin Fernandes      array(0),
48ee0f7bc0SRobin Fernandes      array(1),
49ee0f7bc0SRobin Fernandes      array(1, 2),
50ee0f7bc0SRobin Fernandes      array('color' => 'red', 'item' => 'pen'),
51ee0f7bc0SRobin Fernandes
52ee0f7bc0SRobin Fernandes      // null data
53ee0f7bc0SRobin Fernandes      NULL,
54ee0f7bc0SRobin Fernandes      null,
55ee0f7bc0SRobin Fernandes
56ee0f7bc0SRobin Fernandes      // boolean data
57ee0f7bc0SRobin Fernandes      true,
58ee0f7bc0SRobin Fernandes      false,
59ee0f7bc0SRobin Fernandes      TRUE,
60ee0f7bc0SRobin Fernandes      FALSE,
61ee0f7bc0SRobin Fernandes
62ee0f7bc0SRobin Fernandes      // empty data
63ee0f7bc0SRobin Fernandes      "",
64ee0f7bc0SRobin Fernandes      '',
65ee0f7bc0SRobin Fernandes
66ee0f7bc0SRobin Fernandes      // string data
67ee0f7bc0SRobin Fernandes      "string",
68ee0f7bc0SRobin Fernandes      'string',
69ee0f7bc0SRobin Fernandes
70ee0f7bc0SRobin Fernandes      // object data
71ee0f7bc0SRobin Fernandes      new stdclass(),
72ee0f7bc0SRobin Fernandes
73ee0f7bc0SRobin Fernandes      // undefined data
74ee0f7bc0SRobin Fernandes      $undefined_var,
75ee0f7bc0SRobin Fernandes
76ee0f7bc0SRobin Fernandes      // unset data
77ee0f7bc0SRobin Fernandes      $unset_var,
78ee0f7bc0SRobin Fernandes);
79ee0f7bc0SRobin Fernandes
80ee0f7bc0SRobin Fernandes// loop through each element of the array for autoload
81ee0f7bc0SRobin Fernandes
82ee0f7bc0SRobin Fernandesforeach($values as $value) {
83ee0f7bc0SRobin Fernandes      echo "\nArg value $value \n";
84ee0f7bc0SRobin Fernandes      var_dump( class_exists($classname, $value) );
85ee0f7bc0SRobin Fernandes};
86ee0f7bc0SRobin Fernandes
87ee0f7bc0SRobin Fernandesecho "Done";
88ee0f7bc0SRobin Fernandes?>
89ee0f7bc0SRobin Fernandes--EXPECTF--
90ee0f7bc0SRobin Fernandes*** Testing class_exists() : usage variations ***
91ee0f7bc0SRobin FernandesError: 8 - Undefined variable: undefined_var, %s(71)
92ee0f7bc0SRobin FernandesError: 8 - Undefined variable: unset_var, %s(74)
93ee0f7bc0SRobin Fernandes
94ee0f7bc0SRobin FernandesArg value 0 
95ee0f7bc0SRobin Fernandesbool(false)
96ee0f7bc0SRobin Fernandes
97ee0f7bc0SRobin FernandesArg value 1 
98162aa1a5SNikita PopovIn autoload(string_val)
99ee0f7bc0SRobin Fernandesbool(false)
100ee0f7bc0SRobin Fernandes
101ee0f7bc0SRobin FernandesArg value 12345 
102162aa1a5SNikita PopovIn autoload(string_val)
103ee0f7bc0SRobin Fernandesbool(false)
104ee0f7bc0SRobin Fernandes
105ee0f7bc0SRobin FernandesArg value -2345 
106162aa1a5SNikita PopovIn autoload(string_val)
107ee0f7bc0SRobin Fernandesbool(false)
108ee0f7bc0SRobin Fernandes
109ee0f7bc0SRobin FernandesArg value 10.5 
110162aa1a5SNikita PopovIn autoload(string_val)
111ee0f7bc0SRobin Fernandesbool(false)
112ee0f7bc0SRobin Fernandes
113ee0f7bc0SRobin FernandesArg value -10.5 
114162aa1a5SNikita PopovIn autoload(string_val)
115ee0f7bc0SRobin Fernandesbool(false)
116ee0f7bc0SRobin Fernandes
117ee0f7bc0SRobin FernandesArg value 101234567000 
118162aa1a5SNikita PopovIn autoload(string_val)
119ee0f7bc0SRobin Fernandesbool(false)
120ee0f7bc0SRobin Fernandes
121ee0f7bc0SRobin FernandesArg value 1.07654321E-9 
122162aa1a5SNikita PopovIn autoload(string_val)
123ee0f7bc0SRobin Fernandesbool(false)
124ee0f7bc0SRobin Fernandes
125ee0f7bc0SRobin FernandesArg value 0.5 
126162aa1a5SNikita PopovIn autoload(string_val)
127ee0f7bc0SRobin Fernandesbool(false)
128d81ea16eSStanislav MalyshevError: 8 - Array to string conversion, %sclass_exists_variation_002.php(%d)
129ee0f7bc0SRobin Fernandes
130ee0f7bc0SRobin FernandesArg value Array 
131fef879a2SGabriel CarusoError: 2 - class_exists() expects parameter 2 to be bool, array given, %s(81)
132ee0f7bc0SRobin FernandesNULL
133d81ea16eSStanislav MalyshevError: 8 - Array to string conversion, %sclass_exists_variation_002.php(%d)
134ee0f7bc0SRobin Fernandes
135ee0f7bc0SRobin FernandesArg value Array 
136fef879a2SGabriel CarusoError: 2 - class_exists() expects parameter 2 to be bool, array given, %s(81)
137ee0f7bc0SRobin FernandesNULL
138d81ea16eSStanislav MalyshevError: 8 - Array to string conversion, %sclass_exists_variation_002.php(%d)
139ee0f7bc0SRobin Fernandes
140ee0f7bc0SRobin FernandesArg value Array 
141fef879a2SGabriel CarusoError: 2 - class_exists() expects parameter 2 to be bool, array given, %s(81)
142ee0f7bc0SRobin FernandesNULL
143d81ea16eSStanislav MalyshevError: 8 - Array to string conversion, %sclass_exists_variation_002.php(%d)
144ee0f7bc0SRobin Fernandes
145ee0f7bc0SRobin FernandesArg value Array 
146fef879a2SGabriel CarusoError: 2 - class_exists() expects parameter 2 to be bool, array given, %s(81)
147ee0f7bc0SRobin FernandesNULL
148d81ea16eSStanislav MalyshevError: 8 - Array to string conversion, %sclass_exists_variation_002.php(%d)
149ee0f7bc0SRobin Fernandes
150ee0f7bc0SRobin FernandesArg value Array 
151fef879a2SGabriel CarusoError: 2 - class_exists() expects parameter 2 to be bool, array given, %s(81)
152ee0f7bc0SRobin FernandesNULL
153ee0f7bc0SRobin Fernandes
154ee0f7bc0SRobin FernandesArg value  
155ee0f7bc0SRobin Fernandesbool(false)
156ee0f7bc0SRobin Fernandes
157ee0f7bc0SRobin FernandesArg value  
158ee0f7bc0SRobin Fernandesbool(false)
159ee0f7bc0SRobin Fernandes
160ee0f7bc0SRobin FernandesArg value 1 
161162aa1a5SNikita PopovIn autoload(string_val)
162ee0f7bc0SRobin Fernandesbool(false)
163ee0f7bc0SRobin Fernandes
164ee0f7bc0SRobin FernandesArg value  
165ee0f7bc0SRobin Fernandesbool(false)
166ee0f7bc0SRobin Fernandes
167ee0f7bc0SRobin FernandesArg value 1 
168162aa1a5SNikita PopovIn autoload(string_val)
169ee0f7bc0SRobin Fernandesbool(false)
170ee0f7bc0SRobin Fernandes
171ee0f7bc0SRobin FernandesArg value  
172ee0f7bc0SRobin Fernandesbool(false)
173ee0f7bc0SRobin Fernandes
174ee0f7bc0SRobin FernandesArg value  
175ee0f7bc0SRobin Fernandesbool(false)
176ee0f7bc0SRobin Fernandes
177ee0f7bc0SRobin FernandesArg value  
178ee0f7bc0SRobin Fernandesbool(false)
179ee0f7bc0SRobin Fernandes
180ee0f7bc0SRobin FernandesArg value string 
181162aa1a5SNikita PopovIn autoload(string_val)
182ee0f7bc0SRobin Fernandesbool(false)
183ee0f7bc0SRobin Fernandes
184ee0f7bc0SRobin FernandesArg value string 
185162aa1a5SNikita PopovIn autoload(string_val)
186ee0f7bc0SRobin Fernandesbool(false)
187ee0f7bc0SRobin FernandesError: 4096 - Object of class stdClass could not be converted to string, %s(80)
188ee0f7bc0SRobin Fernandes
189ee0f7bc0SRobin FernandesArg value  
190fef879a2SGabriel CarusoError: 2 - class_exists() expects parameter 2 to be bool, object given, %s(81)
191ee0f7bc0SRobin FernandesNULL
192ee0f7bc0SRobin Fernandes
193ee0f7bc0SRobin FernandesArg value  
194ee0f7bc0SRobin Fernandesbool(false)
195ee0f7bc0SRobin Fernandes
196ee0f7bc0SRobin FernandesArg value  
197ee0f7bc0SRobin Fernandesbool(false)
198162aa1a5SNikita PopovDone
199