Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23911 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69869 invoked by uid 1010); 4 Jun 2006 09:47:12 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 69854 invoked from network); 4 Jun 2006 09:47:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2006 09:47:12 -0000 X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:9938] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 45/00-49656-F1CA2844 for ; Sun, 04 Jun 2006 05:47:12 -0400 Received: (qmail 26031 invoked from network); 4 Jun 2006 09:46:43 -0000 Received: from localhost (HELO zeev-notebook.zend.com) (127.0.0.1) by localhost with SMTP; 4 Jun 2006 09:46:43 -0000 Message-ID: <7.0.1.0.2.20060604124441.0da458d8@zend.com> X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Date: Sun, 04 Jun 2006 12:47:10 +0300 To: Greg Beaver Cc: internals@lists.php.net In-Reply-To: <4482516B.70007@php.net> References: <795156743.20060603134212@marcus-boerger.de> <4482516B.70007@php.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: Missing __toString() part From: zeev@zend.com (Zeev Suraski) In case we can't find a solution Andi's (a) approach, I think I like the explicit cast approach better than just implicitly converting to string. Rasmus pointed out that it's not clear why of all types PHP would implicitly convert the object to a string, and chances are that he's not the only person that will be surprised by that behavior. Zeev At 06:20 04/06/2006, Greg Beaver wrote: >Marcus Boerger wrote: > > Hello guys, > > > > the attached patch closes one more __toString() part. It allows > > to use objects that define __toString as indexes to arrays. What do > > you guys think about this, should we add it or stay with the old > > behavior that didn't allow objects as indexes at all. > >I prefer to require an explicit (string) cast to use an object as an >array index. The "can't use objects as array index" has actually helped >me catch many subtle bugs that were slipping through in earlier PHP >versions, I very much like this fatal error. I don't see this: > >$a = $b[$c]; > >being much clearer to understand than: > >$a = $b[$c]; > >or better yet > >$a = $b[$c->person()]; > >which is by far the clearest and easiest to debug (and results in a >fatal error if $c is the wrong kind of object or the wrong string - even >better for debugging) > >Thanks, >Greg