mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-30 09:50:26 +02:00
Fix error handler to not receive $context anymore as php8 dropped that
This commit is contained in:
@@ -110,7 +110,7 @@ class ErrorHandler
|
||||
*/
|
||||
public function registerErrorHandler(array $levelMap = [], bool $callPrevious = true, int $errorTypes = -1, bool $handleOnlyReportedErrors = true): self
|
||||
{
|
||||
$prev = set_error_handler([$this, 'handleError'], $errorTypes);
|
||||
$prev = set_error_handler($this->handleError(...), $errorTypes);
|
||||
$this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap);
|
||||
if ($callPrevious) {
|
||||
$this->previousErrorHandler = $prev !== null ? $prev(...) : true;
|
||||
@@ -129,7 +129,7 @@ class ErrorHandler
|
||||
*/
|
||||
public function registerFatalHandler($level = null, int $reservedMemorySize = 20): self
|
||||
{
|
||||
register_shutdown_function([$this, 'handleFatalError']);
|
||||
register_shutdown_function($this->handleFatalError(...));
|
||||
|
||||
$this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize);
|
||||
$this->fatalLevel = null === $level ? LogLevel::ALERT : $level;
|
||||
@@ -200,12 +200,7 @@ class ErrorHandler
|
||||
exit(255);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function handleError(int $code, string $message, string $file = '', int $line = 0, ?array $context = []): bool
|
||||
private function handleError(int $code, string $message, string $file = '', int $line = 0): bool
|
||||
{
|
||||
if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) {
|
||||
return false;
|
||||
@@ -223,8 +218,9 @@ class ErrorHandler
|
||||
|
||||
if ($this->previousErrorHandler === true) {
|
||||
return false;
|
||||
} elseif ($this->previousErrorHandler) {
|
||||
return (bool) ($this->previousErrorHandler)($code, $message, $file, $line, $context);
|
||||
}
|
||||
if ($this->previousErrorHandler) {
|
||||
return (bool) ($this->previousErrorHandler)($code, $message, $file, $line);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@@ -176,7 +176,8 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
);
|
||||
$errorHandler = ErrorHandler::register($this->initLogger($classesPartialsTraceIgnore ? ['classesPartialsTraceIgnore' => $classesPartialsTraceIgnore] : []), false);
|
||||
$errorHandler->registerErrorHandler([], false, E_USER_WARNING);
|
||||
$errorHandler->handleError($code, $message, $file, $line);
|
||||
$reflMethod = new \ReflectionMethod($errorHandler, 'handleError');
|
||||
$reflMethod->invoke($errorHandler, $code, $message, $file, $line);
|
||||
}
|
||||
|
||||
public function testException()
|
||||
|
Reference in New Issue
Block a user