From: dan at yes dot lt Operating system: WinXP PHP version: 5.2.3 PHP Bug Type: SPL related Bug description: ArrayAccess::offsetExists works wrong with isset()
Description: ------------ method ArrayAccess actualy works wrong with isset()/empty()... isset()/empty() now calls only ArrayAccess::offsetExist, but should call both ArrayAccess::offsetExist and ArrayAccess::offsetGet to check if value is realy set. that's how arrays do... Reproduce code: --------------- class Test implements ArrayAccess { protected $_array = array(); protected $_count = 0; function offsetExists($offset) { return $offset >= 0 && $offset < $this->_count; } function offsetGet($offset) { return $this->_array[$offset]; } function offsetSet($offset, $value) { $this->_array[] = $value; $this->_count++; } function offsetUnset($offset) { unset($this->_array[$offset]); } } $a = new Test; $a[] = 'A'; // 0 $a[] = 10; // 1 $a[] = null; // 2 echo isset($a[0]) ? 'set' : 'unset', "\n"; echo isset($a[1]) ? 'set' : 'unset', "\n"; echo isset($a[2]) ? 'set' : 'unset', "\n"; Expected result: ---------------- set set unset Actual result: -------------- set set set -- Edit bug report at http://bugs.php.net/?id=41727&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41727&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41727&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41727&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41727&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41727&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41727&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41727&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41727&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41727&r=support Expected behavior: http://bugs.php.net/fix.php?id=41727&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41727&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41727&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41727&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41727&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41727&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41727&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41727&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41727&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41727&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41727&r=mysqlcfg