/** * 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(); }
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(); }
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'); }
/** * {@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(); } }
/** * 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(); }
/** * 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 setUp() { $this->errorReporting = error_reporting(E_ALL | E_STRICT); $this->loader = new ClassLoader(); spl_autoload_register(array($this->loader, 'loadClass'), true, true); DebugClassLoader::enable(); }
<?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();