1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-24 10:06:08 +02:00

Add property types to all properties where possible

This commit is contained in:
Jordi Boggiano
2022-04-21 21:58:19 +02:00
parent 6634bd9b79
commit 0dac87975c
36 changed files with 201 additions and 250 deletions

View File

@@ -26,28 +26,33 @@ use Psr\Log\LogLevel;
*/
class ErrorHandler
{
private LoggerInterface $logger;
private Closure|null $previousExceptionHandler = null;
/** @var array<class-string, LogLevel::*> an array of class name to LogLevel::* constant mapping */
private array $uncaughtExceptionLevelMap = [];
/** @var callable|true|null */
private $previousErrorHandler = null;
/** @var Closure|true|null */
private Closure|bool|null $previousErrorHandler = null;
/** @var array<int, LogLevel::*> an array of E_* constant to LogLevel::* constant mapping */
private array $errorLevelMap = [];
private bool $handleOnlyReportedErrors = true;
private bool $hasFatalErrorHandler = false;
private string $fatalLevel = LogLevel::ALERT;
private string|null $reservedMemory = null;
/** @var mixed|null */
private $lastFatalTrace = null;
private const FATAL_ERRORS = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR];
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
public function __construct(
private LoggerInterface $logger
) {
}
/**
@@ -108,7 +113,7 @@ class ErrorHandler
$prev = set_error_handler([$this, 'handleError'], $errorTypes);
$this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap);
if ($callPrevious) {
$this->previousErrorHandler = $prev ?: true;
$this->previousErrorHandler = $prev !== null ? $prev(...) : true;
} else {
$this->previousErrorHandler = null;
}