Re: Tip for 5.3: exceptions in __toString and __autoload

From: Date: Fri, 26 Dec 2008 07:14:45 +0000
Subject: Re: Tip for 5.3: exceptions in __toString and __autoload
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-42375@lists.php.net to get a copy of this message
On Fri, Dec 26, 2008 at 4:46 AM, David Grudl <david@grudl.com> wrote: > This code throws *Fatal error*: Method test::__toString() must not throw an > exception > > class Test1 > { > public function __toString() > { > throw new Exception; > } > } > > The same problem causes throwing exceptions in function __autoload. > > I think this behavior is against the logic of exceptions. Excellent feature > of PHP 5.3 would be to resolve this errors. regarging __autoload, everything is correct, actually, as throwing exception doesn't let engine to try other variants (which is counter-intuitive). it is perfectly fine to have several autoloaders enabled. regarding __toString(), I am not convinced that it is unresolvable. Someone with better understanding of engine should comment -- Alexey Zakhlestin http://www.milkfarmsoft.com/

« previous php.internals (#42375) next »