From:             chernyshevsky at hotmail dot com
Operating system: Windows 2000
PHP version:      5.0.0
PHP Bug Type:     Zend Engine 2 problem
Bug description:  foreach() doesn't work with arrays returned by __get

Description:
------------
Not sure if this is a duplicate of #28444. It's certainly related.

Basically I was trying to loop through an array set earlier using __set
and retrieve through __get. Simple enough it seems, but the engine died
with an "Cannot access undefined property for object with overloaded
property access" fatal error.

Reproduce code:
---------------
class Object {
        private $values;

        function __set($name, $value) {
                $this->values[$name] = $value;
        }
        function __get($name) {
                return $this->values[$name];
        }
}

$O = new Object;
$O->cows = array("Betty", "Agnes", "Jeff");
foreach($O->cows as $cow) {
        echo "<div>$cow</div>";
}

Expected result:
----------------
Betty
Agnes
Jeff

Actual result:
--------------
Fatal error: Cannot access undefined property for object with overloaded
property access

-- 
Edit bug report at http://bugs.php.net/?id=29378&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29378&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29378&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29378&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29378&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29378&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29378&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29378&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29378&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29378&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29378&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29378&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29378&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29378&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29378&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29378&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29378&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29378&r=float

Reply via email to