|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-07-09 19:52 UTC] tony2001@php.net
[2006-07-12 20:23 UTC] bjori@php.net
[2006-09-22 08:53 UTC] bjori@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 11:00:01 2025 UTC |
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