Doc #70050 [Com]: set_exception_handler receives non-exception objects
| From: | jhdxr@php.net | Date: | Wed, 26 Aug 2015 17:48:29 +0000 |
| Subject: | Doc #70050 [Com]: set_exception_handler receives non-exception objects | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-12665@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70050&edit=1
ID: 70050
Comment by: jhdxr@php.net
Reported by: mfischer@php.net
Summary: set_exception_handler receives non-exception objects
Status: Analyzed
Type: Documentation Problem
Package: *General Issues
Operating System: Ubuntu 14.04.2 LTS
PHP Version: 7.0.0beta1
Block user comment: N
Private report: N
New Comment:
We have already mentioned this issue as one of the backward incompatible changes in migration part,
but in the doc of set_exception_handler, the handler's signature is still
> void handler ( Exception $ex )
and the note below only says we should not provide an explicit Exception type hint in php 7 ,
without any words about Throwable. I think we may list two different signature (php 5.*, php 7), or
make the note more clear.
Previous Comments:
------------------------------------------------------------------------
[2015-07-14 00:21:53] trowski@php.net
I think this issue is best addressed by clear documentation that upgrading to PHP 7 will require the
type declaration on exception handlers to be changed from Exception to Throwable. It should be noted
that an Error object and any future implementor of Throwable are still exceptions, they just
aren't instances of Exception. :) I apologize for the documentation nightmare, but this
isn't without precedence in other languages such as Python and Java.
------------------------------------------------------------------------
[2015-07-13 20:31:19] ab@php.net
As for me - what is bad is the name set_exception_handler which now catches Trowable indeed. But
IMHO - not invoking it only because of name is not handy. Then users have no catch all solution.
Given a similar issue exists in php5, IMHO it is a topic of documentation. It is too late to change
names or introducing a better solution in 7.0 :(
Thanks.
------------------------------------------------------------------------
[2015-07-13 07:15:45] laruence@php.net
Actually, I am kindof understand this problem. and maybe we should do some improvements.
that is, if the exception be throw is not an compatible exception type of exception_handler.
then the exception handler should not be called.
actually, this problem is also exists in php5, like
<?php
set_exception_handler(
function (ExceptionA $e) {
var_dump('yodo');
}
);
class exceptionA extends exception{};
throw new Exception("xxx");
------------------------------------------------------------------------
[2015-07-12 11:03:05] mfischer@php.net
> So what you're saying is that we need to make sure all of that documentation gets updated
> to reflect the new Throwable stuff, right?
No, I'm saying there's a BC problem.
>> everything which is thrown should be of type \Exception
> But... you already know this won't be the case: you voted in favor of the engine
> exceptions RFC.
I don't see the relevancy here. But since you insist on this point: I voted against introducing
a BaseException.
TBH I forgot about this RFC and how I voted and was kind of independently hit by this issue, which
to no-surprise matches how I voted and validates my past choice.
thanks,
- Markus
------------------------------------------------------------------------
[2015-07-12 10:20:26] requinix@php.net
So what you're saying is that we need to make sure all of that documentation gets updated to
reflect the new Throwable stuff, right?
>everything which is thrown should be of type \Exception
But... you already know this won't be the case: you voted in favor of the engine exceptions
RFC. Which clearly said that there will be a hierarchy of exceptions above Exception. And there was
all the discussion about this on the internals list.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=70050
--
Edit this bug report at https://bugs.php.net/bug.php?id=70050&edit=1