Re: Tip for 5.3: exceptions in __toString and __autoload

From: Date: Fri, 26 Dec 2008 02:17:17 +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-42374@lists.php.net to get a copy of this message
On 26 Dec 2008, at 01:46, David Grudl 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.
This is down to the design of the engine, we perform casting to strings in a lot of different places and it couldn't be guaranteed that the engine would handle any exceptions correctly. I'm pretty sure there is something in the internals archives about this change. Scott

« previous php.internals (#42374) next »