#45622 [NEW]: isset($arrayObject->p) misbehaves with ArrayObject::ARRAY_AS_PROPS set

From: Date: Fri, 25 Jul 2008 08:59:15 +0000
Subject: #45622 [NEW]: isset($arrayObject->p) misbehaves with ArrayObject::ARRAY_AS_PROPS set
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-127255@lists.php.net to get a copy of this message
From: robin_fernandes at uk dot ibm dot com Operating system: all PHP version: 5.3CVS-2008-07-25 (CVS) PHP Bug Type: SPL related Bug description: isset($arrayObject->p) misbehaves with ArrayObject::ARRAY_AS_PROPS set Description: ------------ If an instance of ArrayObject $ao has flag ArrayObject::ARRAY_AS_PROPS set, $ao->p will access element p of the underlying storage array - but only if no real property p exists on $ao. If a real property p does exist, it will access that property as if the flag were not set. This works correctly with read, write and unset, but not with isset: when a real property p exists, isset($ao->p) always returns false . Reproduce code: --------------- <?php class C extends ArrayObject { public $p = 'object property'; } $ao = new C(array('p'=>'array element')); $ao->setFlags(ArrayObject::ARRAY_AS_PROPS); echo "\n--> Access the real property:\n"; var_dump(isset($ao->p)); // bug var_dump($ao->p); echo "\n--> Remove the real property and access the array element:\n"; unset($ao->p); var_dump(isset($ao->p)); var_dump($ao->p); echo "\n--> Remove the array element and try access again:\n"; unset($ao->p); var_dump(isset($ao->p)); var_dump($ao->p); ?> Expected result: ---------------- --> Access the real property: bool(true) string(15) "object property" --> Remove the real property and access the array element: bool(true) string(13) "array element" --> Remove the array element and try access again: bool(false) Notice: Undefined index: p in %s on line 21 NULL Actual result: -------------- --> Access the real property: bool(false) string(15) "object property" --> Remove the real property and access the array element: bool(true) string(13) "array element" --> Remove the array element and try access again: bool(false) Notice: Undefined index: p in %s on line 21 NULL -- Edit bug report at http://bugs.php.net/?id=45622&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45622&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45622&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45622&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45622&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45622&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45622&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45622&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45622&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45622&r=support Expected behavior: http://bugs.php.net/fix.php?id=45622&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45622&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45622&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45622&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45622&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45622&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45622&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45622&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45622&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45622&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45622&r=mysqlcfg

« previous php.bugs (#127255) next »