ID:               46774
 User updated by:  deligo2003 at yahoo dot ca
 Reported By:      deligo2003 at yahoo dot ca
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: Ubuntu
 PHP Version:      5.2.7
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[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] => â.Cˆ6ßÔXlé¤Ð‹øŒ*ºv\ì#IœI
            [class] => stdClass
        )

    [1] => ReflectionProperty Object
        (
            [name] => M¨¾FÏXlé¤Ð‹øŒ
            [class] => stdClass
        )

)

ie2:

Array
(
    [0] => ReflectionProperty Object
        (
            [name] => F7—¯5žh¡ þ”oMWM=[‘*‹"ùI
            [class] => stdClass
        )

)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46774&edit=1

Reply via email to