From:             [EMAIL PROTECTED]
Operating system: all
PHP version:      5CVS-2006-07-19 (CVS)
PHP Bug Type:     Scripting Engine problem
Bug description:  Cannot use array returned from foo::__get('bar') in write 
context

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 bug report at http://bugs.php.net/?id=38146&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38146&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38146&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38146&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38146&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38146&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38146&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38146&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38146&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38146&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38146&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38146&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38146&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38146&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38146&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38146&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38146&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38146&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38146&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38146&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38146&r=mysqlcfg

Reply via email to