ID: 46774 Updated by: [email protected] Reported By: deligo2003 at yahoo dot ca -Status: Open +Status: Bogus Bug Type: Reflection related Operating System: Ubuntu PHP Version: 5.2.7 New Comment:
So this is duplicate -> Bogus.. Previous Comments: ------------------------------------------------------------------------ [2008-12-31 16:32:47] [email protected] This is a known issue, and was documented: See bug #45959 ------------------------------------------------------------------------ [2008-12-06 03:06:55] deligo2003 at yahoo dot ca When I said "except for zero." I really meant "except for an integer starting with zero". ie: 1234 will reproduce the error but 0123 will not. For negative integers -1234 will reproduce the error but -0123 will not, and neither will 0-123 Sorry for not stating this correctly in the first place. ------------------------------------------------------------------------ [2008-12-06 03:02:47] deligo2003 at yahoo dot ca Description: ------------ var_export(), get_object_vars(), and ReflectionObject do not recognize or handle object properties correctly that are coerced from a numerically indexed array or an array with string keys of any integer except for zero. ie: (object)array(1,2,3,4); ie: (object)array('1' => 1, '-5' => 2, '3' => 3, '-10' => 4); Values seem to have no effect. There may be other functions/classes that do not handle these types of property names correctly. The samples included only show the results of ReflectionObject::getProperties(), but also functions like ReflectionObject::hasProperty() incorrectly returns false, for example. Reproduce code: --------------- <?php $a = (object)array(1, 2, 3, 4); echo '<pre>'; var_dump($a); print_r($a); var_export($a); print_r(get_object_vars($a)); $r = new ReflectionObject($a); print_r($r->getProperties()); ?> Expected result: ---------------- var_export($a); output: stdClass::__set_state(array(1,2,3,4)) print_r(get_object_vars($a)); output: Array([0]=>1,[1]=>2,[2]=>3,[3]=>4) print_r($r->getProperties()); output: Array( [0]=>ReflectionProperty Object ( [name]=>0 [class]=>stdClass ) ... and so on up to [3] ) Actual result: -------------- var_export($a); output: stdClass::__set_state(array()) print_r(get_object_vars($a)); output: Array() print_r($r->getProperties()); output: note: this result varies ie1: Array ( [0] => ReflectionProperty Object ( [name] => â.C6ßÔXlé¤Ðø*ºv\ì#II [class] => stdClass ) [1] => ReflectionProperty Object ( [name] => M¨¾FÏXlé¤Ðø [class] => stdClass ) ) ie2: Array ( [0] => ReflectionProperty Object ( [name] => F7¯5h¡ þoMWM=[*"ùI [class] => stdClass ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46774&edit=1
