php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30428 __set()/__get property access
Submitted: 2004-10-14 05:52 UTC Modified: 2005-01-13 01:16 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: pavel at plpu dot permnet dot ru Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.1 OS: WinXP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
47 + 2 = ?
Subscribe to this entry?

 
 [2004-10-14 05:52 UTC] pavel at plpu dot permnet dot ru
Description:
------------
sorry for bad English.
I developing class library on PHP5.
All objects in library have property with set()/get()
 access, and som property return objects.
But isnt work 
ObjectA->propertyA->propertyB = "some value" 
if propertyA return object instance.
simple example below



Reproduce code:
---------------
   class A {
     private $_caption = "test";
     function __set($name,$value){
       if($name == "caption") $this->_caption = $value;
     }
   }

   class B {
     private $_A;
     function __construct(){
       $this->_A = new A();
     }

     function __get($name){
       if($name == "A") return $this->_A;
     }
   }

   $B = new B();

//dont work!!!!!!
// Cannot access undefined property for object with    overloaded property access
   $B->A->caption = "test";

// OK !!!!!
   $T = $B->A;
   $T->caption = "test";


Expected result:
----------------
i think 
$Object->ObjectA->property = "" 
must work !!!!! its bug !!! 
this make __set()/__get() methods absolutely uneffective!!!
why i cant write for ex.

$Application->mainMenu->menuItem1->caption = "some" !!!


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-13 01:16 UTC] tony2001@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.

Duplicate of #28444.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 07:01:31 2024 UTC