From:             pstradomski at gmail dot com
Operating system: Linux
PHP version:      5.2.0
PHP Bug Type:     Scripting Engine problem
Bug description:  Overloaded array properties do not work correctly

Description:
------------
It is now impossible to implement overloaded array properties. Array
returned via __get is now a copy (not a reference as in 5.1.x) and it is
impossible to force getter to pass a reference.

Reproduce code:
---------------
<?php

class A {
public function & __get($val) {
  return $this->keys[$val];
}
public function __set($k, $v) {
  $this->keys[$k] = $v;
}
private $keys = array();
}

$a =new A();

$a->arr = array('a','b','c');

$b = &$a->arr;
$b[]= 'd';

foreach ($a->arr as $k => $v) {
  echo "$k => $v\n";
}

$a->arr[]='d';

foreach ($a->arr as $k => $v) {
  echo "$k => $v\n";
}

?>

Expected result:
----------------
0 => a
1 => b
2 => c
3 => d

0 => a
1 => b
2 => c
3 => d
4 => d


Actual result:
--------------
Notice: Indirect modification of overloaded property A::$arr has no effect
in /home/pawel/tmp/a.php on line 18

Notice: Indirect modification of overloaded property A::$arr has no effect
in /home/pawel/tmp/a.php on line 21
0 => a
1 => b
2 => c

Notice: Indirect modification of overloaded property A::$arr has no effect
in /home/pawel/tmp/a.php on line 25

Notice: Indirect modification of overloaded property A::$arr has no effect
in /home/pawel/tmp/a.php on line 27
0 => a
1 => b
2 => c


-- 
Edit bug report at http://bugs.php.net/?id=39449&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39449&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39449&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39449&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39449&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39449&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39449&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39449&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39449&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39449&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39449&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39449&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39449&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39449&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39449&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39449&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39449&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39449&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39449&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39449&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39449&r=mysqlcfg

Reply via email to