ID: 36571
Updated by: [EMAIL PROTECTED]
Reported By: cid73 at 163 dot com
-Status: Open
+Status: Assigned
Bug Type: Scripting Engine problem
-Operating System: WinXP SP2
+Operating System: *
-PHP Version: 5.1.2
+PHP Version: 5.1.3RC3
-Assigned To:
+Assigned To: dmitry
New Comment:
Dmitry, this does not look right to me.
Previous Comments:
------------------------------------------------------------------------
[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