Skip to content

Commit

Permalink
[ErrorHandler][VarDumper] Remove PHP 8.4 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-daubois committed Jul 23, 2024
1 parent 59ee876 commit db15ba0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class ErrorHandler
\E_USER_DEPRECATED => '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',
Expand All @@ -73,7 +72,6 @@ class ErrorHandler
\E_USER_DEPRECATED => [null, LogLevel::INFO],
\E_NOTICE => [null, LogLevel::WARNING],
\E_USER_NOTICE => [null, LogLevel::WARNING],
\E_STRICT => [null, LogLevel::WARNING],
\E_WARNING => [null, LogLevel::WARNING],
\E_USER_WARNING => [null, LogLevel::WARNING],
\E_COMPILE_WARNING => [null, LogLevel::WARNING],
Expand Down Expand Up @@ -183,6 +181,11 @@ public static function call(callable $function, ...$arguments)

public function __construct(?BufferingLogger $bootstrappingLogger = null, bool $debug = false)
{
if (\PHP_VERSION_ID < 80400) {
$this->levels[\E_STRICT] = 'Runtime Notice';
$this->loggers[\E_STRICT] = [null, LogLevel::WARNING];
}

if ($bootstrappingLogger) {
$this->bootstrappingLogger = $bootstrappingLogger;
$this->setDefaultLogger($bootstrappingLogger);
Expand Down
11 changes: 9 additions & 2 deletions Tests/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ public function testDefaultLogger()
\E_USER_DEPRECATED => [null, LogLevel::INFO],
\E_NOTICE => [$logger, LogLevel::WARNING],
\E_USER_NOTICE => [$logger, LogLevel::CRITICAL],
\E_STRICT => [null, LogLevel::WARNING],
\E_WARNING => [null, LogLevel::WARNING],
\E_USER_WARNING => [null, LogLevel::WARNING],
\E_COMPILE_WARNING => [null, LogLevel::WARNING],
Expand All @@ -225,6 +224,11 @@ public function testDefaultLogger()
\E_ERROR => [null, LogLevel::CRITICAL],
\E_CORE_ERROR => [null, LogLevel::CRITICAL],
];

if (\PHP_VERSION_ID < 80400) {
$loggers[\E_STRICT] = [null, LogLevel::WARNING];
}

$this->assertSame($loggers, $handler->setLoggers([]));
} finally {
restore_error_handler();
Expand Down Expand Up @@ -478,7 +482,6 @@ public function testBootstrappingLogger()
\E_USER_DEPRECATED => [$bootLogger, LogLevel::INFO],
\E_NOTICE => [$bootLogger, LogLevel::WARNING],
\E_USER_NOTICE => [$bootLogger, LogLevel::WARNING],
\E_STRICT => [$bootLogger, LogLevel::WARNING],
\E_WARNING => [$bootLogger, LogLevel::WARNING],
\E_USER_WARNING => [$bootLogger, LogLevel::WARNING],
\E_COMPILE_WARNING => [$bootLogger, LogLevel::WARNING],
Expand All @@ -491,6 +494,10 @@ public function testBootstrappingLogger()
\E_CORE_ERROR => [$bootLogger, LogLevel::CRITICAL],
];

if (\PHP_VERSION_ID < 80400) {
$loggers[\E_STRICT] = [$bootLogger, LogLevel::WARNING];
}

$this->assertSame($loggers, $handler->setLoggers([]));

$handler->handleError(\E_DEPRECATED, 'Foo message', __FILE__, 123, []);
Expand Down

0 comments on commit db15ba0

Please sign in to comment.