From:             deligo2003 at yahoo dot ca
Operating system: Ubuntu
PHP version:      5.2.7
PHP Bug Type:     Scripting Engine problem
Bug description:  Arrays Coerced to Objects, Property Problems

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 bug report at http://bugs.php.net/?id=46774&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46774&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46774&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46774&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46774&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46774&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46774&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46774&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46774&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46774&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46774&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46774&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46774&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46774&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46774&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46774&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46774&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46774&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46774&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46774&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46774&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46774&r=mysqlcfg

Reply via email to