Why it's impossible to throw exception from __toString()?
class a
{
public function __toString()
{
throw new Exception();
}
}
$a = new a();
echo $a;
the code above produces this:
Fatal error: Method a::__toString() must not throw an exception in /var/www/localhost/htdocs/index.php on line 12
I was pointed to http://php.net/manual/en/migration52.incompatible.php where this behavior is described, but why? Any reasons to do that?
May be anyone here knows this?
At bug tracker php-dev-team as usual says nothing but "rtfm": http://bugs.php.net/50699