ID: 42235
Updated by: [EMAIL PROTECTED]
Reported By: stephen dot cuppett at webmastersinc dot net
-Status: Assigned
+Status: Bogus
Bug Type: Class/Object related
Operating System: *
PHP Version: 5.2.4RC1
Assigned To: dmitry
New Comment:
Indirect modification is not allowed because you return value from
__get() by value. You should see corresponding warnings.
To get that you like you should just return from get by reference.
public function &__get($vn) {
return $this->map[$vn];
}
Previous Comments:
------------------------------------------------------------------------
[2007-08-11 11:57:57] [EMAIL PROTECTED]
Dmitry, check this out please.
------------------------------------------------------------------------
[2007-08-07 16:35:29] stephen dot cuppett at webmastersinc dot net
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)
}
------------------------------------------------------------------------
[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