Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10718 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92510 invoked by uid 1010); 23 Jun 2004 09:58:02 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 92422 invoked from network); 23 Jun 2004 09:58:00 -0000 Received: from unknown (HELO mail.zend.com) (80.74.107.235) by pb1.pair.com with SMTP; 23 Jun 2004 09:58:00 -0000 Received: (qmail 2542 invoked from network); 23 Jun 2004 09:57:59 -0000 Received: from localhost (HELO AndiNotebook.zend.com) (127.0.0.1) by localhost with SMTP; 23 Jun 2004 09:57:59 -0000 Message-ID: <5.1.0.14.2.20040623000103.02f351b8@127.0.0.1> X-Sender: andi@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Wed, 23 Jun 2004 00:06:42 +0100 To: "Sara Golemon" ,internals@lists.php.net In-Reply-To: <20040622171622.64014.qmail@pb1.pair.com> References: <20040622164209.23239.qmail@pb1.pair.com> <5.1.0.14.2.20040622180046.02e53768@127.0.0.1> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] Bug 28879: Populating arrays with resources and objects as offsets From: andi@zend.com (Andi Gutmans) At 10:15 AM 6/22/2004 -0700, Sara Golemon wrote: > > > http://bugs.php.net/28879 > > > > > This isn't a bug fix, but the behavior we chose. > > Basically only integers and strings are supported as array offsets. > > As you guessed, we converted doubles and bools to integers (possibly > > loosing info in doubles). > > As resources is something abstract, I'm not really sure we should "fix" > > this. Then again, it probably can't do much harm. > > >For myself, I agree with you. Using resources as array offsets just feels >wrong, and I'm more than happy to leave that be. My only concern there was >consistency with $arr[$res] = $val; behavior which *does* pickup the lval >and has since ages long past. > >But since there's no BC need to allow resources in array initialization, >then sure, leave it to the scripter to cast it to an int if that's REALLY >what they want. (Again "why?" comes to mind). You are right, which is a sucky inconsistency. Instead of "fixing" array initialization, maybe the right thing to do, is to add an E_WARNING to $arr[$res] instead? Or at least an E_STRICT. > > Objects can't be converted to integers because two different objects can > > have the same object id! I mentioned it a few times on this list. > > >Nor would I suggest we do that. The portion of that bug report which refers >to objects is only asking why an error is thrown in $arr[$obj] = $val; style >while $arr = array($obj => $val); simply fails silently. > >Here my reservation would be in throwing errors where there previously >wasn't one (this would apply to both Objects and Arrays as offsets). If >this kind of scripting error is going to cause that name/value pair to >simply be ignored however, then it seems as though some notification should >be raised. > >The $arr[$obj] = $val; style raises E_WARNING, so it makes sense (to me) to >do the same with the $arr = array($obj => $val); syntax. Yep, I agree. We should issue an E_WARNING in this case similar to $arr[$obj]. We should need to copy the illegal offset error msg. Andi