Kraken\Throwable\ErrorHandler::handleShutdown PHP Method

handleShutdown() public static method

Invoke default Shutdown Handler.
public static handleShutdown ( boolean $forceKill = false )
$forceKill boolean
    public static function handleShutdown($forceKill = false)
    {
        $err = error_get_last();
        try {
            static::handleError($err['type'], $err['message'], $err['file'], $err['line']);
        } catch (\Error $ex) {
            echo call_user_func(static::$errHandler, $ex) . PHP_EOL;
        } catch (\Exception $ex) {
            echo call_user_func(static::$excHandler, $ex) . PHP_EOL;
        }
        if ($forceKill) {
            posix_kill(posix_getpid(), 9);
        }
    }

Usage Example

 /**
  * @param ContainerInterface $container
  */
 protected function register(ContainerInterface $container)
 {
     $core = $container->make('Kraken\\Core\\CoreInterface');
     $context = $container->make('Kraken\\Runtime\\RuntimeContextInterface');
     $env = new Environment($context, $core->getDataPath() . '/environment/.env');
     $env->setOption('error_reporting', E_ALL);
     $env->setOption('log_errors', '1');
     $env->setOption('display_errors', '0');
     $env->registerErrorHandler(['Kraken\\Throwable\\ErrorHandler', 'handleError']);
     $env->registerShutdownHandler(function () use($context) {
         ErrorHandler::handleShutdown($context->getType() === Runtime::UNIT_PROCESS);
     });
     $env->registerExceptionHandler(['Kraken\\Throwable\\ExceptionHandler', 'handleException']);
     $container->instance('Kraken\\Environment\\EnvironmentInterface', $env);
 }