Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24677 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48850 invoked by uid 1010); 19 Jul 2006 13:43:43 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 48835 invoked from network); 19 Jul 2006 13:43:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2006 13:43:43 -0000 X-PHP-List-Original-Sender: m.bretz@metropolis-ag.de X-Host-Fingerprint: 213.143.192.7 mail.21torr.com Windows XP/2000 Received: from ([213.143.192.7:4404] helo=mail.21torr.com) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id FF/65-11992-A073EB44 for ; Wed, 19 Jul 2006 09:43:40 -0400 Received: from [192.168.1.155] (unverified [213.143.192.1]) by mail.21torr.com (Rockliffe SMTPRA 7.0.3) with ESMTP id for ; Wed, 19 Jul 2006 15:43:35 +0200 Message-ID: <44BE3707.2020506@metropolis-ag.de> Date: Wed, 19 Jul 2006 15:43:35 +0200 User-Agent: Thunderbird 1.5.0.4 (X11/20060706) MIME-Version: 1.0 To: PHPdev References: <44BE2AE5.4090700@bitflux.ch> <10845a340607190624w44b6d7b1ycff7610d03cc3676@mail.gmail.com> In-Reply-To: <10845a340607190624w44b6d7b1ycff7610d03cc3676@mail.gmail.com> Content-Type: multipart/alternative; boundary="------------050202010208030004090302" Subject: Re: [PHP-DEV] PHP 5.2-dev "Cannot use array returned from foo::__get('bar') in write context" From: m.bretz@metropolis-ag.de (Mike Bretz) --------------050202010208030004090302 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I guess this is associated with bug #36647 ( http://bugs.php.net/bug.php?id=36647 ) and I do not think that this makes a lot sense for the applications outside and will break them. For my company I decided that __get handlers really suck and I do not encourage our developers to use it anymore. I strongly request that the whole part of __* handlers gets revisited, especially for memory allocation bugs (see my bugreport). I do not see any benefit of having those methods when the methods either refuse to do things which were possible before(BC!), nor when they do trash the application like now in current release. Leaving the methods untouched is a bad thing, since for security reasons the memleaks should be fixed asap. But "disabling" some of the functionality (return an internal array of the class for further handling) is not that nice at all, too. A smarter way has to be found, pls - if at all possible (derrick told me that this is "by php design" and probably is unfixable by nature). mike Richard Quadling wrote: > For PHP 5.2.0-dev (cli) (built: Jul 12 2006 12:20:25), I get ... > > Fatal error: Cannot use array returned from foo::__get('bar') in write > context in C:\- on line 16 > > But only once, not 1 per line. > > $f = new foo(); > $a = $f->bar; > foreach($a as $key => $value) > > fixes the code. > > > > On 19/07/06, Christian Stocker wrote: >> Just updated to the latest PHP 5.2-dev from CVS and now I get an Fatal >> error with the following code >> *** >> > >> class foo { >> public function __get($member) { >> return array("foo"=>"bar","bar"=>"foo"); >> } >> } >> >> $f = new foo(); >> >> //error >> foreach($f->bar as $key => $value) { >> print "$key => $value"; >> } >> >> ?> >> *** >> >> It throws a >> >> "Fatal error: Cannot use array returned from foo::__get('bar') in write >> context" >> >> on the foreach line. Quite annoying :) >> >> >> That worked fine with 5.1 and also with 5.2-dev from a few days/weeks >> ago (don't know, when I cvs-uped last time, but can't be that long) >> >> Is that expected/wished behaviour? >> >> chregu >> >> >> >> >> -- >> christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich >> phone +41 44 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 >> http://www.bitflux.ch | christian.stocker@bitflux.ch | GPG 0x5CE1DECB >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > -- mike peter bretz metropolis ag / entwicklung email: m.bretz@metropolis-ag.de heinestraße 72 phone: +49-7121-348-120 d-72762 reutlingen fax: +49-7121-348-111 http://www.metropolis-ag.de/ metropolis ag. creating social internetworks. --------------050202010208030004090302--