Edit report at https://bugs.php.net/bug.php?id=55131&edit=1
ID: 55131
User updated by: archon dot saratov at gmail dot com
Reported by: archon dot saratov at gmail dot com
Summary: HUITA fix this bug
Status: Open
Type: Bug
Package: *Programming Data Structures
Operating System: Windows, FreeBSD
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
Description:
------------
bad working a __get method
Test script:
---------------
<?php
class C1 {
protected $arr = array( 'e1' => array() );
public function __get($propertyName) {
if(isset($this->arr[$propertyName])) return $this->arr[$propertyName];
}
public function __set($propertyName, $value) {
if(isset($this->arr[$propertyName])) $this->arr[$propertyName] = $value;
}
}
$c1 = new C1();
var_dump($c1->e1);
$c1->e1[] = 1;
var_dump($c1->e1);
Expected result:
----------------
array
empty
array
0 => int 1
Actual result:
--------------
array
empty
( ! ) Notice: Indirect modification of overloaded property C1::$e1 has no
effect
in E:\Server\xampp\htdocs\test.php on line 18
array
empty
Previous Comments:
------------------------------------------------------------------------
[2011-07-04 14:44:32] archon dot saratov at gmail dot com
Description:
------------
bad working a __get method
Test script:
---------------
<?php
class C1 {
protected $arr = array( 'e1' => array() );
public function __get($propertyName) {
if(isset($this->arr[$propertyName])) return $this->arr[$propertyName];
}
public function __set($propertyName, $value) {
if(isset($this->arr[$propertyName])) $this->arr[$propertyName] = $value;
}
}
$c1 = new C1();
var_dump($c1->e1);
$c1->e1[] = 1;
var_dump($c1->e1);
Expected result:
----------------
array
empty
array
empty
Actual result:
--------------
array
empty
( ! ) Notice: Indirect modification of overloaded property C1::$e1 has no
effect
in E:\Server\xampp\htdocs\test.php on line 18
array
0 => int 1
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55131&edit=1