Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe ErrorHandler

Fonctions membres publiques

 __construct (BufferingLogger $bootstrappingLogger=null, bool $debug=false)
 
 setDefaultLogger (LoggerInterface $logger, $levels=\E_ALL, bool $replace=false)
 
 setLoggers (array $loggers)
 
 setExceptionHandler (?callable $handler)
 
 throwAt (int $levels, bool $replace=false)
 
 scopeAt (int $levels, bool $replace=false)
 
 traceAt (int $levels, bool $replace=false)
 
 screamAt (int $levels, bool $replace=false)
 
 handleError (int $type, string $message, string $file, int $line)
 
 handleException (\Throwable $exception)
 

Fonctions membres publiques statiques

static register (self $handler=null, bool $replace=true)
 
static call (callable $function,... $arguments)
 
static handleFatalError (array $error=null)
 

Champs de données

 E_USER_DEPRECATED
 
 E_NOTICE => [null
 
 E_USER_NOTICE => [null
 
 E_STRICT => [null
 
 E_WARNING => [null
 
 E_USER_WARNING => [null
 
 E_COMPILE_WARNING => [null
 
 E_CORE_WARNING => [null
 
 E_USER_ERROR => [null
 
 E_RECOVERABLE_ERROR => [null
 
 E_COMPILE_ERROR => [null
 
 E_PARSE => [null
 
 E_ERROR => [null
 
 E_CORE_ERROR => [null
 

Fonctions membres protégées

 getErrorEnhancers ()
 

Fonctions membres privées

 reRegister (int $prev)
 
 renderException (\Throwable $exception)
 
 cleanTrace (array $backtrace, int $type, string &$file, int &$line, bool $throw)
 
 parseAnonymousClass (string $message)
 

Attributs privés

 $levels
 
 $loggers
 
 $thrownErrors = 0x1FFF
 
 $scopedErrors = 0x1FFF
 
 $tracedErrors = 0x77FB
 
 $screamedErrors = 0x55
 
 $loggedErrors = 0
 
 $configureException
 
 $debug
 
 $isRecursive = 0
 
 $isRoot = false
 
 $exceptionHandler
 
 $bootstrappingLogger
 

Attributs privés statiques

static $reservedMemory
 
static $toStringException
 
static $silencedErrorCache = []
 
static $silencedErrorCount = 0
 
static $exitCode = 0
 

Description détaillée

A generic ErrorHandler for the PHP engine.

Provides five bit fields that control how errors are handled:

  • thrownErrors: errors thrown as
  • loggedErrors: logged errors, when not -silenced
  • scopedErrors: errors thrown or logged with their local context
  • tracedErrors: errors logged with their stack trace
  • screamedErrors: never -silenced errors

Each error level can be logged by a dedicated PSR-3 logger object. Screaming only applies to logging. Throwing takes precedence over logging. Uncaught exceptions are logged as E_ERROR. E_DEPRECATED and E_USER_DEPRECATED levels never throw. E_RECOVERABLE_ERROR and E_USER_ERROR levels always throw. Non catchable errors that can be detected at shutdown time are logged when the scream bit field allows so. As errors have a performance cost, repeated errors are all logged, so that the developer can see them and weight them as more important to fix than others of the same level.

Auteur
Nicolas Grekas p@tch.nosp@m.work.nosp@m..com
Grégoire Pineau lyrix.nosp@m.x@ly.nosp@m.rixx..nosp@m.info

Documentation des constructeurs et destructeur

◆ __construct()

__construct ( BufferingLogger  $bootstrappingLogger = null,
bool  $debug = false 
)

Documentation des fonctions membres

◆ call()

static call ( callable  $function,
  $arguments 
)
static

Calls a function and turns any PHP error into .

Renvoie
mixed What $function(...$arguments) returns
Exceptions

Références $function, $message, et $type.

◆ cleanTrace()

cleanTrace ( array  $backtrace,
int  $type,
string &  $file,
int &  $line,
bool  $throw 
)
private

Cleans the trace by removing function arguments and the frames added by the error handler and DebugClassLoader.

Références $i, $type, class, et null.

Référencé par ErrorHandler\handleError().

◆ getErrorEnhancers()

getErrorEnhancers ( )
protected

Override this method if you want to define more error enhancers.

Renvoie
ErrorEnhancerInterface[]

Référencé par ErrorHandler\handleException().

◆ handleError()

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

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

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

Références ErrorHandler\$configureException, $context, $i, $id, $message, ErrorHandler\$screamedErrors, $type, ErrorHandler\cleanTrace(), LogLevel\DEBUG, ErrorHandler\E_RECOVERABLE_ERROR, ErrorHandler\E_USER_DEPRECATED, ErrorHandler\E_USER_ERROR, elseif, ErrorHandler\handleException(), null, et ErrorHandler\parseAnonymousClass().

◆ handleException()

handleException ( \Throwable  $exception)

◆ handleFatalError()

static handleFatalError ( array  $error = null)
static

Shutdown registered function for handling PHP fatal errors.

Paramètres
array | null$errorAn array as returned by error_get_last()

Références ErrorHandler\$exitCode, ErrorHandler\E_COMPILE_ERROR, ErrorHandler\E_CORE_ERROR, ErrorHandler\E_ERROR, ErrorHandler\E_PARSE, elseif, et null.

◆ parseAnonymousClass()

parseAnonymousClass ( string  $message)
private

Parse the error message by removing the anonymous class notation and using the parent class instead if possible.

Références $message.

Référencé par ErrorHandler\handleError(), et ErrorHandler\handleException().

◆ register()

static register ( self  $handler = null,
bool  $replace = true 
)
static

Registers the error handler.

Références elseif, et null.

Référencé par Debug\enable().

◆ renderException()

renderException ( \Throwable  $exception)
private

Renders the given exception.

As this method is mainly called during boot where nothing is yet available, the output is always either HTML or CLI depending where PHP runs.

Références $name, $renderer, et $value.

◆ reRegister()

reRegister ( int  $prev)
private

Re-registers as a PHP error handler if levels changed.

Références $this, et null.

Référencé par ErrorHandler\setLoggers(), et ErrorHandler\throwAt().

◆ scopeAt()

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

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

Paramètres
int$levelsA bit field of E_* constants for scoped errors
bool$replaceReplace or amend the previous value
Renvoie
int The previous value

Références ErrorHandler\$levels, et ErrorHandler\$scopedErrors.

◆ screamAt()

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

Sets the error levels where the -operator is ignored.

Paramètres
int$levelsA bit field of E_* constants for screamed errors
bool$replaceReplace or amend the previous value
Renvoie
int The previous value

Références ErrorHandler\$levels, et ErrorHandler\$screamedErrors.

◆ setDefaultLogger()

setDefaultLogger ( LoggerInterface  $logger,
  $levels = \E_ALL,
bool  $replace = false 
)

Sets a logger to non assigned errors levels.

Paramètres
LoggerInterface$loggerA PSR-3 logger to put as default for the given levels
array | int | null$levelsAn array map of E_* to LogLevel::* or an integer bit field of E_* constants
bool$replaceWhether to replace or not any existing logger

Références ErrorHandler\$levels, ErrorHandler\$loggers, $type, null, et ErrorHandler\setLoggers().

Référencé par ErrorHandler\__construct().

◆ setExceptionHandler()

setExceptionHandler ( ?callable  $handler)

Sets a user exception handler.

Paramètres
\Throwablecallable(,$e,)|null$handler
Renvoie
callable|null The previous exception handler

Références ErrorHandler\$exceptionHandler.

◆ setLoggers()

setLoggers ( array  $loggers)

Sets a logger for each error level.

Paramètres
array$loggersError levels to [LoggerInterface|null, LogLevel::*] map
Renvoie
array The previous map
Exceptions

Références ErrorHandler\$loggedErrors, ErrorHandler\$loggers, $type, elseif, ThrowableUtils\getSeverity(), null, et ErrorHandler\reRegister().

Référencé par ErrorHandler\setDefaultLogger().

◆ throwAt()

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

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

Paramètres
int$levelsA bit field of E_* constants for thrown errors
bool$replaceReplace or amend the previous value
Renvoie
int The previous value

Références ErrorHandler\$levels, ErrorHandler\$thrownErrors, ErrorHandler\E_RECOVERABLE_ERROR, ErrorHandler\E_USER_ERROR, et ErrorHandler\reRegister().

◆ traceAt()

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

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

Paramètres
int$levelsA bit field of E_* constants for traced errors
bool$replaceReplace or amend the previous value
Renvoie
int The previous value

Références ErrorHandler\$levels, et ErrorHandler\$tracedErrors.

Documentation des champs

◆ $bootstrappingLogger

$bootstrappingLogger
private

Référencé par ErrorHandler\__construct().

◆ $configureException

$configureException
private

Référencé par ErrorHandler\handleError().

◆ $debug

$debug
private

Référencé par ErrorHandler\__construct().

◆ $exceptionHandler

$exceptionHandler
private

◆ $exitCode

$exitCode = 0
staticprivate

◆ $isRecursive

$isRecursive = 0
private

◆ $isRoot

$isRoot = false
private

◆ $levels

$levels
private
Valeur initiale :
= [
\E_DEPRECATED => 'Deprecated'

Référencé par ErrorHandler\scopeAt(), ErrorHandler\screamAt(), ErrorHandler\setDefaultLogger(), ErrorHandler\throwAt(), et ErrorHandler\traceAt().

◆ $loggedErrors

$loggedErrors = 0
private

◆ $loggers

$loggers
private
Valeur initiale :
= [
\E_DEPRECATED => [null, LogLevel::INFO]

Référencé par ErrorHandler\setDefaultLogger(), et ErrorHandler\setLoggers().

◆ $reservedMemory

$reservedMemory
staticprivate

◆ $scopedErrors

$scopedErrors = 0x1FFF
private

Référencé par ErrorHandler\scopeAt().

◆ $screamedErrors

$screamedErrors = 0x55
private

◆ $silencedErrorCache

$silencedErrorCache = []
staticprivate

◆ $silencedErrorCount

$silencedErrorCount = 0
staticprivate

◆ $thrownErrors

$thrownErrors = 0x1FFF
private

Référencé par ErrorHandler\throwAt().

◆ $toStringException

$toStringException
staticprivate

◆ $tracedErrors

$tracedErrors = 0x77FB
private

Référencé par ErrorHandler\traceAt().

◆ E_COMPILE_ERROR

E_COMPILE_ERROR => [null

◆ E_COMPILE_WARNING

E_COMPILE_WARNING => [null

◆ E_CORE_ERROR

E_CORE_ERROR => [null

◆ E_CORE_WARNING

E_CORE_WARNING => [null

◆ E_ERROR

E_ERROR => [null

◆ E_NOTICE

E_NOTICE => [null

◆ E_PARSE

E_PARSE => [null

◆ E_RECOVERABLE_ERROR

E_RECOVERABLE_ERROR => [null

◆ E_STRICT

E_STRICT => [null

◆ E_USER_DEPRECATED

E_USER_DEPRECATED
Valeur initiale :
=> 'User Deprecated',
\E_NOTICE => 'Notice',
\E_USER_NOTICE => 'User Notice',
\E_STRICT => 'Runtime Notice',
\E_WARNING => 'Warning',
\E_USER_WARNING => 'User Warning',
\E_COMPILE_WARNING => 'Compile Warning',
\E_CORE_WARNING => 'Core Warning',
\E_USER_ERROR => 'User Error',
\E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
\E_COMPILE_ERROR => 'Compile Error',
\E_PARSE => 'Parse Error',
\E_ERROR => 'Error',
\E_CORE_ERROR => 'Core Error',
]

Référencé par ErrorHandler\handleError().

◆ E_USER_ERROR

E_USER_ERROR => [null

◆ E_USER_NOTICE

E_USER_NOTICE => [null

◆ E_USER_WARNING

E_USER_WARNING => [null

◆ E_WARNING

E_WARNING => [null

La documentation de cette classe a été générée à partir du fichier suivant :