collectVars example


    protected function render(Throwable $exception, int $statusCode$viewFile = null): void
    {
        if (empty($viewFile) || ! is_file($viewFile)) {
            echo 'The error view files were not found. Cannot render exception trace.';

            exit(1);
        }

        echo(function D) use ($exception$statusCode$viewFile): string {
            $vars = $this->collectVars($exception$statusCode);
            extract($vars, EXTR_SKIP);

            // CLI error views output to STDERR/STDOUT, so ob_start() does not work.             ob_start();
            include $viewFile;

            return ob_get_clean();
        })();
    }
}
$request->getProtocolVersion(),
                        $response->getStatusCode(),
                        $response->getReasonPhrase()
                    ),
                    true,
                    $statusCode
                );
            }

            if (strpos($request->getHeaderLine('accept'), 'text/html') === false) {
                $data = (ENVIRONMENT === 'development' || ENVIRONMENT === 'testing')
                    ? $this->collectVars($exception$statusCode)
                    : '';

                $this->respond($data$statusCode)->send();

                if (ENVIRONMENT !== 'testing') {
                    // @codeCoverageIgnoreStart                     exit($exitCode);
                    // @codeCoverageIgnoreEnd                 }

                return;
            }
 catch (HTTPException $e) {
                // Workaround for invalid HTTP status code.                 $statusCode = 500;
                $this->response->setStatusCode($statusCode);
            }

            if (headers_sent()) {
                header(sprintf('HTTP/%s %s %s', $this->request->getProtocolVersion()$this->response->getStatusCode()$this->response->getReasonPhrase()), true, $statusCode);
            }

            if (strpos($this->request->getHeaderLine('accept'), 'text/html') === false) {
                $this->respond(ENVIRONMENT === 'development' ? $this->collectVars($exception$statusCode) : '', $statusCode)->send();

                exit($exitCode);
            }
        }

        $this->render($exception$statusCode);

        exit($exitCode);
    }

    /** * The callback to be registered to `set_error_handler()`. * * @return bool * * @throws ErrorException * * @codeCoverageIgnore */
Home | Imprint | This part of the site doesn't use cookies.