Dear Giovanni, I brought this up last July, see https://bugs.php.net/bug.php?id=70050 ; because in a few code bases I tested back then, this was the first issue I hit.
Unfortunately, it was only deemed a "Documentation Problem" back then. AFAIK this is the most up to date information. Sorry I don't have further news. cheers, - Markus On 11.01.16 14:31, Giovanni Giacobbi wrote: > Greetings, > > Short premise before I get flamed: I know PHP 7 is rolling and it is way > too late for this, that I should've tested the RCs, follow the mailing list > and so on, but I'm a dev like you guys and struggle with the time to do > everything by the book, including reading the previous threads because I'm > pretty sure this was brought up by somebody, but as there are hundreds of > message under the "Throwable" topic and I can't read all of them. > > In short I have this situation: > > <?php > class SpecificHandler { > public function exception(Exception $e) { > .. do something very useful... > } > } > > function global_handler($e) { > SpecificHandler::exception($e); > } > > set_exception_handler("global_handler"); > ?> > > This happens because the specific handler will output the exception > according to the expected format (HTML, JSON, or even an image). > > Now after upgrading to PHP7 when one of the new Error exception is thrown, > I get the following error: > > PHP Fatal error: Uncaught TypeError: Argument 1 passed to > SpecificHandler::exception() must be an instance of Exception, instance of > Error given, called in [...] > > Having been a PHP dev for 10 years now I know that the policy is to try to > break as little as possible while implementing new features, and I like > that. I know that sometimes things must be broken to progress, but in this > case maybe there is a very simple fix that I can suggest to avoid breaking > existing code, change set_handler_exception like this: > > set_exception_handler(callback function, bool also_throwables = false); > > The new parameter "also_throwables" defaults to false, so the same > behaviour as before is preserved. If you want it to catch also the new PHP7 > Error exceptions, you can just set it to true. > > What is your take on this? I know I can easily fix my code to work on both > PHP 5.x and PHP 7.x, but I really disliked this kind of BC. > > Kind regards > Giovanni > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php