php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24807 Dereferencing objects and Property accesses with __get() and __set()
Submitted: 2003-07-25 15:35 UTC Modified: 2003-07-29 12:49 UTC
From: Bertrand dot Willm at laposte dot net Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.0b1 (beta1) OS: Windows XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Bertrand dot Willm at laposte dot net
New email:
PHP Version: OS:

 

 [2003-07-25 15:35 UTC] Bertrand dot Willm at laposte dot net
Description:
------------
I try to use the following notation:
$object->property1->property2 = 'value';
when property1 and property2 are properties we access trow __get and __set methods.
calling __get with property1 return an object that defined __get and __set methods.
but there is a warning explaining the object doesn't support property references.


Reproduce code:
---------------
<?php
class CBaseClass {
   private $text = 'default';
   function __Get() {
      return $this->text;
   }
   function __Set($name, $value) {
      $this->text = $value;
   }
}
class CExtClass {
   private $baseObject;
   function __construct() {
      $this->baseObject = new CBaseClass();
   }
   function __Get() {
      return $this->baseObject;
   }
}
$extObject = new CExtClass();
echo $extObject->extProperty->baseProperty, '<br>';
$extObject->extProperty->baseProperty = 'new';
echo $extObject->extProperty->baseProperty, '<br>';
?>

Expected result:
----------------
default
new


Actual result:
--------------
default

Warning: This object doesn't support property references in c:\sitesweb\www\test.php5 on line 22
default


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-29 07:26 UTC] sfox@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

Suggest you read ZEND_CHANGES :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 15:01:32 2024 UTC