Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
error_handler
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 2
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 handleError
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14namespace phpbb\debug;
15
16use Symfony\Component\ErrorHandler\BufferingLogger;
17use Symfony\Component\ErrorHandler\ErrorHandler;
18
19/**
20 * @psalm-suppress InvalidExtendClass
21 */
22class error_handler extends ErrorHandler
23{
24    /**
25     * @psalm-suppress MethodSignatureMismatch
26     */
27    public function __construct(BufferingLogger $bootstrappingLogger = null, private readonly bool $debug = false) // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found
28    {
29        parent::__construct($bootstrappingLogger, $debug);
30    }
31
32    /**
33     * @psalm-suppress MethodSignatureMismatch
34     */
35    public function handleError(int $type, string $message, string $file, int $line): bool
36    {
37        if (!$this->debug || $type === E_USER_WARNING || $type === E_USER_NOTICE)
38        {
39            $handler = defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler';
40
41            return $handler($type, $message, $file, $line);
42        }
43
44        return parent::handleError($type, $message, $file, $line);
45    }
46}