1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

[ticket/17176] Use symfony error handler instead of debug

PHPBB3-17176
This commit is contained in:
Marc Alexander
2023-09-21 13:15:57 +02:00
parent 043d7286e0
commit 5231e04d49
4 changed files with 12 additions and 82 deletions

View File

@@ -13,14 +13,13 @@
namespace phpbb\debug;
use Symfony\Component\Debug\BufferingLogger;
use Symfony\Component\Debug\DebugClassLoader;
use Symfony\Component\Debug\ExceptionHandler;
use Symfony\Component\ErrorHandler\BufferingLogger;
use Symfony\Component\ErrorHandler\ErrorHandler;
/**
* Registers all the debug tools.
* @see Symfony\Component\Debug\Debug
* @see \Symfony\Component\ErrorHandler\Debug
*/
class debug
{
@@ -34,10 +33,10 @@ class debug
* If the Symfony ClassLoader component is available, a special
* class loader is also registered.
*
* @param int $errorReportingLevel The level of error reporting you want
* @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
* @param int|null $errorReportingLevel The level of error reporting you want
* @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
*/
public static function enable($errorReportingLevel = null, $displayErrors = true)
public static function enable(?int $errorReportingLevel = null, bool $displayErrors = true): void
{
if (static::$enabled)
{
@@ -58,7 +57,7 @@ class debug
if ('cli' !== php_sapi_name())
{
ini_set('display_errors', 0);
ExceptionHandler::register();
ErrorHandler::register();
}
else if ($displayErrors && (!ini_get('log_errors') || ini_get('error_log')))
{
@@ -75,6 +74,6 @@ class debug
error_handler::register()->throwAt(0, true);
}
DebugClassLoader::enable();
Debug::enable();
}
}

View File

@@ -13,7 +13,7 @@
namespace phpbb\debug;
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\ErrorHandler\ErrorHandler;
/**
* @psalm-suppress InvalidExtendClass
@@ -23,7 +23,7 @@ class error_handler extends ErrorHandler
/**
* @psalm-suppress MethodSignatureMismatch
*/
public function handleError($type, $message, $file, $line)
public function handleError(int $type, string $message, string $file, int $line): bool
{
if ($type === E_USER_WARNING || $type === E_USER_NOTICE)
{