Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27205 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52093 invoked by uid 1010); 27 Dec 2006 20:23:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 52078 invoked from network); 27 Dec 2006 20:23:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Dec 2006 20:23:52 -0000 Authentication-Results: pb1.pair.com header.from=antony@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=antony@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: antony@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from [212.25.124.162] ([212.25.124.162:18012] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/34-20830-436D2954 for ; Wed, 27 Dec 2006 15:23:52 -0500 Received: (qmail 4118 invoked from network); 27 Dec 2006 20:21:40 -0000 Received: from internal.zend.office (HELO ?127.0.0.1?) (10.1.1.1) by internal.zend.office with SMTP; 27 Dec 2006 20:21:40 -0000 Message-ID: <4592D62F.7070701@zend.com> Date: Wed, 27 Dec 2006 23:23:11 +0300 User-Agent: Thunderbird 1.5.0.8 (X11/20061025) MIME-Version: 1.0 To: Andrei Zmievski CC: php-dev Internals References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Return value of convert_to_*() From: antony@zend.com (Antony Dovgal) On 12/27/2006 11:02 PM, Andrei Zmievski wrote: > Antony and I just had a spirited discussion on IRC about his latest > patches to convert_to_unicode() and convert_to_string(). The specific > troublesome point was conversion of IS_OBJECT type. His point was that > since all we care about is the end result, then the function should > return SUCCESS regardless of whether the object could convert itself to > a string or whether we forced the conversion and got a simple "Object" > string. I do not subscribe to this point of view. I added return values > to conversion functions precisely because I wanted to distinguish > between "good" and "forced" conversions. Why do you want that? "Bad" conversion is failed conversion, that's the case when you get E_RECOVERABLE_ERROR and it bails out. I consider all the other cases are "good" conversions, since we've got the result we requested and have SUCCESSfully converted the object into string. > One such place is zend_parse_parameters(). If you say zpp(..., "s", &str, &str_len) and > the user passes an object without __toString() method, zpp() should > issue an error saying that it expected a string and got an object > instead, even if we "forced" the conversion result to be a string in > convert_to_string(). An error? You mean this one: zend_error(E_NOTICE, "Object of class %v to string conversion", Z_OBJCE_P(op)->name); ? We already have it, no need for a new error. It's perfectly legal to do it in 5.2 and I don't see why PHP6 is different. IMO it's same as changing the E_RECOVERABLE to E_ERROR - users won't have any way to "workaround" it, even though this was the original intention of E_RECOVERABLE. -- Wbr, Antony Dovgal