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