Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8552 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62320 invoked by uid 1010); 17 Mar 2004 08:51:42 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 62294 invoked from network); 17 Mar 2004 08:51:41 -0000 Received: from unknown (HELO shiva.mind.de) (212.42.230.204) by pb1.pair.com with SMTP; 17 Mar 2004 08:51:41 -0000 Received: from [192.168.1.105] (p508EABAF.dip.t-dialin.net [80.142.171.175]) by shiva.mind.de (Postfix) with ESMTP id 4ADA497B4F; Wed, 17 Mar 2004 09:51:37 +0100 (CET) Date: Wed, 17 Mar 2004 09:49:31 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <20843861921.20040317094931@marcus-boerger.de> To: Andi Gutmans Cc: Marcus Boerger , Timm Friebe , internals@lists.php.net In-Reply-To: <5.1.0.14.2.20040317104450.02ab8d90@127.0.0.1> References: <1079472144.266.12.camel@localhost> <1079472144.266.12.camel@localhost> <5.1.0.14.2.20040317104450.02ab8d90@127.0.0.1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Exception::__toString() not called From: helly@php.net (Marcus Boerger) Hello Andi, the problem is that we have many classes that the handler table to behave mostly like a default php object. We'd need to manually set the cast handler for all of them. marcus Wednesday, March 17, 2004, 9:45:26 AM, you wrote: > The Exception class should support cast_object(). I don't see why we need > to add extra flags. > Andi > At 11:45 PM 3/16/2004 +0100, Marcus Boerger wrote: >>Hello Timm, hello Andi, >> >>i htought i had a better solution to the __toString() problem. >>But then i found out why we made it so complex. The reason IIRC >>was to prevent __toString() being called everywhere automatically >>when it is a user function. >> >>Havin said this the solution is very easy. We expand the signature >>of cast_object to inform about exactly this - whether user space >>functions may be called or not. From _convert_to_string() we set >>that param to zero and from make_printable_zval we set it to 1 >>and inside the cast function we only need to verify the type of >>the function if necessary. >> >>Even better would be to add a flag that disallows usercode functions. >>Because with such a flag we do not have a problem if a conversion >>calls an internal method which then calls a userspace function which >>it shouldn't. >> >>Anid? >> >> >>Tuesday, March 16, 2004, 10:22:24 PM, you wrote: >> >> > Hi, >> >> > Both of the following examples used to output the >> > Exception::__toString() output, which they don't anymore: >> >> > $ php-dev -r '$e= new Exception(); echo $e, "\n";' >> > Object id #1 >> >> > $ php-dev -r '$e= new Exception(); echo (string)$e, "\n";' >> > Object id #1 >> >> > Works fine for userland objects: >> >> > $ php-dev -r 'class Foo { function __toString() { return "foo"; }} echo >> > new Foo(), "\n";' >> > foo >>