From: vma1 at abv dot bg
Operating system: Linux
PHP version: 5.1.0b2
PHP Bug Type: Class/Object related
Bug description: Cannot modify arrays returned by ArrayAccess::offsetGet()
Description:
------------
It is not possible to modify an element of an array returned by
ArrayAccess::offsetGet(). Also the error message suggests that offsetGet()
should return a reference but it is not possible due to the offsetGet()
original declaration.
Reproduce code:
---------------
<?
class obj_array implements ArrayAccess
{
private $array;
public function __construct ($array)
{
$this->array = $array;
}
public function offsetExists ($index)
{
return (array_key_exists ($index, $this->array));
}
public function offsetGet ($index)
{
return ($this->array [$index]);
}
public function offsetSet ($index, $value)
{
$this->array [$index] = $value;
}
public function offsetUnset ($index)
{
unset ($this->array [$index]);
}
}
$obj = new obj_array (array ("index_1" => array ("index_2" => 123)));
$obj ["index_1"]["index_2"] = 456;
?>
Expected result:
----------------
Nothing should be displayed when the code is run.
Actual result:
--------------
Fatal error: Objects used as arrays in post/pre increment/decrement must
return values by reference in /archive/try.php on line 33
--
Edit bug report at http://bugs.php.net/?id=33645&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33645&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33645&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33645&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33645&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33645&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33645&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33645&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33645&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33645&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33645&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33645&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33645&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33645&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33645&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33645&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33645&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33645&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33645&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33645&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33645&r=mysqlcfg