From: serovov at gmail dot com Operating system: ANY PHP version: 5.2.6 PHP Bug Type: *General Issues Bug description: Object(with numeric named vars) -> array = isset(); bug;
Description: ------------ When object has numeric named vars, and we cast this object to array. we have a problem with isset() checks; PS. if is not a bug, please, explain why. Reproduce code: --------------- <?php class buggy { public function __construct(array $data) { foreach ($data as $key => $value) { $this->$key = $value; } } } function test_buggy($buggy) { $kbuggy = array_keys($buggy); var_dump( $buggy, $kbuggy, isset($buggy[current($kbuggy)]), isset($buggy[$kbuggy[0]]), isset($buggy[$kbuggy[1]]), isset($buggy[$kbuggy[2]]) ); } $array = array( 'a', 'b', 'c', ); $buggy = new buggy($array); $buggy = (array) $buggy; echo "Test #1: "; test_buggy($buggy); echo "Test #2: "; $buggy = unserialize(serialize($buggy)); test_buggy($buggy); ?> Expected result: ---------------- Test #1: array '0' => string 'a' (length=1) '1' => string 'b' (length=1) '2' => string 'c' (length=1) array 0 => string '0' (length=1) 1 => string '1' (length=1) 2 => string '2' (length=1) boolean false boolean false boolean false boolean false Test #2: array 0 => string 'a' (length=1) 1 => string 'b' (length=1) 2 => string 'c' (length=1) array 0 => int 0 1 => int 1 2 => int 2 boolean true boolean true boolean true boolean true Actual result: -------------- Test #1: array 0 => string 'a' (length=1) 1 => string 'b' (length=1) 2 => string 'c' (length=1) array 0 => int 0 1 => int 1 2 => int 2 boolean true boolean true boolean true boolean true Test #2: array 0 => string 'a' (length=1) 1 => string 'b' (length=1) 2 => string 'c' (length=1) array 0 => int 0 1 => int 1 2 => int 2 boolean true boolean true boolean true boolean true -- Edit bug report at http://bugs.php.net/?id=46530&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46530&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46530&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46530&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46530&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46530&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=46530&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46530&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46530&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46530&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46530&r=support Expected behavior: http://bugs.php.net/fix.php?id=46530&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46530&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46530&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46530&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46530&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46530&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46530&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46530&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46530&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46530&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46530&r=mysqlcfg