<?php use Weew\ErrorHandler\ErrorHandler; use Weew\ErrorHandler\ErrorType; require __DIR__ . '/../../../../vendor/autoload.php'; $errorHandler = new ErrorHandler(); $errorHandler->enableFatalErrorHandling(); $errorHandler->addFatalErrorHandler(function () { echo 'handled fatal'; return true; }); trigger_error('error', ErrorType::FOO);
public function test_fatal_error_from_fatal_error_handler_is_handled() { $handler = new ErrorHandler(); $fatalError = new FatalError(ErrorType::PARSE, 'foo', 'bar', 'baz'); $handler->addFatalErrorHandler(function (IError $error) { throw new Exception(); }); try { $handler->handleFatalError($fatalError); } catch (Exception $ex) { } ob_start(); }