From: vma1 at abv dot bg Operating system: Linux PHP version: 5CVS-2006-07-09 (snap) PHP Bug Type: Arrays related Bug description: A problem with values returned by ArrayAccess::offsetGet()
Description: ------------ Values returned by ArrayAccess::offsetGet() cannot be used as a search key in a call to array_key_exists(). It looks like for some reason the scripting engine requires that the first argument of array_key_exists() is writable, which conflicts with the documented prototype of array_key_exists(). The sample code works fine with PHP 5.1.4 so it is a problem introduced in PHP 5.2. Reproduce code: --------------- <?php class array_obj implements ArrayAccess { public function offsetExists ($index) {return (true);} public function offsetGet ($index) {return (5);} public function offsetSet ($index, $value) {} public function offsetUnset ($index) {} } $obj = new array_obj (); array_key_exists ($obj [0], array ("a", "b", "c")); ?> Expected result: ---------------- The program should terminate with no output at all. Actual result: -------------- Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in /archive/error.php on line 14 -- Edit bug report at http://bugs.php.net/?id=38049&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38049&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38049&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38049&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38049&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38049&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38049&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38049&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38049&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38049&r=support Expected behavior: http://bugs.php.net/fix.php?id=38049&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38049&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38049&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38049&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38049&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38049&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38049&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38049&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38049&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38049&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38049&r=mysqlcfg