1--TEST-- 2Test get_class() function : usage variations - passing unexpected types. 3--FILE-- 4<?php 5echo "*** Testing get_class() : usage variations ***\n"; 6 7// Note: basic use cases in Zend/tests/009.phpt 8 9//get an unset variable 10$unset_var = 10; 11unset ($unset_var); 12 13//array of values to iterate over 14$values = array( 15 16 // int data 17 0, 18 1, 19 12345, 20 -2345, 21 22 // float data 23 10.5, 24 -10.5, 25 10.1234567e10, 26 10.7654321E-10, 27 .5, 28 29 // array data 30 array(), 31 array(0), 32 array(1), 33 array(1, 2), 34 array('color' => 'red', 'item' => 'pen'), 35 36 // null data 37 NULL, 38 null, 39 40 // boolean data 41 true, 42 false, 43 TRUE, 44 FALSE, 45 46 // empty data 47 "", 48 '', 49 50 // string data 51 "string", 52 'string', 53 54 // undefined data 55 $undefined_var, 56 57 // unset data 58 $unset_var, 59); 60 61// loop through each element of the array for object 62 63foreach($values as $value) { 64 echo @"\nArg value: $value (type: " . gettype($value) . ")\n"; 65 try { 66 var_dump( get_class($value) ); 67 } catch (TypeError $e) { 68 echo $e->getMessage(), "\n"; 69 } 70}; 71 72echo "Done"; 73?> 74--EXPECTF-- 75*** Testing get_class() : usage variations *** 76 77Warning: Undefined variable $undefined_var in %s on line %d 78 79Warning: Undefined variable $unset_var in %s on line %d 80 81Arg value: 0 (type: integer) 82get_class(): Argument #1 ($object) must be of type object, int given 83 84Arg value: 1 (type: integer) 85get_class(): Argument #1 ($object) must be of type object, int given 86 87Arg value: 12345 (type: integer) 88get_class(): Argument #1 ($object) must be of type object, int given 89 90Arg value: -2345 (type: integer) 91get_class(): Argument #1 ($object) must be of type object, int given 92 93Arg value: 10.5 (type: double) 94get_class(): Argument #1 ($object) must be of type object, float given 95 96Arg value: -10.5 (type: double) 97get_class(): Argument #1 ($object) must be of type object, float given 98 99Arg value: 101234567000 (type: double) 100get_class(): Argument #1 ($object) must be of type object, float given 101 102Arg value: 1.07654321E-9 (type: double) 103get_class(): Argument #1 ($object) must be of type object, float given 104 105Arg value: 0.5 (type: double) 106get_class(): Argument #1 ($object) must be of type object, float given 107 108Arg value: Array (type: array) 109get_class(): Argument #1 ($object) must be of type object, array given 110 111Arg value: Array (type: array) 112get_class(): Argument #1 ($object) must be of type object, array given 113 114Arg value: Array (type: array) 115get_class(): Argument #1 ($object) must be of type object, array given 116 117Arg value: Array (type: array) 118get_class(): Argument #1 ($object) must be of type object, array given 119 120Arg value: Array (type: array) 121get_class(): Argument #1 ($object) must be of type object, array given 122 123Arg value: (type: NULL) 124get_class(): Argument #1 ($object) must be of type object, null given 125 126Arg value: (type: NULL) 127get_class(): Argument #1 ($object) must be of type object, null given 128 129Arg value: 1 (type: boolean) 130get_class(): Argument #1 ($object) must be of type object, true given 131 132Arg value: (type: boolean) 133get_class(): Argument #1 ($object) must be of type object, false given 134 135Arg value: 1 (type: boolean) 136get_class(): Argument #1 ($object) must be of type object, true given 137 138Arg value: (type: boolean) 139get_class(): Argument #1 ($object) must be of type object, false given 140 141Arg value: (type: string) 142get_class(): Argument #1 ($object) must be of type object, string given 143 144Arg value: (type: string) 145get_class(): Argument #1 ($object) must be of type object, string given 146 147Arg value: string (type: string) 148get_class(): Argument #1 ($object) must be of type object, string given 149 150Arg value: string (type: string) 151get_class(): Argument #1 ($object) must be of type object, string given 152 153Arg value: (type: NULL) 154get_class(): Argument #1 ($object) must be of type object, null given 155 156Arg value: (type: NULL) 157get_class(): Argument #1 ($object) must be of type object, null given 158Done 159