#31581 [Opn->Fbk]: Overloaded property can't be accessed with foreach
ID: 31581
Updated by: sniper@php.net
Reported By: evert at rooftopsolutions dot nl
-Status: Open
+Status: Feedback
Bug Type: Scripting Engine problem
Operating System: Linux 2.4.26
PHP Version: 4.3.10
New Comment:
Yes, you should try the snapshot since couple of overloading issues
have been fixed in it..
Previous Comments:
------------------------------------------------------------------------
[2005-01-17 21:05:35] evert at rooftopsolutions dot nl
Did you mean I should test it on the snapshot, or is it solved on the
latest snapshot?
I noticed that a commenter on http://nl3.php.net/overload
experienced
the same problem.
------------------------------------------------------------------------
[2005-01-17 18:28:30] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2005-01-17 08:00:10] evert at rooftopsolutions dot nl
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 this bug report at http://bugs.php.net/?id=31581&edit=1
Thread (8 messages)