Bug #66641 [NEW]: ArrayObject doens't call offsetSet when using += with ARRAY_AS_PROPS flag
From: corentin dot larose at qapa dot com
Operating system: UBUNTU 12.04
PHP version: 5.4.24
Package: SPL related
Bug Type: Bug
Bug description:ArrayObject doens't call offsetSet when using += with ARRAY_AS_PROPS flag
Description:
------------
ArrayObject doesn't call offsetSet when using combined operators on a
property with \ArrayObject::ARRAY_AS_PROPS flag.
https://bugs.php.net/bug.php?id=45653&edit=2
says it should work.
Test script:
---------------
<?php
class MyArrayObject extends ArrayObject {
public function offsetSet($name, $value) {
parent::offsetSet($name . '_control', $value);
parent::offsetSet($name, $value);
}
}
$test = new MyArrayObject();
$test->setFlags(\ArrayObject::ARRAY_AS_PROPS);
$test['my_value_1'] = 1;
$test['my_value_1'] = $test['my_value_1'] + 1;
$test['my_value_1'] += 1;
$test->my_value_2 = 1;
$test->my_value_2 = $test->my_value_2 + 1;
$test->my_value_2 += 1; // It seems that MyArrayObject::offsetSet() is
not called here
echo '<pre>';
print_r($test);
Expected result:
----------------
MyArrayObject Object
(
[storage:ArrayObject:private] => Array
(
[my_value_1_control] => 3
[my_value_1] => 3
[my_value_2_control] => 3
[my_value_2] => 3
)
)
Actual result:
--------------
MyArrayObject Object
(
[storage:ArrayObject:private] => Array
(
[my_value_1_control] => 3
[my_value_1] => 3
[my_value_2_control] => 2
[my_value_2] => 3
)
)
--
Edit bug report at https://bugs.php.net/bug.php?id=66641&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66641&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66641&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66641&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66641&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66641&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66641&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66641&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66641&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66641&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66641&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66641&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66641&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66641&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66641&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66641&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66641&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66641&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66641&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66641&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66641&r=mysqlcfg
Thread (3 messages)
- corentin dot larose at qapa dot com