Bug #70050 [NEW]: set_exception_handler receives non-exception objects
From: mfischer
Operating system: Ubuntu 14.04.2 LTS
PHP version: 7.0.0beta1
Package: *General Issues
Bug Type: Bug
Bug description:set_exception_handler receives non-exception objects
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 bug report at https://bugs.php.net/bug.php?id=70050&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70050&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70050&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70050&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70050&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70050&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70050&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70050&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70050&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70050&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70050&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70050&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70050&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70050&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70050&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70050&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70050&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70050&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70050&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70050&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70050&r=mysqlcfg
Thread (1 message)
- mfischer@php.net