php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40625 Indirect modification of overloaded property
Submitted: 2007-02-25 03:18 UTC Modified: 2007-02-25 19:35 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: noreply@php.net Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.1 OS: XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: noreply@php.net
New email:
PHP Version: OS:

 

 [2007-02-25 03:18 UTC] 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 "

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-25 19:35 UTC] 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.
 [2013-11-28 10:06 UTC] 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.
 [2013-11-28 14:22 UTC] nikic@php.net
@martijn: Everything works fine, you just have to return from __get by reference (write &__get instead of just __get).
 [2013-11-28 14:39 UTC] martijn dot otto at copernica dot com
Ah, that seems to work, thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 06:01:35 2024 UTC