Edit report at http://bugs.php.net/bug.php?id=52794&edit=1

 ID:                 52794
 Updated by:         cataphr...@php.net
 Reported by:        seroshkin at gmail dot com
 Summary:            $a = $b = $c = $d logic with ArrayObject
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Arrays related
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

This is not a bug.



You did not override offsetSet. The assignment returns the assigned
value, hence $b will be 'Fail' in the first example.



However, in the second, despite $o[1] = 'Fail';, $o[1] will return 'Ok'
due to your definition of offsetGet and $b will be 'Ok'.


Previous Comments:
------------------------------------------------------------------------
[2010-09-07 16:53:29] seroshkin at gmail dot com

Description:
------------
If i use expression like

$a = $b = $c = $d;



where $b or $c determined as class extends ArrayObject, then

ArrayObject::offsetGet method do not call.



It may be only if above expression interpreted as

$a = $d;

$b = $d;

$c = $d;

Test script:
---------------
class foo extends ArrayObject{

  function offsetGet($index){return 'Ok';}

}

$o = new foo();

$a = $o[1];

$b = ($o[1] = 'Fail');

echo $a,$b;

//Output: OkFail



//but if



$o[1] = 'Fail';

$b = $o[1];

echo $a,$b;

//Output: OkOk



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52794&edit=1

Reply via email to