This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Debug/Debug.php
Nicolas Grekas 5380d68431 Merge branch '2.8' into 3.0
* 2.8: (25 commits)
  [Console] Fix an autocompletion question helper issue with non-sequentially indexed choices
  [Process] Fix pipes handling
  Mentioned the deprecation of deep parameters in UPGRADE files
  [Filesystem] Fix false positive in ->remove()
  [Filesystem] Cleanup/sync with 2.3
  [Validator] Fix the locale validator so it treats a locale alias as a valid locale
  [HttpFoundation] Fix transient test
  [HttpFoundation] Add a dependency on the mbstring polyfill
  [2.7] update readme files for new components
  add readme files where missing
  [2.8] update readme files for new components
  fix lowest TwigBridge deps versions
  reference form type by name on Symfony 2.7
  [EventDispatcher] fix syntax error
  Don't use reflections when possible
  Don't use reflections when possible
  [Form] Update form tests after the ICU data update
  [Intl] Update tests and the number formatter to match behaviour of the intl extension
  [Intl] Update the ICU data to version 55
  [Intl] Fix the update-data.php script in preparation for ICU 5.5
  ...

Conflicts:
	UPGRADE-2.8.md
	UPGRADE-3.0.md
	src/Symfony/Bridge/Twig/composer.json
	src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/FragmentRendererPass.php
	src/Symfony/Component/Console/Helper/DialogHelper.php
	src/Symfony/Component/Console/Helper/ProgressHelper.php
	src/Symfony/Component/Console/Tests/Helper/LegacyDialogHelperTest.php
	src/Symfony/Component/HttpFoundation/composer.json
	src/Symfony/Component/Security/Core/README.md
	src/Symfony/Component/Security/Csrf/README.md
	src/Symfony/Component/Security/Http/README.md
	src/Symfony/Component/Validator/Constraints/LocaleValidator.php
2016-03-10 11:34:12 +01:00

64 lines
1.7 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Debug;
/**
* Registers all the debug tools.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Debug
{
private static $enabled = false;
/**
* Enables the debug tools.
*
* This method registers an error handler and an exception handler.
*
* 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)
*/
public static function enable($errorReportingLevel = E_ALL, $displayErrors = true)
{
if (static::$enabled) {
return;
}
static::$enabled = true;
if (null !== $errorReportingLevel) {
error_reporting($errorReportingLevel);
} else {
error_reporting(E_ALL);
}
if ('cli' !== PHP_SAPI) {
ini_set('display_errors', 0);
ExceptionHandler::register();
} elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
// CLI - display errors only if they're not already logged to STDERR
ini_set('display_errors', 1);
}
if ($displayErrors) {
ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
} else {
ErrorHandler::register()->throwAt(0, true);
}
DebugClassLoader::enable();
}
}