blink\core\ErrorException::isFatalError PHP Method

isFatalError() public static method

Returns if error is one of fatal type.
public static isFatalError ( array $error ) : boolean
$error array error got from error_get_last()
return boolean if error is one of fatal type
    public static function isFatalError($error)
    {
        return isset($error['type']) && in_array($error['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING]);
    }

Usage Example

Example #1
0
 public function handleFatalError()
 {
     unset($this->_memoryReserve);
     // load ErrorException manually here because autoloading them will not work
     // when error occurs while autoloading a class
     if (!class_exists('blink\\core\\ErrorException', false)) {
         require_once __DIR__ . '/ErrorException.php';
     }
     $error = error_get_last();
     if (ErrorException::isFatalError($error)) {
         $exception = new ErrorException($error['message'], $error['type'], $error['type'], $error['file'], $error['line']);
         $this->exception = $exception;
         $this->report($exception);
         if ($this->discardExistingOutput) {
             $this->clearOutput();
         }
         //$this->renderException($exception);
         // need to explicitly flush logs because exit() next will terminate the app immediately
         exit(1);
     }
 }