Authenticates the request, runs the frontend helpers defined by the
request, and registers its own shutdown() method for execution at
hook_eofe in tslib/class.tslib_fe.php.

@return void
180110
public function run()
    {
        if (!$this->request->isAuthenticated()) {
            $this->logger->log(
                SolrLogManager::ERROR,
                'Invalid Index Queue Frontend Request detected!',
                [
                    'page indexer request' => (array)$this->request,
                    'index queue header' => $_SERVER['HTTP_X_TX_SOLR_IQ']
                ]
            );
            http_response_code(403);
            die('Invalid Index Queue Request!');
        }

        $this->dispatcher->dispatch($this->request, $this->response);

        // register shutdown method here instead of in ext_localconf.php to
        // allow frontend helpers to execute at hook_eofe in
        // tslib/class.tslib_fe.php before shutting down
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe'][__CLASS__] = self::class . '->shutdown';
    }
343347
public function run()
    {

        // register the default autoloader
        require SERVER_AUTOLOADER;

        // register shutdown handler
        register_shutdown_function(array(&$this, "shutdown"));

        // we need to register the class loaders again
        $application = $this->application;
        $application->registerClassLoaders();

        // register the applications annotation registries
        $application->registerAnnotationRegistries();

        // add the application instance to the environment
        Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application);

        // create s simulated request/session ID whereas session equals request ID
        Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $sessionId = SessionUtils::generateRandomString());
        Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $sessionId);

        // load application and message instance
        $message = $this->message;

        try {
            // create an intial context instance
            $initialContext = new InitialContext();
            $initialContext->injectApplication($application);

            // load the callbacks for the actual message state
            foreach ($message->getCallbacks($message->getState()) as $callback) {
                // explode the lookup + method name
                list ($lookupName, $methodName) = $callback;
                // lookup the bean instance and invoke the callback
                call_user_func(array($initialContext->lookup($lookupName), $methodName), $message);
            }

        } catch (\Exception $e) {
            \error($e->__toString());
        }
    }
439063
public function run()
    {

        try {
            // register shutdown handler
            register_shutdown_function($this->getDefaultShutdownMethod());

            // bootstrap the daemon
            $this->bootstrap();

            // mark the daemon as successfully shutdown
            $this->synchronized(function ($self) {
                $self->state = EnumState::get(EnumState::RUNNING);
            }, $this);

            // keep the daemon running
            while ($this->keepRunning()) {
                try {
                    $this->iterate($this->getDefaultTimeout());
                } catch (\Exception $e) {
                    $this->log(LogLevel::ERROR, $e->__toString());
                }
            }

            // clean up the instances and free memory
            $this->cleanUp();

            // mark the daemon as successfully shutdown
            $this->synchronized(function ($self) {
                $self->state = EnumState::get(EnumState::SHUTDOWN);
            }, $this);

        } catch (\Exception $e) {
            $this->log(LogLevel::ERROR, $e->__toString());
        }
    }
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;
	}
403914
private function registerShutdownHandler()
    {
        if ($this->shutdownFunctionRegistered) {
            return;
        }

        $subscriber = $this;
        register_shutdown_function(function () use ($subscriber) {
            if (!$error = error_get_last()) {
                return;
            }

            // Don't fail on non-blcoking errors!
            if (\in_array($error['type'], [E_DEPRECATED, E_USER_DEPRECATED, E_CORE_WARNING, E_CORE_ERROR], true)) {
                return;
            }

            $subscriber->handleErrors();
        });

        $this->shutdownFunctionRegistered = true;
    }
1222406
public function shutdownFunction() {
		if(($e=error_get_last()) && $e !== static::$errorAtStart) {
			foreach($this->ignoreDirs as $dir) {
				if(strpos($e['file'], $dir) === 0)
					return;
			}

			while(ob_get_level()) ob_end_clean();
			$exceptionHandler = set_exception_handler(function() {});
			restore_exception_handler();
			$exception = new FatalErrorException($e['message'], $e['type'], 0, $e['file'], $e['line']);
			call_user_func_array($exceptionHandler, [$exception]);
		}
	}
1207832
public function logout()
    {

        // load the authentication manager and try to authenticate this request
        /** @var \AppserverIo\Psr\Auth\AuthenticationManagerInterface $authenticationManager */
        if ($authenticationManager = $this->getAuthenticationManager()) {
            // try to load the authentication managers default authenticator
            if (($authenticator = $authenticationManager->getAuthenticator()) == null) {
                throw new ServletException('Can\'t find default authenticator');
            }

            // logout the actual user
            $authenticator->logout($this);
        }
    }
98346
public static function registerShutdownFunction()
    {
        Base::getLog()->debug(__METHOD__ . ' register shutdown function');

        $args = func_get_args();
        $callback = array_shift($args);
        if ( ! is_callable($callback))
        {
            return false;
        }

        self::$shutdownFunctions[] = [
            'callback' => $callback,
            'params'   => $args,
        ];
        return true;
    }
304741
final public static function shutdownFunctionHandler()
    {
        $lasterror = error_get_last();
        if (!FEnv::isset("framework.env")) {
            die($lasterror['message']);
        }

        if (isset($lasterror['type']) == true) {
            if ($lasterror['type'] === E_ERROR) {
                $mess = explode("Stack trace", $lasterror['message']);
                throw new Server500(new \ArrayObject(array("explain" => $mess[0],
                    "type_error" => self::errorMap($lasterror['type']),
                    "file_error" => $lasterror["file"], "line_error" => $lasterror["line"])));
            } elseif ($lasterror['type'] === E_PARSE) {
                $mess = explode("Stack trace", $lasterror['message']);
                throw new Server500(new \ArrayObject(array("explain" => $mess[0],
                    "type_error" => self::errorMap($lasterror['type']),
                    "file_error" => $lasterror["file"], "line_error" => $lasterror["line"])));
            } elseif ($lasterror['type'] === E_WARNING) {
                $mess = explode("Stack trace", $lasterror['message']);
                throw new Server500(new \ArrayObject(array("explain" => $mess[0],
                    "type_error" => self::errorMap($lasterror['type']),
                    "file_error" => $lasterror["file"], "line_error" => $lasterror["line"])));
            } else {
                trigger_error($lasterror['message']);
            }
        }

        exit(1);
    }
1093656
public function register()
    {
        ini_set('display_errors', false);
        set_exception_handler([$this, 'handleException']);
        set_error_handler([$this, 'handleError']);

        if ($this->memoryReserveSize > 0) {
            $this->_memoryReserve = str_repeat('x', $this->memoryReserveSize);
        }
        register_shutdown_function([$this, 'handleFatalError']);
    }
386515
protected function registerShutdownCallback()
    {
        $this->swooleServer->on('Shutdown', function () {
            $this->events->dispatch(new Events\ServerShutdown($this));

            $this->dispatchEvent('Shutdown', $this);
        });
    }
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']));
        }
    }
333046
public function register()
    {
        set_exception_handler(new ExceptionHandler($this->request, $this->factory));
        register_shutdown_function(new ShutdownHandler($this->request, $this->factory));
    }
713089
public function onShutdown()
    {
        try {
            $e = error_get_last();
            if (in_array($e['type'], [
                E_ERROR,
                E_PARSE,
                E_CORE_ERROR,
                E_COMPILE_ERROR,
                E_USER_ERROR,
                E_RECOVERABLE_ERROR
            ]))
            {
                Log::error($e['message'], [
                    'trace' => [],
                    'errorFile'  =>  $e['file'],
                    'errorLine'  =>  $e['line'],
                ]);
            }
            $logger = App::getBean('Logger');
            $logger->save();
        } catch(\Throwable $th) {
            echo $th->getMessage(), ' ', $th->getFile(), ':', $th->getLine(), PHP_EOL;
        }
    }
219900
public static function applyShutdownFunction()
    {
        Base::getLog()->debug(__METHOD__ . ' apply shutdown functions');
        foreach (self::$shutdownFunctions as $pair)
        {
            call_user_func_array(Arr::get($pair, 'callback'), Arr::get($pair, 'params'));
        }
    }
1323052
public function setup() {
		$this->errorHandler = $errorHandler = \Asgard\Debug\ErrorHandler::register();
		if(php_sapi_name() !== 'cli')
			\Asgard\Debug\Debug::setFormat('html');

		register_shutdown_function([$this, 'shutdownFunction']);
		$this->addShutdownCallback([$errorHandler, 'shutdownFunction']);

		$compiledFile = $this->getCompiledFile();
		if($compiledFile && file_exists($compiledFile))
			include_once $compiledFile;

		return $this;
	}
1085428
public static function shutdownHandler(): void
    {
        if (!self::$reserved) {
            return;
        }

        $error = \error_get_last();
        if (\in_array($error['type'],
            [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE, E_RECOVERABLE_ERROR, E_USER_ERROR], true
        )) {
            self::exceptionHandler(
                Helpers::fixStack(
                    new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'])
                ), false
            );
        }
    }