Re: Exception::__toString() not called

From: Date: Tue, 16 Mar 2004 22:45:46 +0000
Subject: Re: Exception::__toString() not called
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-8547@lists.php.net to get a copy of this message
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 > - Timm -- Best regards, Marcus mailto:helly@php.net

« previous php.internals (#8547) next »