set_exception_handler() Must Update Its Type To Throwable
All thrown issues were children of the Exception class. In PHP 7.0, all issues are children of Throwable. Exception is not only one of two classes implementing it, along with Error.
To keep compatibility, it is important to switch types.
PHP code
<?php
// PHP 5.6- typed with Exception
class foo {
static function bar(\Exception $e) {
print $e->getMessage();
}
}
set_exception_handler([Foo::class, 'bar']);
// Produces an error
1 / 0;
?>
Before
PHP Warning: Division by zero
Warning: Division by zero
After
PHP Fatal error: Uncaught TypeError: foo::bar(): Argument #1 ($e) must be of type Exception, DivisionByZeroError given
PHP version change
This behavior changed in 8.0.