class HandleExceptions

Properties

static string|null $reservedMemory

Reserved memory so that errors can be displayed properly on memory exhaustion.

static protected Application|null $app

The application instance.

static protected HandleExceptions|null $owner

The bootstrapper whose handlers are currently installed.

protected HandleExceptions|null $previous

The bootstrapper that owned the handlers before this one installed its own.

protected null|Application> $application

The application this bootstrapper installed its handlers for.

protected Closure|null $errorHandler

The error handler installed by this bootstrapper.

protected Closure|null $exceptionHandler

The exception handler installed by this bootstrapper.

protected string|null $displayErrors

The display_errors setting this bootstrapper replaced when it installed its handlers.

Methods

void
bootstrap(Application $app)

Bootstrap the given application.

bool
handleError(int $level, string $message, string $file = '', int $line = 0)

Report PHP deprecations, or convert PHP errors to ErrorException instances.

void
handleDeprecationError(string $message, string $file, int $line, int $level = E_DEPRECATED)

Report a deprecation to the "deprecations" logger.

bool
shouldIgnoreDeprecationErrors()

Determine if deprecation errors should be ignored.

void
ensureDeprecationLoggerIsConfigured(Repository $config)

Ensure the "deprecations" logger is configured.

void
ensureNullLogDriverIsConfigured(Repository $config)

Ensure the "null" log driver is configured.

void
handleException(Throwable $e)

Handle an uncaught exception from the application.

void
renderForConsole(Throwable $e)

Render an exception to the console.

void
handleShutdown()

Handle the PHP shutdown event.

FatalError
fatalErrorFromPhpError(array $error, int|null $traceOffset = null)

Create a new fatal error instance from an error array.

forwardsTo(string $method)

Forward a method call to the bootstrapper that currently owns the handlers.

bool
isDeprecation(int $level)

Determine if the error level is a deprecation.

bool
isFatal(int $type)

Determine if the error type is fatal.

getExceptionHandler()

Get an instance of the exception handler.

static void
release(Application $app)

Release the handlers installed for an application that is being discarded.

static void
flushState(TestCase|null $testCase = null)

Flush all static state.

static void
flushHandlersState(TestCase|null $testCase = null)

Flush the bootstrapper's global handlers state.

Details

at line 76
void bootstrap(Application $app)

Bootstrap the given application.

Parameters

Application $app

Return Value

void

at line 118
bool handleError(int $level, string $message, string $file = '', int $line = 0)

Report PHP deprecations, or convert PHP errors to ErrorException instances.

Deprecations are handled here even when silenced with @. Other errors excluded by error_reporting() are passed on to PHP's standard handler so error_get_last() still reports them.

Parameters

int $level
string $message
string $file
int $line

Return Value

bool

Exceptions

ErrorException

at line 136
void handleDeprecationError(string $message, string $file, int $line, int $level = E_DEPRECATED)

Report a deprecation to the "deprecations" logger.

Parameters

string $message
string $file
int $line
int $level

Return Value

void

at line 190
protected bool shouldIgnoreDeprecationErrors()

Determine if deprecation errors should be ignored.

Return Value

bool

at line 202
protected void ensureDeprecationLoggerIsConfigured(Repository $config)

Ensure the "deprecations" logger is configured.

Parameters

Repository $config

Return Value

void

at line 228
protected void ensureNullLogDriverIsConfigured(Repository $config)

Ensure the "null" log driver is configured.

Parameters

Repository $config

Return Value

void

at line 247
void handleException(Throwable $e)

Handle an uncaught exception from the application.

Note: Most exceptions can be handled via the try / catch block in the HTTP and Console kernels. But, fatal error exceptions must be handled differently since they are not normal exceptions.

Parameters

Throwable $e

Return Value

void

at line 277
protected void renderForConsole(Throwable $e)

Render an exception to the console.

Parameters

Throwable $e

Return Value

void

at line 285
void handleShutdown()

Handle the PHP shutdown event.

Return Value

void

at line 297
protected FatalError fatalErrorFromPhpError(array $error, int|null $traceOffset = null)

Create a new fatal error instance from an error array.

Parameters

array $error
int|null $traceOffset

Return Value

FatalError

at line 310
protected Closure forwardsTo(string $method)

Forward a method call to the bootstrapper that currently owns the handlers.

A released error or exception handler can return to the top of PHP's stack when a handler installed after it is removed, so it forwards to the current owner. Shutdown callbacks only run for their own owner, since the owner's callback is registered too. Without an owner, errors fall back to PHP.

Parameters

string $method

Return Value

Closure

at line 331
protected bool isDeprecation(int $level)

Determine if the error level is a deprecation.

Parameters

int $level

Return Value

bool

at line 339
protected bool isFatal(int $type)

Determine if the error type is fatal.

Parameters

int $type

Return Value

bool

at line 347
protected ExceptionHandler getExceptionHandler()

Get an instance of the exception handler.

Return Value

ExceptionHandler

at line 360
static void release(Application $app)

Release the handlers installed for an application that is being discarded.

Restores the handlers, display_errors setting and application that were active before the application was bootstrapped, so later errors are reported without its flushed container. Handlers and settings changed by other code stay in place.

Parameters

Application $app

Return Value

void

at line 390
static void flushState(TestCase|null $testCase = null)

Flush all static state.

Parameters

TestCase|null $testCase

Return Value

void

at line 411
static void flushHandlersState(TestCase|null $testCase = null)

Flush the bootstrapper's global handlers state.

Parameters

TestCase|null $testCase

Return Value

void