| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the Symfony package.
|
|
|
5 |
*
|
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
7 |
*
|
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
|
|
9 |
* file that was distributed with this source code.
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
namespace Symfony\Component\ErrorHandler;
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
* Registers all the debug tools.
|
|
|
16 |
*
|
|
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
18 |
*/
|
|
|
19 |
class Debug
|
|
|
20 |
{
|
|
|
21 |
public static function enable(): ErrorHandler
|
|
|
22 |
{
|
|
|
23 |
error_reporting(-1);
|
|
|
24 |
|
|
|
25 |
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
|
|
|
26 |
ini_set('display_errors', 0);
|
|
|
27 |
} elseif (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOL) || \ini_get('error_log')) {
|
|
|
28 |
// CLI - display errors only if they're not already logged to STDERR
|
|
|
29 |
ini_set('display_errors', 1);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
@ini_set('zend.assertions', 1);
|
|
|
33 |
ini_set('assert.active', 1);
|
|
|
34 |
ini_set('assert.warning', 0);
|
|
|
35 |
ini_set('assert.exception', 1);
|
|
|
36 |
|
|
|
37 |
DebugClassLoader::enable();
|
|
|
38 |
|
|
|
39 |
return ErrorHandler::register(new ErrorHandler(new BufferingLogger(), true));
|
|
|
40 |
}
|
|
|
41 |
}
|