Açıklama Yok

Debug.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Debug;
  11. @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', Debug::class, \Symfony\Component\ErrorHandler\Debug::class), \E_USER_DEPRECATED);
  12. /**
  13. * Registers all the debug tools.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. *
  17. * @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Debug instead.
  18. */
  19. class Debug
  20. {
  21. private static $enabled = false;
  22. /**
  23. * Enables the debug tools.
  24. *
  25. * This method registers an error handler and an exception handler.
  26. *
  27. * @param int $errorReportingLevel The level of error reporting you want
  28. * @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
  29. */
  30. public static function enable($errorReportingLevel = \E_ALL, $displayErrors = true)
  31. {
  32. if (static::$enabled) {
  33. return;
  34. }
  35. static::$enabled = true;
  36. if (null !== $errorReportingLevel) {
  37. error_reporting($errorReportingLevel);
  38. } else {
  39. error_reporting(\E_ALL);
  40. }
  41. if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
  42. ini_set('display_errors', 0);
  43. ExceptionHandler::register();
  44. } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
  45. // CLI - display errors only if they're not already logged to STDERR
  46. ini_set('display_errors', 1);
  47. }
  48. if ($displayErrors) {
  49. ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  50. } else {
  51. ErrorHandler::register()->throwAt(0, true);
  52. }
  53. DebugClassLoader::enable();
  54. }
  55. }