ID: 31976 Updated by: [EMAIL PROTECTED] Reported By: adove at booyahnetworks dot com -Status: Open +Status: Bogus Bug Type: Zend Engine 2 problem Operating System: WinXP PHP Version: 5.0.3 New Comment:
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. See #29378. Previous Comments: ------------------------------------------------------------------------ [2005-02-15 02:00:32] adove at booyahnetworks dot com Description: ------------ Using an overloaded property from an object instance directly in a foreach fails. If you assign the property (or a reference to it) to a variable first it works fine. This is reproducable. Interestingly enough, I see a strange problem with inheritance and overloaded members. I am unable to reproduce it in a simple example. I will continue to work that. Basically, you get the same fatal error as here BUT on assignment to a member variable of the parent class that is not overloaded. It's bizzare. As soon as I remove the __get/__set from the child, the parent method works fine again from an instance of child. Again, simple examples do not seem to reproduce. <sigh> Reproduce code: --------------- class Son { protected $m_aActions; function __construct(&$aActions) { $this->m_aActions = $aActions; } function __get($mName) { $mRetval = null; switch($mName) { case("Actions"): { $mRetval = $this->m_aActions; break; } } return $mRetval; } } $aActions = array("add", "delete"); $oSon = new Son($aActions); $aActions = $oSon->Actions; var_dump($aActions); foreach($oSon->Actions as $strAction) { echo $strAction . "\n"; } Expected result: ---------------- array(2) { [0]=> string(3) "add" [1]=> string(6) "delete" } add delete Actual result: -------------- array(2) { [0]=> string(3) "add" [1]=> string(6) "delete" } Fatal error: Cannot access undefined property for object with overloaded property access ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31976&edit=1