From: evert at rooftopsolutions dot nl
Operating system: Linux 2.4.26
PHP version: 4.3.10
PHP Bug Type: Scripting Engine problem
Bug description: Overloaded property can't be accessed with foreach
Description:
------------
When an array is directly accessed is accessed trough an overloaded class,
it works just fine.
When you access it trough foreach, it triggers an error.
Reproduce code:
---------------
<?
class OlClass {
var $data;
function OlClass() {
$this->data = new StdClass();
$this->data->arr = Array('a','b','c');
overload('OlClass');
}
function __get($p,&$v) {
$v = $this->data->$p;
return true;
}
}
$o = new OlClass;
print_r($o->arr);
foreach($o->arr as $value) echo($value);
?>
Expected result:
----------------
Array ( [0] => a [1] => b [2] => c )
abc
Actual result:
--------------
Array ( [0] => a [1] => b [2] => c )
Warning: Invalid argument supplied for foreach() in
/home/evert/public_html/dev/sabretooth/s41/test/test4.php on line 28
--
Edit bug report at http://bugs.php.net/?id=31581&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31581&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=31581&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=31581&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31581&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31581&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31581&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31581&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31581&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31581&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31581&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=31581&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=31581&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31581&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31581&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31581&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31581&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31581&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31581&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31581&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31581&r=mysqlcfg