<?php
namespace HHVM\UserDocumentation\Inconsistencies\Intro\Examples\toStringExc;
class A {
public function __toString() {
throw new \Exception('Not allowed in PHP');
return 'A';
}
}
$a = new A();
echo $a;
Fatal error: Uncaught Exception: Not allowed in PHP in /in/kgrk5:7
Stack trace:
#0 /in/kgrk5(13): HHVM\UserDocumentation\Inconsistencies\Intro\Examples\toStringExc\A->__toString()
#1 {main}
thrown in /in/kgrk5 on line 7
Process exited with code 255.
Fatal error: Method HHVM\UserDocumentation\Inconsistencies\Intro\Examples\toStringExc\A::__toString() must not throw an exception, caught Exception: Not allowed in PHP in /in/kgrk5 on line 0
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0
Fatal error: Method HHVM\UserDocumentation\Inconsistencies\Intro\Examples\toStringExc\A::__toString() must not throw an exception in /in/kgrk5 on line 0
Process exited with code 255.