#24807 [Com]: Dereferencing objects and Property accesses with __get() and __set()
| From: | thomas dot hebinck at digionline dot de | Date: | Thu, 21 Aug 2003 16:50:58 +0000 |
| Subject: | #24807 [Com]: Dereferencing objects and Property accesses with __get() and __set() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-46438@lists.php.net to get a copy of this message | ||
ID: 24807
Comment by: thomas dot hebinck at digionline dot de
Reported By: Bertrand dot Willm at laposte dot net
Status: Bogus
Bug Type: Class/Object related
Operating System: Windows XP
PHP Version: 5.0.0b1 (beta1)
New Comment:
It works the old way:
$test = $extObject->extProperty;
$test->baseProperty = 'new';
How to switch this from 'bogus' back to 'open'?
Previous Comments:
------------------------------------------------------------------------
[2003-07-29 12:49:10] Bertrand dot Willm at laposte dot net
You suggest me to read ZEND_CHANGES but can't find anything
corresponding to that in the www.php.net site (I use the "Search for"
functionnality on the whole site).
I look again on the page called "PHP: Changes in PHP 5/Zend Engine
2.0", the following new functionnality is explained:
"Dereferencing objects returned from functions".
As it is possible to deference object members and now it is possible to
deference object returned from function, for me, not to be allowed
deference object properties looks like a bug.
It is because of things like this, that I found the __get and __set
methods are an unsatsifactory answer to properties.
------------------------------------------------------------------------
[2003-07-29 07:26:17] 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 :)
------------------------------------------------------------------------
[2003-07-25 15:35:14] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24807&edit=1