|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-07-24 07:44 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 12:00:01 2025 UTC |
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