Remove deadcode after the bump to PHP >= 8.4

This commit is contained in:
Nicolas Grekas
2025-06-03 17:41:25 +02:00
parent 2a32f5f31d
commit aae9ff4f22
5 changed files with 8 additions and 48 deletions

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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) {

View File

@@ -405,9 +405,6 @@ class DebugClassLoaderTest extends TestCase
], $deprecations);
}
/**
* @requires PHP >= 8.3
*/
public function testReturnTypePhp83()
{
$deprecations = [];

View File

@@ -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, []);