This commit is contained in:
1 parent
f7c532a648
commit
640bd67556
5801 files changed
+484532
-55857
No files matched your search
+12
-12
@@ -90,7 +90,6 @@ class ErrorHandler
|
||||
private int $screamedErrors = 0x55; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE
|
||||
private int $loggedErrors = 0;
|
||||
private \Closure $configureException;
|
||||
private bool $debug;
|
||||
|
||||
private bool $isRecursive = false;
|
||||
private bool $isRoot = false;
|
||||
@@ -117,11 +116,12 @@ class ErrorHandler
|
||||
$handler = new static();
|
||||
}
|
||||
|
||||
if (null === $prev = set_error_handler([$handler, 'handleError'])) {
|
||||
restore_error_handler();
|
||||
if (null === $prev = get_error_handler()) {
|
||||
// Specifying the error types earlier would expose us to https://bugs.php.net/63206
|
||||
set_error_handler([$handler, 'handleError'], $handler->thrownErrors | $handler->loggedErrors);
|
||||
$handler->isRoot = true;
|
||||
} else {
|
||||
set_error_handler([$handler, 'handleError']);
|
||||
}
|
||||
|
||||
if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
|
||||
@@ -177,8 +177,10 @@ class ErrorHandler
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct(?BufferingLogger $bootstrappingLogger = null, bool $debug = false)
|
||||
{
|
||||
public function __construct(
|
||||
?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];
|
||||
@@ -193,9 +195,8 @@ class ErrorHandler
|
||||
$traceReflector->setValue($e, $trace);
|
||||
$e->file = $file ?? $e->file;
|
||||
$e->line = $line ?? $e->line;
|
||||
}, null, new class() extends \Exception {
|
||||
}, null, new class extends \Exception {
|
||||
});
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,9 +363,8 @@ class ErrorHandler
|
||||
private function reRegister(int $prev): void
|
||||
{
|
||||
if ($prev !== ($this->thrownErrors | $this->loggedErrors)) {
|
||||
$handler = set_error_handler(static fn () => null);
|
||||
$handler = get_error_handler();
|
||||
$handler = \is_array($handler) ? $handler[0] : null;
|
||||
restore_error_handler();
|
||||
if ($handler === $this) {
|
||||
restore_error_handler();
|
||||
if ($this->isRoot) {
|
||||
@@ -599,7 +599,7 @@ class ErrorHandler
|
||||
}
|
||||
if (!$handler) {
|
||||
if (null === $error && $exitCode = self::$exitCode) {
|
||||
register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
|
||||
register_shutdown_function('register_shutdown_function', static function () use ($exitCode) { exit($exitCode); });
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -638,7 +638,7 @@ class ErrorHandler
|
||||
}
|
||||
|
||||
if ($exit && $exitCode = self::$exitCode) {
|
||||
register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
|
||||
register_shutdown_function('register_shutdown_function', static function () use ($exitCode) { exit($exitCode); });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -742,6 +742,6 @@ class ErrorHandler
|
||||
*/
|
||||
private function parseAnonymousClass(string $message): string
|
||||
{
|
||||
return preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', static fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
|
||||
return preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', static fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user