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