Annotation of embedaddon/php/ext/standard/tests/class_object/get_class_methods_variation_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test get_class_methods() function : usage variations - unexpected types
3: --FILE--
4: <?php
5: /* Prototype : proto array get_class_methods(mixed class)
6: * Description: Returns an array of method names for class or class instance.
7: * Source code: Zend/zend_builtin_functions.c
8: * Alias to functions:
9: */
10:
11:
12: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
13: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
14: }
15: set_error_handler('test_error_handler');
16:
17: echo "*** Testing get_class_methods() : usage variations ***\n";
18:
19: // Initialise function arguments not being substituted (if any)
20:
21: //get an unset variable
22: $unset_var = 10;
23: unset ($unset_var);
24:
25: //array of values to iterate over
26: $values = array(
27:
28: // int data
29: 0,
30: 1,
31: 12345,
32: -2345,
33:
34: // float data
35: 10.5,
36: -10.5,
37: 10.1234567e10,
38: 10.7654321E-10,
39: .5,
40:
41: // array data
42: array(),
43: array(0),
44: array(1),
45: array(1, 2),
46: array('color' => 'red', 'item' => 'pen'),
47:
48: // null data
49: NULL,
50: null,
51:
52: // boolean data
53: true,
54: false,
55: TRUE,
56: FALSE,
57:
58: // empty data
59: "",
60: '',
61:
62: // string data
63: "string",
64: 'string',
65:
66: // object data
67: new stdclass(),
68:
69: // undefined data
70: $undefined_var,
71:
72: // unset data
73: $unset_var,
74: );
75:
76: // loop through each element of the array for class
77:
78: foreach($values as $value) {
79: echo "\nArg value $value \n";
80: var_dump( get_class_methods($value) );
81: };
82:
83: echo "Done";
84: ?>
85: --EXPECTF--
86: *** Testing get_class_methods() : usage variations ***
87: Error: 8 - Undefined variable: undefined_var, %s(67)
88: Error: 8 - Undefined variable: unset_var, %s(70)
89:
90: Arg value 0
91: NULL
92:
93: Arg value 1
94: NULL
95:
96: Arg value 12345
97: NULL
98:
99: Arg value -2345
100: NULL
101:
102: Arg value 10.5
103: NULL
104:
105: Arg value -10.5
106: NULL
107:
108: Arg value 101234567000
109: NULL
110:
111: Arg value 1.07654321E-9
112: NULL
113:
114: Arg value 0.5
115: NULL
116:
117: Arg value Array
118: NULL
119:
120: Arg value Array
121: NULL
122:
123: Arg value Array
124: NULL
125:
126: Arg value Array
127: NULL
128:
129: Arg value Array
130: NULL
131:
132: Arg value
133: NULL
134:
135: Arg value
136: NULL
137:
138: Arg value 1
139: NULL
140:
141: Arg value
142: NULL
143:
144: Arg value 1
145: NULL
146:
147: Arg value
148: NULL
149:
150: Arg value
151: NULL
152:
153: Arg value
154: NULL
155:
156: Arg value string
157: NULL
158:
159: Arg value string
160: NULL
161: Error: 4096 - Object of class stdClass could not be converted to string, %s(76)
162:
163: Arg value
164: array(0) {
165: }
166:
167: Arg value
168: NULL
169:
170: Arg value
171: NULL
172: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>