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