From 77603bad557b467fe086d2098225fa1e88debffe Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 27 Jun 2022 15:16:42 +0200 Subject: [PATCH 1/3] CS fixes --- Debug.php | 2 +- ExceptionHandler.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Debug.php b/Debug.php index a44b993..99215cf 100644 --- a/Debug.php +++ b/Debug.php @@ -49,7 +49,7 @@ public static function enable($errorReportingLevel = \E_ALL, $displayErrors = tr if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) { ini_set('display_errors', 0); ExceptionHandler::register(); - } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) { + } elseif ($displayErrors && (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || \ini_get('error_log'))) { // CLI - display errors only if they're not already logged to STDERR ini_set('display_errors', 1); } diff --git a/ExceptionHandler.php b/ExceptionHandler.php index 21be282..fd8a7fd 100644 --- a/ExceptionHandler.php +++ b/ExceptionHandler.php @@ -55,7 +55,7 @@ class ExceptionHandler public function __construct(bool $debug = true, string $charset = null, $fileLinkFormat = null) { $this->debug = $debug; - $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8'; + $this->charset = $charset ?: \ini_get('default_charset') ?: 'UTF-8'; $this->fileLinkFormat = $fileLinkFormat; } @@ -390,7 +390,7 @@ private function formatClass(string $class): string private function formatPath(string $path, int $line): string { $file = $this->escapeHtml(preg_match('#[^/\\\\]*+$#', $path, $file) ? $file[0] : $path); - $fmt = $this->fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); + $fmt = $this->fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); if (!$fmt) { return sprintf('in %s%s', $this->escapeHtml($path), $file, 0 < $line ? ' line '.$line : ''); From 60d1b678b7eccfde2415316e62fc689f932fe82b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 27 Jul 2022 18:05:11 +0200 Subject: [PATCH 2/3] Workaround disabled "var_dump" --- ErrorHandler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ErrorHandler.php b/ErrorHandler.php index 99791f9..67f526d 100644 --- a/ErrorHandler.php +++ b/ErrorHandler.php @@ -355,7 +355,7 @@ public function screamAt($levels, $replace = false) private function reRegister(int $prev) { if ($prev !== $this->thrownErrors | $this->loggedErrors) { - $handler = set_error_handler('var_dump'); + $handler = set_error_handler('is_int'); $handler = \is_array($handler) ? $handler[0] : null; restore_error_handler(); if ($handler === $this) { @@ -490,7 +490,7 @@ public function handleError($type, $message, $file, $line) $log = 0; } else { if (\PHP_VERSION_ID < (\PHP_VERSION_ID < 70400 ? 70316 : 70404)) { - $currentErrorHandler = set_error_handler('var_dump'); + $currentErrorHandler = set_error_handler('is_int'); restore_error_handler(); } @@ -601,7 +601,7 @@ public static function handleFatalError(array $error = null) $sameHandlerLimit = 10; while (!\is_array($handler) || !$handler[0] instanceof self) { - $handler = set_exception_handler('var_dump'); + $handler = set_exception_handler('is_int'); restore_exception_handler(); if (!$handler) { From 1a692492190773c5310bc7877cb590c04c2f05be Mon Sep 17 00:00:00 2001 From: Guilliam Xavier Date: Thu, 28 Jul 2022 18:05:51 +0200 Subject: [PATCH 3/3] [Debug][ErrorHandler] fix operator precedence --- ErrorHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ErrorHandler.php b/ErrorHandler.php index 67f526d..fe425e0 100644 --- a/ErrorHandler.php +++ b/ErrorHandler.php @@ -354,7 +354,7 @@ public function screamAt($levels, $replace = false) */ private function reRegister(int $prev) { - if ($prev !== $this->thrownErrors | $this->loggedErrors) { + if ($prev !== ($this->thrownErrors | $this->loggedErrors)) { $handler = set_error_handler('is_int'); $handler = \is_array($handler) ? $handler[0] : null; restore_error_handler();