ID: 41727 Updated by: [EMAIL PROTECTED] Reported By: dan at yes dot lt -Status: Open +Status: Bogus Bug Type: SPL related Operating System: WinXP PHP Version: 5.2.3 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You can call offsetGet() yourself if you want. Previous Comments: ------------------------------------------------------------------------ [2007-06-18 13:00:54] dan at yes dot lt 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 this bug report at http://bugs.php.net/?id=41727&edit=1