1ee0f7bc0SRobin Fernandes--TEST--
204145dc2SVeres LajosTest class_exists() function : usage variations - unexpected types for argument 1
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$autoload = true;
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      // object data
67ee0f7bc0SRobin Fernandes      new stdclass(),
68ee0f7bc0SRobin Fernandes
69ee0f7bc0SRobin Fernandes      // undefined data
70ee0f7bc0SRobin Fernandes      $undefined_var,
71ee0f7bc0SRobin Fernandes
72ee0f7bc0SRobin Fernandes      // unset data
73ee0f7bc0SRobin Fernandes      $unset_var,
74ee0f7bc0SRobin Fernandes);
75ee0f7bc0SRobin Fernandes
76ee0f7bc0SRobin Fernandes// loop through each element of the array for classname
77ee0f7bc0SRobin Fernandes
78ee0f7bc0SRobin Fernandesforeach($values as $value) {
79ee0f7bc0SRobin Fernandes      echo "\nArg value $value \n";
80ee0f7bc0SRobin Fernandes      var_dump( class_exists($value, $autoload) );
81ee0f7bc0SRobin Fernandes};
82ee0f7bc0SRobin Fernandes
83ee0f7bc0SRobin Fernandesecho "Done";
84ee0f7bc0SRobin Fernandes?>
85ee0f7bc0SRobin Fernandes--EXPECTF--
86ee0f7bc0SRobin Fernandes*** Testing class_exists() : usage variations ***
87ee0f7bc0SRobin FernandesError: 8 - Undefined variable: undefined_var, %s(67)
88ee0f7bc0SRobin FernandesError: 8 - Undefined variable: unset_var, %s(70)
89ee0f7bc0SRobin Fernandes
90ee0f7bc0SRobin FernandesArg value 0 
91162aa1a5SNikita PopovIn autoload(0)
92ee0f7bc0SRobin Fernandesbool(false)
93ee0f7bc0SRobin Fernandes
94ee0f7bc0SRobin FernandesArg value 1 
95162aa1a5SNikita PopovIn autoload(1)
96ee0f7bc0SRobin Fernandesbool(false)
97ee0f7bc0SRobin Fernandes
98ee0f7bc0SRobin FernandesArg value 12345 
99162aa1a5SNikita PopovIn autoload(12345)
100ee0f7bc0SRobin Fernandesbool(false)
101ee0f7bc0SRobin Fernandes
102ee0f7bc0SRobin FernandesArg value -2345 
103ee0f7bc0SRobin Fernandesbool(false)
104ee0f7bc0SRobin Fernandes
105ee0f7bc0SRobin FernandesArg value 10.5 
106ee0f7bc0SRobin Fernandesbool(false)
107ee0f7bc0SRobin Fernandes
108ee0f7bc0SRobin FernandesArg value -10.5 
109ee0f7bc0SRobin Fernandesbool(false)
110ee0f7bc0SRobin Fernandes
111ee0f7bc0SRobin FernandesArg value 101234567000 
112162aa1a5SNikita PopovIn autoload(101234567000)
113ee0f7bc0SRobin Fernandesbool(false)
114ee0f7bc0SRobin Fernandes
115ee0f7bc0SRobin FernandesArg value 1.07654321E-9 
116ee0f7bc0SRobin Fernandesbool(false)
117ee0f7bc0SRobin Fernandes
118ee0f7bc0SRobin FernandesArg value 0.5 
119ee0f7bc0SRobin Fernandesbool(false)
120d81ea16eSStanislav MalyshevError: 8 - Array to string conversion, %sclass_exists_variation_001.php(%d)
121ee0f7bc0SRobin Fernandes
122ee0f7bc0SRobin FernandesArg value Array 
123ee0f7bc0SRobin FernandesError: 2 - class_exists() expects parameter 1 to be string, array given, %s(77)
124ee0f7bc0SRobin FernandesNULL
125d81ea16eSStanislav MalyshevError: 8 - Array to string conversion, %sclass_exists_variation_001.php(%d)
126ee0f7bc0SRobin Fernandes
127ee0f7bc0SRobin FernandesArg value Array 
128ee0f7bc0SRobin FernandesError: 2 - class_exists() expects parameter 1 to be string, array given, %s(77)
129ee0f7bc0SRobin FernandesNULL
130d81ea16eSStanislav MalyshevError: 8 - Array to string conversion, %sclass_exists_variation_001.php(%d)
131ee0f7bc0SRobin Fernandes
132ee0f7bc0SRobin FernandesArg value Array 
133ee0f7bc0SRobin FernandesError: 2 - class_exists() expects parameter 1 to be string, array given, %s(77)
134ee0f7bc0SRobin FernandesNULL
135d81ea16eSStanislav MalyshevError: 8 - Array to string conversion, %sclass_exists_variation_001.php(%d)
136ee0f7bc0SRobin Fernandes
137ee0f7bc0SRobin FernandesArg value Array 
138ee0f7bc0SRobin FernandesError: 2 - class_exists() expects parameter 1 to be string, array given, %s(77)
139ee0f7bc0SRobin FernandesNULL
140d81ea16eSStanislav MalyshevError: 8 - Array to string conversion, %sclass_exists_variation_001.php(%d)
141ee0f7bc0SRobin Fernandes
142ee0f7bc0SRobin FernandesArg value Array 
143ee0f7bc0SRobin FernandesError: 2 - class_exists() expects parameter 1 to be string, array given, %s(77)
144ee0f7bc0SRobin FernandesNULL
145ee0f7bc0SRobin Fernandes
146ee0f7bc0SRobin FernandesArg value  
147ee0f7bc0SRobin Fernandesbool(false)
148ee0f7bc0SRobin Fernandes
149ee0f7bc0SRobin FernandesArg value  
150ee0f7bc0SRobin Fernandesbool(false)
151ee0f7bc0SRobin Fernandes
152ee0f7bc0SRobin FernandesArg value 1 
153162aa1a5SNikita PopovIn autoload(1)
154ee0f7bc0SRobin Fernandesbool(false)
155ee0f7bc0SRobin Fernandes
156ee0f7bc0SRobin FernandesArg value  
157ee0f7bc0SRobin Fernandesbool(false)
158ee0f7bc0SRobin Fernandes
159ee0f7bc0SRobin FernandesArg value 1 
160162aa1a5SNikita PopovIn autoload(1)
161ee0f7bc0SRobin Fernandesbool(false)
162ee0f7bc0SRobin Fernandes
163ee0f7bc0SRobin FernandesArg value  
164ee0f7bc0SRobin Fernandesbool(false)
165ee0f7bc0SRobin Fernandes
166ee0f7bc0SRobin FernandesArg value  
167ee0f7bc0SRobin Fernandesbool(false)
168ee0f7bc0SRobin Fernandes
169ee0f7bc0SRobin FernandesArg value  
170ee0f7bc0SRobin Fernandesbool(false)
171ee0f7bc0SRobin FernandesError: 4096 - Object of class stdClass could not be converted to string, %s(76)
172ee0f7bc0SRobin Fernandes
173ee0f7bc0SRobin FernandesArg value  
174ee0f7bc0SRobin FernandesError: 2 - class_exists() expects parameter 1 to be string, object given, %s(77)
175ee0f7bc0SRobin FernandesNULL
176ee0f7bc0SRobin Fernandes
177ee0f7bc0SRobin FernandesArg value  
178ee0f7bc0SRobin Fernandesbool(false)
179ee0f7bc0SRobin Fernandes
180ee0f7bc0SRobin FernandesArg value  
181ee0f7bc0SRobin Fernandesbool(false)
182162aa1a5SNikita PopovDone
183