ID:               38146
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Assigned
 Bug Type:         Scripting Engine problem
 Operating System: all
 PHP Version:      5CVS-2006-07-19 (CVS)
 Assigned To:      dmitry


Previous Comments:
------------------------------------------------------------------------

[2006-07-19 16:14:35] [EMAIL PROTECTED]

Description:
------------
When looping through an array, returned by a __get method, 
the following error appears:

"Fatal error: Cannot use array returned from foo::__get
('bar') in write context" 

Worked in 5.1

Would be nice, if that could be fixed, as there's no write 
done in this case and it's a pretty annoying BC break.

Although one can avoid it with:

$f = new foo();
$a = $f->bar;
foreach($a as $key => $value) {}

so there's at least a workaround.

BTW, similar to http://bugs.php.net/bug.php?id=38102, except 
that i don't write to the arrray and on the other bug he 
does


Reproduce code:
---------------
<?php

class foo {
    public function __get($member) {
        $f = array("foo"=>"bar","bar"=>"foo");
        return $f;
    }
}

$f = new foo();

//error
foreach($f->bar as $key => $value) {
    print "$key => $value";
}


Expected result:
----------------
foo => bar
bar => foo

Actual result:
--------------
Fatal error: Cannot use array returned from foo::__get('bar') 
in write context


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38146&edit=1

Reply via email to