ID: 38049 Updated by: [EMAIL PROTECTED] Reported By: vma1 at abv dot bg -Status: Open +Status: Assigned Bug Type: Arrays related Operating System: Linux PHP Version: 5CVS-2006-07-09 (snap) -Assigned To: +Assigned To: bjori New Comment:
Yeah, you're right it works fine in 5.1.4, but new arginfo causes this in 5.2. Hannes, are you sure arginfo for array_key_exists() is correct? I don't see any reasons to use references there, though. This patch fixes it for me: Index: ext/standard/basic_functions.c =================================================================== RCS file: /repository/php-src/ext/standard/basic_functions.c,v retrieving revision 1.725.2.31.2.15 diff -u -p -d -r1.725.2.31.2.15 basic_functions.c --- ext/standard/basic_functions.c 2 Jul 2006 00:11:05 -0000 1.725.2.31.2.15 +++ ext/standard/basic_functions.c 9 Jul 2006 19:51:24 -0000 @@ -655,9 +655,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_array_map ZEND_END_ARG_INFO() static -ZEND_BEGIN_ARG_INFO(arginfo_array_key_exists, ZEND_SEND_PREFER_REF) - ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, key) - ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, search) +ZEND_BEGIN_ARG_INFO(arginfo_array_key_exists, 0) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, search) ZEND_END_ARG_INFO() static Previous Comments: ------------------------------------------------------------------------ [2006-07-09 16:43:06] vma1 at abv dot bg 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 this bug report at http://bugs.php.net/?id=38049&edit=1