#33582 [Asn->Bgs]: ArrayAccess - getOffset doesn't work

From: Date: Wed, 13 Jul 2005 09:45:50 +0000
Subject: #33582 [Asn->Bgs]: ArrayAccess - getOffset doesn't work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81798@lists.php.net to get a copy of this message
ID: 33582 Updated by: tony2001@php.net Reported By: tomas_matousek at hotmail dot com -Status: Assigned +Status: Bogus Bug Type: SPL related Operating System: WinXP PHP Version: 5.1.0b2 Assigned To: helly New Comment: Duplicate of bug #32983. Previous Comments: ------------------------------------------------------------------------ [2005-07-06 10:17:35] tomas_matousek at hotmail dot com Description: ------------ Since you fixed this issue: "Fixed inheritance check to control return by reference and pass by reference correctly (ArrayAccess can no longer support references correctly)." offsetGet doesn't work correctly not only with references. I would suggest you to change interface and require return by reference for offsetGet. This would fix also issues regarding references. Reproduce code: --------------- class C { public $x; } $z = new C; class ArrayClass implements ArrayAccess { function offsetGet($index) { global $z; $result = array("obj" => $z); return $result; } function offsetSet($index, $newval) { } function offsetExists($index) { } function offsetUnset($index) { } } $obj = new ArrayClass(); $obj["index"]["obj"]->x = 10; Expected result: ---------------- I would expect no error. The code is imho correct. Actual result: -------------- Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33582&edit=1

« previous php.bugs (#81798) next »