ID: 36571
Updated by: [EMAIL PROTECTED]
Reported By: cid73 at 163 dot com
-Status: Assigned
+Status: Closed
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 5.1.3RC3
Assigned To: dmitry
New Comment:
Not reproducible with 5.2-CVS.
Previous Comments:
------------------------------------------------------------------------
[2006-04-12 09:59:05] [EMAIL PROTECTED]
One more overloading bug.
It is unfixable at this moment :(
------------------------------------------------------------------------
[2006-04-11 11:37:18] [EMAIL PROTECTED]
Dmitry, this does not look right to me.
------------------------------------------------------------------------
[2006-03-01 14:55:50] cid73 at 163 dot com
Description:
------------
I'm not sure if there are inner operaters named "[]=" or "{}=", but it
really goes wrong when overloading such operations.
Here's some demo code.
Reproduce code:
---------------
class Setter
{
private $attributes;
public function __construct($attributes) {
$this->attributes = $attributes; }
private function __set($var, $value) {
$this->attributes[$var] = $value; }
private function __get($var) {
if ( isset($this->attributes[$var]) ) {
return $this->attributes[$var]; }
else {
return null; }}
}
$a = array('a' => array('a', 'b', 'c'), 'b' => 'Hello');
$o = new Setter($a);
$o->a[0] = 'A';
$o->a[] = 'd';
$o->b{0} = 'h';
print_r($a); // gotta check $a, $o is good
/* ouputs:
Array
(
[a] => Array
(
[0] => A
[1] => b
[2] => c
[3] => d
)
[b] => hello
)
*/
Expected result:
----------------
$a is unchangeable at the moment
Actual result:
--------------
$a was modified
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36571&edit=1