Ejemplo n.º 1
0
 private function disableDebugClassLoader()
 {
     if (!class_exists('Symfony\\Component\\Debug\\DebugClassLoader')) {
         return;
     }
     DebugClassLoader::disable();
 }
Ejemplo n.º 2
0
 /**
  * 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 = null, $displayErrors = true)
 {
     if (static::$enabled) {
         return;
     }
     static::$enabled = true;
     if ($errorReportingLevel !== null) {
         error_reporting($errorReportingLevel);
     } else {
         error_reporting(-1);
     }
     if ('cli' !== php_sapi_name()) {
         ini_set('display_errors', 0);
         ExceptionHandler::register();
     } else {
         if ($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) {
         error_handler::register(new error_handler(new BufferingLogger()));
     } else {
         error_handler::register()->throwAt(0, true);
     }
     DebugClassLoader::enable();
 }
Ejemplo n.º 3
0
 public static function enable($environment = 'dev')
 {
     if (static::$enabled) {
         return;
     }
     static::$enabled = true;
     error_reporting(-1);
     // Beware, ExceptionHandler::register and ErrorHandler::register must be called in this order
     // to fatal errors handling work
     ExceptionHandler::register(true, $environment);
     ErrorHandler::register();
     DebugClassLoader::enable();
 }
Ejemplo n.º 4
0
 public function testIdempotence()
 {
     DebugClassLoader::enable();
     $functions = spl_autoload_functions();
     foreach ($functions as $function) {
         if (is_array($function) && $function[0] instanceof DebugClassLoader) {
             $reflClass = new \ReflectionClass($function[0]);
             $reflProp = $reflClass->getProperty('classLoader');
             $reflProp->setAccessible(true);
             $this->assertNotInstanceOf('Symfony\\Component\\Debug\\DebugClassLoader', $reflProp->getValue($function[0]));
             return;
         }
     }
     $this->fail('DebugClassLoader did not register');
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function boot()
 {
     // it is a quick way to check if loader was enabled
     $wasDebugEnabled = class_exists('\\Symfony\\Component\\Debug\\DebugClassLoader', false);
     if ($wasDebugEnabled) {
         // disable temporary to apply AOP loader first
         DebugClassLoader::disable();
     }
     $this->container->get('goaop.aspect.container');
     if (!AopComposerLoader::wasInitialized()) {
         throw new \RuntimeException("Initialization of AOP loader was failed, probably due to Debug::enable()");
     }
     if ($wasDebugEnabled) {
         DebugClassLoader::enable();
     }
 }
Ejemplo n.º 6
0
 /**
  * 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 integer $errorReportingLevel The level of error reporting you want
  * @param Boolean $displayErrors       Whether to display errors (for development) or just log them (for production)
  */
 public static function enable($errorReportingLevel = null, $displayErrors = true)
 {
     if (static::$enabled) {
         return;
     }
     static::$enabled = true;
     error_reporting(-1);
     ErrorHandler::register($errorReportingLevel, $displayErrors);
     if ('cli' !== php_sapi_name()) {
         ExceptionHandler::register();
         // CLI - display errors only if they're not already logged to STDERR
     } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
         ini_set('display_errors', 1);
     }
     DebugClassLoader::enable();
 }
Ejemplo n.º 7
0
 /**
  * Set the handlers.
  *
  * @param bool $debug
  */
 public static function register($debug = true)
 {
     $errorLevels = error_reporting();
     if ($debug) {
         $errorLevels |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
         Debug\DebugClassLoader::enable();
     }
     if (PHP_SAPI !== 'cli') {
         Debug\ErrorHandler::register()->throwAt($errorLevels, true);
         Debug\ExceptionHandler::register($debug);
     } else {
         $consoleHandler = function (\Exception $e) {
             $app = new Application('Bolt CLI', Version::VERSION);
             $output = new ConsoleOutput(OutputInterface::VERBOSITY_DEBUG);
             $app->renderException($e, $output);
             ob_clean();
         };
         Debug\ExceptionHandler::register($debug)->setHandler($consoleHandler);
     }
 }
 protected function tearDown()
 {
     DebugClassLoader::disable();
     spl_autoload_unregister(array($this->loader, 'loadClass'));
     error_reporting($this->errorReporting);
 }
Ejemplo n.º 9
0
<?php

declare (strict_types=1);
/*
 * This file is part of the SkeletonDancer package.
 *
 * (c) Sebastiaan Stok <*****@*****.**>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */
require __DIR__ . '/../vendor/autoload.php';
use Rollerworks\Tools\SkeletonDancer\Cli\DancerApplicationConfig;
\Symfony\Component\Debug\ErrorHandler::register();
\Symfony\Component\Debug\DebugClassLoader::enable();
$cli = new \Webmozart\Console\ConsoleApplication(new DancerApplicationConfig());
$cli->run();