Нема описа

Debug.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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\ErrorHandler;
  11. /**
  12. * Registers all the debug tools.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class Debug
  17. {
  18. public static function enable(): ErrorHandler
  19. {
  20. error_reporting(-1);
  21. if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
  22. ini_set('display_errors', 0);
  23. } elseif (!filter_var(ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || ini_get('error_log')) {
  24. // CLI - display errors only if they're not already logged to STDERR
  25. ini_set('display_errors', 1);
  26. }
  27. @ini_set('zend.assertions', 1);
  28. ini_set('assert.active', 1);
  29. ini_set('assert.warning', 0);
  30. ini_set('assert.exception', 1);
  31. DebugClassLoader::enable();
  32. return ErrorHandler::register(new ErrorHandler(new BufferingLogger(), true));
  33. }
  34. }