Handles fatal PHP errors
截获致命性错误，注册到 register_shutdown_function 中，由脚本完成时或exit时调用以作日志

@return void
773730
public function handleFatalError()
    {
        unset($this->_memoryReserve);
        
        $error = error_get_last();
        
        if (static::isFatalError($error)) {
            $exception = new ErrorException($error['message'], $error['type'], $error['type'], $error['file'], $error['line']);
            $this->exception = $exception;

            $this->logException($exception);
            
            /*
            if ($this->options['discard_output']) {
                $this->clearOutput();
            }
            
            $this->renderException($exception);
            */
            //debug_print_backtrace();
            
            exit(1);
        }
    }
714021
public function shutdownHandler()
    {
        // We can't throw exceptions in the shutdown handler.
        $this->treatErrorsAsExceptions(false);

        $error = error_get_last();
        if ($error && $error['type'] & $this->fatalErrors) {
            $this->errorHandler(
                $error['type'],
                $error['message'],
                $error['file'],
                $error['line']
            );
        }
    }
1160192
public static function shutdown()
    {
        if (!is_null($error = error_get_last()) && self::isFatal($error['type'])) {
            self::exception(new Exception(
                $error['type'], $error['message'], $error['file'], $error['line']
            ));
        }

        // TODO 写入日志
    }
1165786
public static function shutdown()
    {
        $last_error = error_get_last();

        if (!is_null($last_error) && $last_error['type'] === E_ERROR) {
            $code = $last_error['type'];
            $message = $last_error['message'];
            $file = $last_error['file'];
            $line = $last_error['line'];

            try {
                // Log the error message
                if (self::$_Log instanceof Log) {
                    self::$_Log->pushToLog(sprintf(
                        '%s %s: %s%s%s',
                        __CLASS__,
                        $code,
                        $message,
                        ($line ? " on line $line" : null),
                        ($file ? " of file $file" : null)
                    ), $code, true);
                }

                ob_clean();

                // Display the error message
                echo self::renderHtml(
                    'fatalerror.fatal',
                    'Fatal Error',
                    $message,
                    $file,
                    $line
                );
            } catch (Exception $e) {
                echo "<pre>";
                echo 'A severe error occurred whilst trying to handle an exception, check the Symphony log for more details' . PHP_EOL;
                echo $e->getMessage() . ' on ' . $e->getLine() . ' of file ' . $e->getFile() . PHP_EOL;
            }
        }
    }
405424
public function shutdownHandler()
    {
        $lastError = error_get_last();

        if (is_array($lastError)) {
            $this->errorHandler(
                $lastError[ 'type' ],
                $lastError[ 'message' ],
                $lastError[ 'file' ],
                $lastError[ 'line' ]
            );
        }
    }
570947
public function registerFatalAction()
    {
        // As of PHP Version 7.0.2, the register_tick_function() causes PHP to
        // crash, with a connection reset! We need to check the version to avoid
        // this, and then tell the dev what happened.
        // Not to mention that fatals got removed anyway.
        if (version_compare(phpversion(), '7.0.0', '>=')) {
            // Too high! 420 Method Failure :-(
            $this->pool->messages->addMessage($this->pool->messages->getHelp('php7yellow'));
            krexx($this->pool->messages->getHelp('php7'));

            // Just return, there is nothing more to do here.
            return $this;
        }

        // Do we need another shutdown handler?
        if (static::$krexxFatal === null) {
            static::$krexxFatal = $this->pool->createClass('Brainworxx\\Krexx\\Errorhandler\\Fatal');
            declare(ticks = 1);
            register_shutdown_function(
                array(
                    static::$krexxFatal,
                    'shutdownCallback',
                )
            );
        }

        static::$krexxFatal->setIsActive(true);
        $this->fatalShouldActive = true;
        register_tick_function(array($this::$krexxFatal, 'tickCallback'));

        return $this;
    }
980723
public static function fatalErrorHandler() {
				
		// get fatal error array
		$error = error_get_last();

		if (!is_null($error)) {

			// command line log has date and plain text
			if ('cli' == php_sapi_name()) {
				
				print date(DATE_RFC2822) . "\nFatal error (" . $error['type'] . ') on file ' .
					$error['file'] . ' line ' . $error['line'] . ': ' . $error['message'] . "\n";

			// format for an HTML web print
			} else {

				print '<div style="background-color:#f1f1f1;border:2px solid red;margin:10px 0;padding:12px 16px">' .
						PRODUCT_NAME . ' fatal error: ' . $error['message'] . '</div>';

			}
		
			// get admin emails by options
			$emails = array_filter(explode(',', Options::get('admin_emails')));
			
			if (count($emails)) {

				// get proper server description
				if (isset($_SERVER['SERVER_NAME'])) {
					$server = $_SERVER['SERVER_NAME'];
				} else if (isset($_SERVER['SERVER_ADDR'])) {
					$server = $_SERVER['SERVER_ADDR'];
				} else {
					$server = '[Unknown]';
				}
			
				// build email parameters
				$subject = PRODUCT_NAME . ' fatal error on ' . $server;
				$message = PRODUCT_NAME . ' generated a fatal error on server ' .  BASE_HREF . ' as of ' .
					date(DATE_RFC2822) . " UTC." . PHP_EOL . PHP_EOL .
					'Error [type ' . $error['type'] . ']: ' . PHP_EOL .
					$error['message'] . ' (' . $error['file'] . ' line ' . $error['line'] . ')';
				$headers = 'From: ' . PRODUCT_NAME . ' <' . strtolower(PRODUCT_NAME) . '@' . $server . '>';

				// send email to each admin
				foreach ($emails as $email) {
					mail($email, $subject, $message, $headers);
				}
				
			}
			
		}
	
	}
945821
public function shutdown()
    {
        // check if there was a fatal error caused shutdown
        if ($lastError = error_get_last()) {
            // initialize type + message
            $type = 0;
            $message = '';
            // extract the last error values
            extract($lastError);
            // query whether we've a fatal/user error
            if ($type === E_ERROR || $type === E_USER_ERROR) {
                error_log($message);
            }
        }
    }
271015
protected function registerShutdownHandlers()
    {
        $self = $this;
        register_shutdown_function(function () use ($self) {
            if (($error = error_get_last()) && in_array($error['type'], array(E_PARSE, E_ERROR, E_USER_ERROR))) {
                $self->shutdown(1, $error);
            } else {
                $self->emit('finish', 0);
                $self->shutdown();
            }

            if (!is_resource($self->queue) || !msg_stat_queue($self->queue)) {
                return;
            }

            msg_remove_queue($self->queue);
        });
    }
1176577
public function shutdown()
    {
        // check if there was a fatal error caused shutdown
        if ($lastError = error_get_last()) {
            // initialize type + message
            $type = 0;
            $message = '';
            // extract the last error values
            extract($lastError);
            // query whether we've a fatal/user error
            if ($type === E_ERROR || $type === E_USER_ERROR) {
                $this->getInitialContext()->getSystemLogger()->critical($message);
            }
        }
    }
216169
function register()
	{
		set_error_handler(array($this,'_handleError'));
		set_exception_handler(array($this,'_handleException'));
		register_shutdown_function(array($this,'_shutdown'));
		$this->_registered = true;
		return $this;
	}
1232160
public function fatalHandler()
    {
        $error = $this->getLastError();
        
        if ($this->isRegistered() && $this->isFatalError($error)) {
            if (defined('FRAMEWORK_PATH')) {
                chdir(FRAMEWORK_PATH);
            }

            if ($this->isMemoryExhaustedError($error)) {
                // We can safely change the memory limit be the reserve amount because if suhosin is relevant
                // the memory will have been decreased prior to exhaustion
                $this->changeMemoryLimit($this->reserveMemory);
            }

            $exception = $this->createException(
                $error['message'],
                $error['type'],
                $error['file'],
                $error['line']
            );

            $context = array(
                'file' => $error['file'],
                'line' => $error['line']
            );

            if ($this->reportBacktrace) {
                $context['backtrace'] = $this->getBacktraceReporter()->getBacktrace();
            }

            if ($this->exceptionInContext) {
                $context['exception'] = $exception;
            }

            $this->logger->critical($error['message'], $context);

            // Fatal errors should be reported when live as they stop the display of regular output
            if ($this->showErrors || $this->getEnvReporter()->isLive()) {
                $this->getErrorReporter()->reportError($exception);
            }
        }
    }
26801
public function handleShutdown()
    {
        $error = $this->system->getLastError();
        if ($error === null) {
            return;
        }
        if (($error['type'] & error_reporting()) === 0) {
            return;
        }
        if ($this->lastError !== null &&
            $error['message'] === $this->lastError['message'] &&
            $error['file'] === $this->lastError['file'] &&
            $error['line'] === $this->lastError['line']) {
            return;
        }
        $trace = [[
            'file' => $error['file'],
            'line' => $error['line'],
        ]];
        $exc = new Fatal($error['message'], $trace);
        $notice = $this->buildNotice($exc);

        // If we reached this step, we are in shutdown handler.
        // An exception thrown in a shutdown handler will not be propagated
        // to the exception handler. Pass that information along.
        $this->canThrowExceptions = false;

        if ($error && $this->isLevelFatal($error['type'])) {
            // If there was a fatal error,
            // it was not handled in handleError yet.
            $this->handleError(
                $error['type'],
                $error['message'],
                $error['file'],
                $error['line']
            );
        }
		if($error["type"] != 0) {
            //call_user_func($this->errorHandler,new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']));
			//log_error( $error["type"], $error["message"], $error["file"], $error["line"] );
		}
    }
1336469
public static function shutdown()
    {
        if (\is_null($e = \error_get_last()) === false) {
            self::exceptionHandler(new \sb\Exception($e['type'], $e['message'], $e['file'], $e['line']));
        }
    }
95732
public function handleShutdown()
    {
        $this->canThrowExceptions = false;

        $error = $this->system->getLastError();
        if ($error && Misc::isLevelFatal($error['type'])) {
            $this->handleError($error['type'], $error['message'], $error['file'], $error['line']);
        }
    }
1113643
public static function shutdown()
    {
        if (defined('__TIMER_OUT_FILE__')) {
            $strTimerOutput = Timer::varDump(false);
            if ($strTimerOutput) {
                file_put_contents(__TIMER_OUT_FILE__, $strTimerOutput . "\n", FILE_APPEND);
            }
        }

        $error = error_get_last();
        if ($error &&
            is_array($error) &&
            (!defined('\CodeGen::DebugMode') || \CodeGen::DebugMode)
        ) { // if we are codegenning, only error if we are in debug mode. Prevents chmod error.

            QcubedHandleError(
                $error['type'],
                $error['message'],
                $error['file'],
                $error['line'],
                ''
            );
        }
        //flush();	// required for hhvm
        //error_log("Flushed");
    }
1367740
public static function shutdown() 
	{	
		// enter shutdown context
		static::$in_shutdown_process = true;
		
		$error = error_get_last();
		
		// if the error is not null and the level is 
		// fatal. Forward the error to our error handler.
		if ( !is_null( $error ) && static::is_fatal_level( $error['type'] ) ) 
		{
			static::error( $error['type'], $error['message'], $error['file'], $error['line'] );
		}
	}