annotate vendor/symfony/debug/Debug.php @ 2:92f882872392

Trusted hosts, + remove migration modules
author Chris Cannam
date Tue, 05 Dec 2017 09:26:43 +0000
parents 4c8ae668cc8c
children 5fb285c0d0e3
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\Debug;
Chris@0 13
Chris@0 14 /**
Chris@0 15 * Registers all the debug tools.
Chris@0 16 *
Chris@0 17 * @author Fabien Potencier <fabien@symfony.com>
Chris@0 18 */
Chris@0 19 class Debug
Chris@0 20 {
Chris@0 21 private static $enabled = false;
Chris@0 22
Chris@0 23 /**
Chris@0 24 * Enables the debug tools.
Chris@0 25 *
Chris@0 26 * This method registers an error handler and an exception handler.
Chris@0 27 *
Chris@0 28 * If the Symfony ClassLoader component is available, a special
Chris@0 29 * class loader is also registered.
Chris@0 30 *
Chris@0 31 * @param int $errorReportingLevel The level of error reporting you want
Chris@0 32 * @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
Chris@0 33 */
Chris@0 34 public static function enable($errorReportingLevel = E_ALL, $displayErrors = true)
Chris@0 35 {
Chris@0 36 if (static::$enabled) {
Chris@0 37 return;
Chris@0 38 }
Chris@0 39
Chris@0 40 static::$enabled = true;
Chris@0 41
Chris@0 42 if (null !== $errorReportingLevel) {
Chris@0 43 error_reporting($errorReportingLevel);
Chris@0 44 } else {
Chris@0 45 error_reporting(E_ALL);
Chris@0 46 }
Chris@0 47
Chris@0 48 if ('cli' !== PHP_SAPI) {
Chris@0 49 ini_set('display_errors', 0);
Chris@0 50 ExceptionHandler::register();
Chris@0 51 } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
Chris@0 52 // CLI - display errors only if they're not already logged to STDERR
Chris@0 53 ini_set('display_errors', 1);
Chris@0 54 }
Chris@0 55 if ($displayErrors) {
Chris@0 56 ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
Chris@0 57 } else {
Chris@0 58 ErrorHandler::register()->throwAt(0, true);
Chris@0 59 }
Chris@0 60
Chris@0 61 DebugClassLoader::enable();
Chris@0 62 }
Chris@0 63 }