mirror of
https://github.com/symfony/error-handler.git
synced 2026-03-24 08:12:09 +01:00
Remove deadcode after the bump to PHP >= 8.4
This commit is contained in:
@@ -868,7 +868,7 @@ class DebugClassLoader
|
||||
|
||||
$constant = new \ReflectionClassConstant($definingClass, $constantName);
|
||||
|
||||
if (\PHP_VERSION_ID >= 80300 && $constantType = $constant->getType()) {
|
||||
if ($constantType = $constant->getType()) {
|
||||
if ($constantType instanceof \ReflectionNamedType) {
|
||||
$n = $constantType->getName();
|
||||
} else {
|
||||
|
||||
@@ -180,11 +180,6 @@ class ErrorHandler
|
||||
?BufferingLogger $bootstrappingLogger = null,
|
||||
private bool $debug = false,
|
||||
) {
|
||||
if (\PHP_VERSION_ID < 80400) {
|
||||
$this->levels[\E_STRICT] = 'Runtime Notice';
|
||||
$this->loggers[\E_STRICT] = [null, LogLevel::ERROR];
|
||||
}
|
||||
|
||||
if ($bootstrappingLogger) {
|
||||
$this->bootstrappingLogger = $bootstrappingLogger;
|
||||
$this->setDefaultLogger($bootstrappingLogger);
|
||||
@@ -435,22 +430,6 @@ class ErrorHandler
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (\PHP_VERSION_ID < 80303 && str_contains($message, '@anonymous')) {
|
||||
$backtrace = debug_backtrace(false, 5);
|
||||
|
||||
for ($i = 1; isset($backtrace[$i]); ++$i) {
|
||||
if (isset($backtrace[$i]['function'], $backtrace[$i]['args'][0])
|
||||
&& ('trigger_error' === $backtrace[$i]['function'] || 'user_error' === $backtrace[$i]['function'])
|
||||
) {
|
||||
if ($backtrace[$i]['args'][0] !== $message) {
|
||||
$message = $backtrace[$i]['args'][0];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (str_contains($message, "@anonymous\0")) {
|
||||
$message = $this->parseAnonymousClass($message);
|
||||
$logMessage = $this->levels[$type].': '.$message;
|
||||
|
||||
@@ -255,21 +255,13 @@ class HtmlErrorRenderer implements ErrorRendererInterface
|
||||
// highlight_file could throw warnings
|
||||
// see https://bugs.php.net/25725
|
||||
$code = @highlight_file($file, true);
|
||||
if (\PHP_VERSION_ID >= 80300) {
|
||||
// remove main pre/code tags
|
||||
$code = preg_replace('#^<pre.*?>\s*<code.*?>(.*)</code>\s*</pre>#s', '\\1', $code);
|
||||
// split multiline span tags
|
||||
$code = preg_replace_callback('#<span ([^>]++)>((?:[^<\\n]*+\\n)++[^<]*+)</span>#', function ($m) {
|
||||
return "<span $m[1]>".str_replace("\n", "</span>\n<span $m[1]>", $m[2]).'</span>';
|
||||
}, $code);
|
||||
$content = explode("\n", $code);
|
||||
} else {
|
||||
// remove main code/span tags
|
||||
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);
|
||||
// split multiline spans
|
||||
$code = preg_replace_callback('#<span ([^>]++)>((?:[^<]*+<br \/>)++[^<]*+)</span>#', fn ($m) => "<span $m[1]>".str_replace('<br />', "</span><br /><span $m[1]>", $m[2]).'</span>', $code);
|
||||
$content = explode('<br />', $code);
|
||||
}
|
||||
// remove main pre/code tags
|
||||
$code = preg_replace('#^<pre.*?>\s*<code.*?>(.*)</code>\s*</pre>#s', '\\1', $code);
|
||||
// split multiline span tags
|
||||
$code = preg_replace_callback('#<span ([^>]++)>((?:[^<\\n]*+\\n)++[^<]*+)</span>#', function ($m) {
|
||||
return "<span $m[1]>".str_replace("\n", "</span>\n<span $m[1]>", $m[2]).'</span>';
|
||||
}, $code);
|
||||
$content = explode("\n", $code);
|
||||
|
||||
$lines = [];
|
||||
if (0 > $srcContext) {
|
||||
|
||||
@@ -405,9 +405,6 @@ class DebugClassLoaderTest extends TestCase
|
||||
], $deprecations);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP >= 8.3
|
||||
*/
|
||||
public function testReturnTypePhp83()
|
||||
{
|
||||
$deprecations = [];
|
||||
|
||||
@@ -214,10 +214,6 @@ class ErrorHandlerTest extends TestCase
|
||||
\E_CORE_ERROR => [null, LogLevel::CRITICAL],
|
||||
];
|
||||
|
||||
if (\PHP_VERSION_ID < 80400) {
|
||||
$loggers[\E_STRICT] = [null, LogLevel::ERROR];
|
||||
}
|
||||
|
||||
$this->assertSame($loggers, $handler->setLoggers([]));
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
@@ -455,10 +451,6 @@ class ErrorHandlerTest extends TestCase
|
||||
\E_CORE_ERROR => [$bootLogger, LogLevel::CRITICAL],
|
||||
];
|
||||
|
||||
if (\PHP_VERSION_ID < 80400) {
|
||||
$loggers[\E_STRICT] = [$bootLogger, LogLevel::ERROR];
|
||||
}
|
||||
|
||||
$this->assertSame($loggers, $handler->setLoggers([]));
|
||||
|
||||
$handler->handleError(\E_DEPRECATED, 'Foo message', __FILE__, 123, []);
|
||||
|
||||
Reference in New Issue
Block a user