From: hawcue at yahoo dot com
Operating system: Windows XP
PHP version: 5.0.0
PHP Bug Type: Class/Object related
Bug description: Dereferencing, __get and array property
Description:
------------
Part of this report is related with BUG#24807.
In the following code, I would like to get and set an object property in
the way similar to that in Java, C# and Delphi, e.g.,
"$a->Child->Name='xxx'" and "echo $a->Child->Name". However, the PHP
parser would not allow the first usage.
Another question is about array property. Within current PHP5 release, I
can't see a way to define an object property that is of array type and
supports access to individual array element.
These two questions may not be considered as bugs, however, to my belief
they are very fundamental to object properties.
Reproduce code:
---------------
class Input {
private $_name='abc';
private $_child;
function __get($name) {
if($name=='Name')
return $this->_name;
else if($name=='Child') {
if(!isset($this->_child))
$this->_child=new Input;
return $this->_child;
}
}
function __set($name,$value) {
if($name=='Name')
$this->_name=$value;
}
}
$a=new Input;
$a->Child->Name='cde';
echo $a->Child->Name;
Expected result:
----------------
cde
Actual result:
--------------
Fatal error: Cannot access undefined property for object with overloaded
property access ...
--
Edit bug report at http://bugs.php.net/?id=29458&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29458&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29458&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29458&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29458&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29458&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29458&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29458&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29458&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29458&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29458&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29458&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29458&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29458&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29458&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29458&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29458&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29458&r=float