Doc #70050 [Opn]: set_exception_handler receives non-exception objects
| From: | mfischer@php.net | Date: | Sun, 12 Jul 2015 11:03:05 +0000 |
| Subject: | Doc #70050 [Opn]: set_exception_handler receives non-exception objects | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-12509@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
Updated by: mfischer@php.net
Reported by: mfischer@php.net
Summary: set_exception_handler receives non-exception objects
Status: Open
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:
> 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
Previous Comments:
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
[2015-07-12 10:11:57] mfischer@php.net
Description:
------------
A callable set with "set_exception_handler" receives objects which are not of type
Exception.
Why is the "Exception" in the example script typehinted?
Why not, the documentation states:
"This handler function needs to accept one parameter, which will be the exception object that
was thrown."
Which is not true anymore.
I welcome "Fatal error" being turned into something which is handleable, but this seems
like a BC break and IMHO everything which is thrown should be of type \Exception .
Test script:
---------------
<?php
set_exception_handler(
function (Exception $e) {
var_dump('yodo');
}
);
Foo::bar;
Expected result:
----------------
The handler should receive something which is an "Exception", not an "Error"
object.
Actual result:
--------------
$ php test.php
Fatal error: Uncaught TypeError: Argument 1 passed to {closure}() must be an instance of Exception,
instance of Error given in /vagrant/api.swat.io/test.php:3
Stack trace:
#0 [internal function]: {closure}(Object(Error))
#1 {main}
thrown in /vagrant/api.swat.io/test.php on line 3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70050&edit=1