From: agalkin at agalkin dot ru
Operating system: Mac OS X 10.5.4
PHP version: 5.2.6
PHP Bug Type: SPL related
Bug description: ArrayObject does not call offsetSet when an element is
incremented
Description:
------------
When an element of ArrayObject is incremented (++ operation), the object
does not call its offsetSet method. I've tried overloading all public
methods in ArrayObject: offsetGet is called, but not offsetSet or any
other. Same with decrementing (--). This behaviour makes it impossible to
handle all array modifications by overloading ArrayObject methods in
derived class.
Reproduce code:
---------------
class myArray extends ArrayIterator
{
public function offsetSet($index, $newval)
{
echo "offsetSet called\n";
return parent::offsetSet($index, $newval);
}
}
$a = new myArray(array('x' => 1));
echo "x += 1\n";
$a['x'] += 1; // calls offsetGet, then offsetSet with updated value
echo $a['x']."\n";
echo "x++\n";
$a['x']++; // only calls offsetGet
echo $a['x']."\n"; // but the value gets incremented
Expected result:
----------------
x += 1
offsetSet called
2
x++
offsetSet called
3
Actual result:
--------------
x += 1
offsetSet called
2
x++
3
--
Edit bug report at http://bugs.php.net/?id=45653&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45653&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45653&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45653&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45653&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45653&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45653&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45653&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45653&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45653&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45653&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45653&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45653&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45653&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45653&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45653&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45653&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45653&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45653&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45653&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45653&r=mysqlcfg