[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/symfony/debug/ -> Debug.php (source)

   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\Debug;
  13  
  14  /**
  15   * Registers all the debug tools.
  16   *
  17   * @author Fabien Potencier <fabien@symfony.com>
  18   */
  19  class Debug
  20  {
  21      private static $enabled = false;
  22  
  23      /**
  24       * Enables the debug tools.
  25       *
  26       * This method registers an error handler, an exception handler and a special class loader.
  27       *
  28       * @param int  $errorReportingLevel The level of error reporting you want
  29       * @param bool $displayErrors       Whether to display errors (for development) or just log them (for production)
  30       */
  31      public static function enable($errorReportingLevel = \E_ALL, $displayErrors = true)
  32      {
  33          if (static::$enabled) {
  34              return;
  35          }
  36  
  37          static::$enabled = true;
  38  
  39          if (null !== $errorReportingLevel) {
  40              error_reporting($errorReportingLevel);
  41          } else {
  42              error_reporting(\E_ALL);
  43          }
  44  
  45          if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
  46              ini_set('display_errors', 0);
  47              ExceptionHandler::register();
  48          } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
  49              // CLI - display errors only if they're not already logged to STDERR
  50              ini_set('display_errors', 1);
  51          }
  52          if ($displayErrors) {
  53              ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  54          } else {
  55              ErrorHandler::register()->throwAt(0, true);
  56          }
  57  
  58          DebugClassLoader::enable();
  59      }
  60  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1