php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30413 __set called for wrong object
Submitted: 2004-10-12 19:14 UTC Modified: 2004-10-13 09:19 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: info at pandora-web dot de Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.2 OS: Linux 2.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: info at pandora-web dot de
New email:
PHP Version: OS:

 

 [2004-10-12 19:14 UTC] info at pandora-web dot de
Description:
------------
When using overloaded Objects in Overloaded Object, then the __set method of the first object is called instead of the last Object in chain.

Reproduce code:
---------------
class TestClass {
    private $_p = array();
    
    public function __get($propName){
        return $this->_p[$propName];    
    }
    
    public function __set($propName, $propValue){
        $this->_p[$propName] = $value;
    }
}

$a = new TestClass();
$a->TestVar = 'test';
print $a->testVar;  //--> 'test'

$a->testVar = new TestClass();
$a->testVar->testVar = 'test2'; // __set of $a->testVar called instead of getter of $a->testVar and setter of $a->testVar->testVar

Expected result:
----------------
I think I is better to call the __get method of the first objects and than the __set method of the last one in chain.

Actual result:
--------------
<br />
<b>Fatal error</b>:  Cannot access undefined property for object with overloaded property access in <b>xxxx</b> on line <b>xxxx</b><br />

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-12 23:26 UTC] info at pandora-web dot de
see bug #28444

This is just another test case.

Please correct this odd behavior.

Thanx
 [2004-10-13 09:19 UTC] derick@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Please add your information to bug #28444 then, closing this one as a "submitted twice" bug.

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC