Bug #40625 [Com]: Indirect modification of overloaded property
| From: | nikic@php.net | Date: | Thu, 28 Nov 2013 14:22:37 +0000 |
| Subject: | Bug #40625 [Com]: Indirect modification of overloaded property | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-182983@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=40625&edit=1
ID: 40625
Comment by: nikic@php.net
Reported by: noreply@php.net
Summary: Indirect modification of overloaded property
Status: Not a bug
Type: Bug
Package: Class/Object related
Operating System: XP SP2
PHP Version: 5.2.1
Block user comment: N
Private report: N
New Comment:
@martijn: Everything works fine, you just have to return from __get by reference (write &__get
instead of just __get).
Previous Comments:
------------------------------------------------------------------------
[2013-11-28 10:06:04] martijn dot otto at copernica dot com
This bug is now almost five years old and still has not been fixed. Stating that is has never worked
before and it gives a notice about this lack of functionality is of course no excuse to close this
bug.
I would like to see this issue fixed.
------------------------------------------------------------------------
[2007-02-25 19:35:31] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
It didn\'t work properly before either, and now we warn about it.
------------------------------------------------------------------------
[2007-02-25 03:18:29] noreply@php.net
Description:
------------
While using __get and __set im getting the following notice : "Notice: Indirect modification of
overloaded property $var has no effect "
It worked perfect in previous PHP versions.
Reproduce code:
---------------
class myclass
{
/*
$this->_data =
array(1) {
["abcd"] => array(2) {
["a"] => string(2) "cc"
["b"] => string(2) "dd"
}
}
*/
public function __get($name)
{
$result = null;
if (isset($this->_data[$name])) {
$result = $this->_data[$name];
}
return (array)$this->_data[$name] ;
}
public function __set($value, $arg)
{
foreach($arg as $key=>$inhoud) {
$this->_data[$value][$key] = $inhoud;
}
}
}
$myclass = new myclass();
$myclass->abcd['a'] = 'ee'; //does not work anymore
$myclass->newNode['a'] = 'ee'; //does not work anymore
Expected result:
----------------
array(2) {
["abcd"] => array(2) {
["a"] => string(2) "ee"
["b"] => string(2) "dd"
}
["newNode"] => string(2) "ee"
}
Actual result:
--------------
Data does not change and outputs "Notice: Indirect modification of overloaded property $var has
no effect "
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=40625&edit=1