class ErrorHandler extends ErrorHandler

deprecated since version 2.3, to be removed in 3.0. Use the same class from the Debug component instead.

ErrorHandler.

Constants

TYPE_DEPRECATION

Methods

static ErrorHandler
register(ErrorHandler|int|null $handler = null, bool $replace = true)

Registers the error handler.

__construct(BufferingLogger $bootstrappingLogger = null)

No description

setDefaultLogger(LoggerInterface $logger, array|int $levels = null, bool $replace = false)

Sets a logger to non assigned errors levels.

array
setLoggers(array $loggers)

Sets a logger for each error level.

callable|null
setExceptionHandler(callable $handler)

Sets a user exception handler.

int
throwAt(int $levels, bool $replace = false)

Sets the PHP error levels that throw an exception when a PHP error occurs.

int
scopeAt(int $levels, bool $replace = false)

Sets the PHP error levels for which local variables are preserved.

int
traceAt(int $levels, bool $replace = false)

Sets the PHP error levels for which the stack trace is preserved.

int
screamAt(int $levels, bool $replace = false)

Sets the error levels where the @-operator is ignored.

bool
handleError(int $type, string $message, string $file, int $line)

Handles errors by filtering then logging them according to the configured bit fields.

handleException(Exception|Throwable $exception, array $error = null)

Handles an exception by logging then forwarding it to another handler.

static 
handleFatalError(array $error = null)

Shutdown registered function for handling PHP fatal errors.

static 
stackErrors()

Configures the error handler for delayed handling.

static 
unstackErrors()

Unstacks stacked errors and forwards to the logger.

getFatalErrorHandlers()

Gets the fatal error handlers.

setLevel(int|null $level) deprecated

Sets the level at which the conversion to Exception is done.

setDisplayErrors(int $displayErrors) deprecated

Sets the display_errors flag value.

static 
setLogger(LoggerInterface $logger, string $channel = 'deprecation') deprecated

Sets a logger for the given channel.

handle($level, $message, $file = 'unknown', $line = 0, $context = array()) deprecated

No description

handleFatal() deprecated

Handles PHP fatal errors.

Details

in ErrorHandler at line 123
static ErrorHandler register(ErrorHandler|int|null $handler = null, bool $replace = true)

Registers the error handler.

Parameters

ErrorHandler|int|null $handler The handler to register, or @deprecated (since version 2.6, to be removed in 3.0) bit field of thrown levels
bool $replace Whether to replace or not any existing handler

Return Value

ErrorHandler The registered error handler

in ErrorHandler at line 177
__construct(BufferingLogger $bootstrappingLogger = null)

Parameters

BufferingLogger $bootstrappingLogger

in ErrorHandler at line 192
setDefaultLogger(LoggerInterface $logger, array|int $levels = null, bool $replace = false)

Sets a logger to non assigned errors levels.

Parameters

LoggerInterface $logger A PSR-3 logger to put as default for the given levels
array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
bool $replace Whether to replace or not any existing logger

in ErrorHandler at line 226
array setLoggers(array $loggers)

Sets a logger for each error level.

Parameters

array $loggers Error levels to [LoggerInterface|null, LogLevel::*] map

Return Value

array The previous map

Exceptions

InvalidArgumentException

in ErrorHandler at line 279
callable|null setExceptionHandler(callable $handler)

Sets a user exception handler.

Parameters

callable $handler A handler that will be called on Exception

Return Value

callable|null The previous exception handler

Exceptions

InvalidArgumentException

in ErrorHandler at line 298
int throwAt(int $levels, bool $replace = false)

Sets the PHP error levels that throw an exception when a PHP error occurs.

Parameters

int $levels A bit field of E_* constants for thrown errors
bool $replace Replace or amend the previous value

Return Value

int The previous value

in ErrorHandler at line 321
int scopeAt(int $levels, bool $replace = false)

Sets the PHP error levels for which local variables are preserved.

Parameters

int $levels A bit field of E_* constants for scoped errors
bool $replace Replace or amend the previous value

Return Value

int The previous value

in ErrorHandler at line 340
int traceAt(int $levels, bool $replace = false)

Sets the PHP error levels for which the stack trace is preserved.

Parameters

int $levels A bit field of E_* constants for traced errors
bool $replace Replace or amend the previous value

Return Value

int The previous value

in ErrorHandler at line 359
int screamAt(int $levels, bool $replace = false)

Sets the error levels where the @-operator is ignored.

Parameters

int $levels A bit field of E_* constants for screamed errors
bool $replace Replace or amend the previous value

Return Value

int The previous value

in ErrorHandler at line 404
bool handleError(int $type, string $message, string $file, int $line)

Handles errors by filtering then logging them according to the configured bit fields.

Parameters

int $type One of the E_* constants
string $message
string $file
int $line

Return Value

bool Returns false when no handling happens so that the PHP engine can handle the error itself

Exceptions

ErrorException When $this->thrownErrors requests so

in ErrorHandler at line 565
handleException(Exception|Throwable $exception, array $error = null)

Handles an exception by logging then forwarding it to another handler.

Parameters

Exception|Throwable $exception An exception to handle
array $error An array as returned by error_get_last()

in ErrorHandler at line 643
static handleFatalError(array $error = null)

Shutdown registered function for handling PHP fatal errors.

Parameters

array $error An array as returned by error_get_last()

in ErrorHandler at line 735
static stackErrors()

Configures the error handler for delayed handling.

Ensures also that non-catchable fatal errors are never silenced.

As shown by http://bugs.php.net/42098 and http://bugs.php.net/60724 PHP has a compile stage where it behaves unusually. To workaround it, we plug an error handler that only stacks errors for later.

The most important feature of this is to prevent autoloading until unstackErrors() is called.

in ErrorHandler at line 743
static unstackErrors()

Unstacks stacked errors and forwards to the logger.

in ErrorHandler at line 772
protected FatalErrorHandlerInterface[] getFatalErrorHandlers()

Gets the fatal error handlers.

Override this method if you want to define more fatal error handlers.

Return Value

FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface

in ErrorHandler at line 788
setLevel(int|null $level) deprecated

deprecated since version 2.6, to be removed in 3.0. Use throwAt() instead.

Sets the level at which the conversion to Exception is done.

Parameters

int|null $level The level (null to use the error_reporting() value and 0 to disable)

in ErrorHandler at line 803
setDisplayErrors(int $displayErrors) deprecated

deprecated since version 2.6, to be removed in 3.0. Use throwAt() instead.

Sets the display_errors flag value.

Parameters

int $displayErrors The display_errors flag value

in ErrorHandler at line 824
static setLogger(LoggerInterface $logger, string $channel = 'deprecation') deprecated

deprecated since version 2.6, to be removed in 3.0. Use setLoggers() or setDefaultLogger() instead.

Sets a logger for the given channel.

Parameters

LoggerInterface $logger A logger interface
string $channel The channel associated with the logger (deprecation, emergency or scream)

in ErrorHandler at line 849
handle($level, $message, $file = 'unknown', $line = 0, $context = array()) deprecated

deprecated since version 2.6, to be removed in 3.0. Use handleError() instead.

Parameters

$level
$message
$file
$line
$context

in ErrorHandler at line 861
handleFatal() deprecated

deprecated since version 2.6, to be removed in 3.0. Use handleFatalError() instead.

Handles PHP fatal errors.