#42235 [Opn]: Overloaded properties not allowing modification

From: Date: Tue, 07 Aug 2007 16:35:29 +0000
Subject: #42235 [Opn]: Overloaded properties not allowing modification
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115851@lists.php.net to get a copy of this message
ID: 42235 User updated by: stephen dot cuppett at webmastersinc dot net Reported By: stephen dot cuppett at webmastersinc dot net Status: Open Bug Type: Class/Object related Operating System: Windows and Linux PHP Version: 5.2.4RC1 New Comment: It should be noted that the supposed congruent case works: <?php class MyObj { public $test_var; } $myvar = new MyObj(); $myvar->test_var = array(); $myvar->test_var['tester'] = 3; $myvar->test_var['tester2'] = 5; var_dump($myvar->test_var); ?> C:\temp\dataobject_test>php simpletest.php array(2) { ["tester"]=> int(3) ["tester2"]=> int(5) } Previous Comments: ------------------------------------------------------------------------ [2007-08-07 16:27:23] stephen dot cuppett at webmastersinc dot net Description: ------------ Also documented in: http://pear.php.net/bugs/bug.php?id=11775 There appears to be a regression as to Bug #39449: http://bugs.php.net/bug.php?id=39449 On 5.2.4RC1, I'm getting the immutable overloaded properties problem with DB_DataObject and in the simple test below. Also bugs: 41116, 40828, 40823, 39990 Reproduce code: --------------- <?php class MyObj { private $map; public function __construct() { $this->map = array(); } public function __set($vn, $value) { $this->map[$vn] = $value; } public function __get($vn) { return $this->map[$vn]; } } $myvar = new MyObj(); $myvar->test_var = array(); $myvar->test_var['tester'] = 3; $myvar->test_var['tester2'] = 5; var_dump($myvar->test_var); ?> Expected result: ---------------- C:\temp\dataobject_test>php simpletest.php array(2) { ["tester"]=> int(3) ["tester2"]=> int(5) } Actual result: -------------- C:\temp\dataobject_test>php simpletest.php PHP Notice: Indirect modification of overloaded property MyObj::$test_var has no effect in C:\temp\dataobject_test\simpletest.php on line 16 Notice: Indirect modification of overloaded property MyObj::$test_var has no effect in C:\temp\dataobject_test\simpletest.php on line 16 PHP Notice: Indirect modification of overloaded property MyObj::$test_var has no effect in C:\temp\dataobject_test\simpletest.php on line 17 Notice: Indirect modification of overloaded property MyObj::$test_var has no effect in C:\temp\dataobject_test\simpletest.php on line 17 array(0) { } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42235&edit=1

« previous php.bugs (#115851) next »