public function testConfigure()
 {
     $logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $userHandler = function () {
     };
     $listener = new DebugHandlersListener($userHandler, $logger);
     $xHandler = new ExceptionHandler();
     $eHandler = new ErrorHandler();
     $eHandler->setExceptionHandler(array($xHandler, 'handle'));
     $exception = null;
     set_error_handler(array($eHandler, 'handleError'));
     set_exception_handler(array($eHandler, 'handleException'));
     try {
         $listener->configure();
     } catch (\Exception $exception) {
     }
     restore_exception_handler();
     restore_error_handler();
     if (null !== $exception) {
         throw $exception;
     }
     $this->assertSame($userHandler, $xHandler->setHandler('var_dump'));
     $loggers = $eHandler->setLoggers(array());
     $this->assertArrayHasKey(E_DEPRECATED, $loggers);
     $this->assertSame(array($logger, LogLevel::INFO), $loggers[E_DEPRECATED]);
 }
 public function testConsoleEvent()
 {
     $dispatcher = new EventDispatcher();
     $listener = new DebugHandlersListener(null);
     $app = $this->getMock('Symfony\\Component\\Console\\Application');
     $app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet()));
     $command = new Command(__FUNCTION__);
     $command->setApplication($app);
     $event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput());
     $dispatcher->addSubscriber($listener);
     $xListeners = array(KernelEvents::REQUEST => array(array($listener, 'configure')), ConsoleEvents::COMMAND => array(array($listener, 'configure')));
     $this->assertSame($xListeners, $dispatcher->getListeners());
     $exception = null;
     $eHandler = new ErrorHandler();
     set_error_handler(array($eHandler, 'handleError'));
     set_exception_handler(array($eHandler, 'handleException'));
     try {
         $dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
     } catch (\Exception $exception) {
     }
     restore_exception_handler();
     restore_error_handler();
     if (null !== $exception) {
         throw $exception;
     }
     $xHandler = $eHandler->setExceptionHandler('var_dump');
     $this->assertInstanceOf('Closure', $xHandler);
     $app->expects($this->once())->method('renderException');
     $xHandler(new \Exception());
 }
 public function injectLogger()
 {
     if (null !== $this->logger) {
         ErrorHandler::setLogger($this->logger, $this->channel);
         $this->logger = null;
     }
 }
 public function testStacking()
 {
     // the ContextErrorException must not be loaded to test the workaround
     // for https://bugs.php.net/65322.
     if (class_exists('Symfony\\Component\\Debug\\Exception\\ContextErrorException', false)) {
         $this->markTestSkipped('The ContextErrorException class is already loaded.');
     }
     ErrorHandler::register();
     try {
         // Trigger autoloading + E_STRICT at compile time
         // which in turn triggers $errorHandler->handle()
         // that again triggers autoloading for ContextErrorException.
         // Error stacking works around the bug above and everything is fine.
         eval('
             namespace ' . __NAMESPACE__ . ';
             class ChildTestingStacking extends TestingStacking { function foo($bar) {} }
         ');
         $this->fail('ContextErrorException expected');
     } catch (\ErrorException $exception) {
         // if an exception is thrown, the test passed
         restore_error_handler();
         restore_exception_handler();
         $this->assertEquals(E_STRICT, $exception->getSeverity());
         $this->assertStringStartsWith(__FILE__, $exception->getFile());
         $this->assertRegexp('/^Runtime Notice: Declaration/', $exception->getMessage());
     } catch (\Exception $e) {
         restore_error_handler();
         restore_exception_handler();
         throw $e;
     }
 }
Esempio n. 5
0
 /**
  * Registers the autoloader and necessary components.
  *
  * @param string      $name        Name for this application.
  * @param string|null $version     Version number for this application.
  * @param string|null $environment The environment.
  */
 public function __construct($name, $version = null, $environment = self::ENV_PROD)
 {
     parent::__construct($environment);
     $app = $this;
     $this['session.test'] = true;
     $this['console'] = $this->share(function () use($name, $version) {
         return new Console\Application($name, $version);
     });
     $this['dispatcher'] = $this->share($this->extend('dispatcher', function (EventDispatcher $dispatcher, Application $app) {
         $dispatcher->addListener('phraseanet.notification.sent', function () use($app) {
             $app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']);
         });
         $dispatcher->addSubscriber(new BridgeSubscriber($app));
         return $dispatcher;
     }));
     $this->register(new PluginServiceProvider());
     $this->register(new WebsocketServerServiceProvider());
     $this->register(new ComposerSetupServiceProvider());
     $this->register(new CLIDriversServiceProvider());
     $this->register(new LessBuilderServiceProvider());
     $this->register(new SignalHandlerServiceProvider());
     $this->register(new TaskManagerServiceProvider());
     $this->register(new TranslationExtractorServiceProvider());
     $this->register(new DoctrineMigrationServiceProvider());
     $this->bindRoutes();
     error_reporting(-1);
     ErrorHandler::register();
     PhraseaCLIExceptionHandler::register();
 }
 /**
  * @return void
  * @author Michaël VEROUX
  */
 public function boot()
 {
     if ('prod' === $this->container->getParameter('kernel.environment')) {
         $handler = ErrorHandler::register();
         $handler->setExceptionHandler(array($this, 'handle'));
     }
 }
 /**
  * @expectedException \Symfony\Component\Debug\Exception\DummyException
  */
 public function testStacking()
 {
     // the ContextErrorException must not be loaded to test the workaround
     // for https://bugs.php.net/65322.
     if (class_exists('Symfony\\Component\\Debug\\Exception\\ContextErrorException', false)) {
         $this->markTestSkipped('The ContextErrorException class is already loaded.');
     }
     $exceptionHandler = $this->getMock('Symfony\\Component\\Debug\\ExceptionHandler', array('handle'));
     set_exception_handler(array($exceptionHandler, 'handle'));
     $that = $this;
     $exceptionCheck = function ($exception) use($that) {
         $that->assertInstanceOf('Symfony\\Component\\Debug\\Exception\\ContextErrorException', $exception);
         $that->assertEquals(E_STRICT, $exception->getSeverity());
         $that->assertStringStartsWith(__FILE__, $exception->getFile());
         $that->assertRegexp('/^Runtime Notice: Declaration/', $exception->getMessage());
     };
     $exceptionHandler->expects($this->once())->method('handle')->will($this->returnCallback($exceptionCheck));
     ErrorHandler::register();
     try {
         // Trigger autoloading + E_STRICT at compile time
         // which in turn triggers $errorHandler->handle()
         // that again triggers autoloading for ContextErrorException.
         // Error stacking works around the bug above and everything is fine.
         eval('
             namespace ' . __NAMESPACE__ . ';
             class ChildTestingStacking extends TestingStacking { function foo($bar) {} }
         ');
     } catch (\Exception $e) {
         restore_error_handler();
         restore_exception_handler();
         throw $e;
     }
     restore_error_handler();
     restore_exception_handler();
 }
Esempio n. 8
0
 public function bootstrap()
 {
     $app = $this;
     $app['dir.base'] = __DIR__ . "/../../../../";
     $app->register(new ConfigServiceProvider());
     $app['debug'] = $app['config']['debug'];
     ErrorHandler::register();
     ExceptionHandler::register($app['debug']);
     $app->register(new HttpFragmentServiceProvider());
     $app->register(new ServiceControllerServiceProvider());
     $app->register(new ORMServiceProvider());
     $app->register(new SessionServiceProvider());
     $app->register(new SecurityServiceProvider());
     $app['security.encoder.digest'] = function ($app) {
         // uses the password-compat encryption
         return new BCryptPasswordEncoder(10);
     };
     $app->register(new ManagerRegistryServiceProvider());
     $app['security.firewalls'] = array('default' => array('pattern' => '/', 'form' => array('login_path' => '/login', 'check_path' => '/login_check'), 'logout' => array('logout_path' => '/logout', 'invalidate_session' => true), 'users' => function () use($app) {
         return new EntityUserProvider($app['manager_registry'], User::class, 'username');
     }, 'anonymous' => true));
     $app['security.access_rules'] = [['^/admin', 'ROLE_ADMIN']];
     $app->register(new TranslationServiceProvider(), array('locale_fallbacks' => array('en'), 'locale' => 'en'));
     $app->register(new ValidatorServiceProvider());
     $app->register(new FormServiceProvider());
     $app->register(new TwigServiceProvider(), ['twig.path' => __DIR__ . '/../resources/views', 'twig.form.templates' => ['bootstrap_3_layout.html.twig'], 'twig.strict_variables' => false]);
     $app->extend('twig', function (\Twig_Environment $twig) {
         $twig->addTest(new \Twig_SimpleTest('callable', function ($variable) {
             return is_callable($variable);
         }));
         $twig->addFunction(new \Twig_SimpleFunction('is_callable', function ($variable) {
             return is_callable($variable);
         }));
         $twig->addFunction(new \Twig_SimpleFunction('call_user_func', function ($callable, $params = null) {
             return call_user_func($callable, $params);
         }));
         $twig->getExtension('core')->setDateFormat('Y/m/d', '%d days');
         return $twig;
     });
     $app->extend('form.types', function ($types) use($app) {
         $types[] = new EntityType($app['manager_registry']);
         $types[] = new TemplateChoiceType($app['theme']);
         $types[] = new PageType($app['theme']);
         return $types;
     });
     $app->register(new SerializerServiceProvider());
     $app->register(new WebProfilerServiceProvider(), ['profiler.cache_dir' => './../storage/framework/cache/profiler', 'web_profiler.debug_toolbar.enable' => $app['debug'], 'profiler.mount_prefix' => '/admin/_profiler']);
     $app['finder'] = function () {
         return new Finder();
     };
     $app['filesystem'] = function () {
         return new Filesystem();
     };
     $app->register(new ConverterServiceProvider());
     $app->register(new ThemeServiceProvider());
     $app['twig.loader.filesystem']->addPath($app['dir.theme'], 'theme');
     $app->register(new CMSServiceProvider());
     $app->setRoutes();
 }
Esempio n. 9
0
 public function handleError($type, $message, $file, $line, array $context, array $backtrace = null)
 {
     if ($type === E_USER_WARNING || $type === E_USER_NOTICE) {
         $handler = defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler';
         $handler($type, $message, $file, $line);
     }
     return parent::handleError($type, $message, $file, $line, $context, $backtrace);
 }
 public function register(Application $app)
 {
     $debug = isset($app['config']) ? $app['config']['app.debug'] : true;
     $handler = ExceptionHandler::register($debug);
     ErrorHandler::register(E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_RECOVERABLE_ERROR);
     if ($cli = $app->runningInConsole() or $debug) {
         ini_set('display_errors', 1);
     }
     $app['exception'] = $handler;
 }
Esempio n. 11
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // handle errors as exceptions
     ErrorHandler::register();
     // views
     if (class_exists('\\JpGraph\\JpGraph')) {
         foreach (array('png', 'jpeg', 'jpg', 'gif') as $format) {
             self::$viewMapping[$format] = 'Volkszaehler\\View\\JpGraph';
         }
     }
 }
 public function register(Application $app)
 {
     ErrorHandler::register();
     ExceptionHandler::register($app['debug']);
     $app->error(function (\Exception $exception, $code) use($app) {
         if (!$app['debug'] || $code === 404) {
             // 404.html, or 40x.html, or 4xx.html, or error.html
             $templates = array('errors/' . $code . '.html.twig', 'errors/' . substr($code, 0, 2) . 'x.html.twig', 'errors/' . substr($code, 0, 1) . 'xx.html.twig', 'errors/' . 'default.html.twig');
             return new Response($app['twig']->resolveTemplate($templates)->render(array('code' => $code)), $code);
         }
     });
 }
Esempio n. 13
0
 public function __construct()
 {
     parent::__construct();
     // Convert errors to exceptions
     ErrorHandler::register();
     ExceptionHandler::register();
     $this['cache.directory'] = __DIR__ . '/../../../app/cache';
     $this['vendor.directory'] = __DIR__ . '/../../../vendor';
     $this->registerControllers();
     $this->registerServiceProviders();
     $this->registerInternalServices();
 }
Esempio n. 14
0
 public static function run()
 {
     // Converts warnings to exceptions
     ErrorHandler::register();
     $config = self::loadConfig();
     $container = new Container($config['extensions']);
     unset($config['extensions']);
     $container->configure();
     $container->mergeParameters($config);
     $container->build();
     $container->get('console.application')->run();
 }
Esempio n. 15
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     ErrorHandler::register();
     // JSON/REST application
     $this->register(new ContentNegotiationServiceProvider(), array("conneg.responseFormats" => array("json"), "conneg.requestFormats" => array("json"), "conneg.defaultFormat" => "json"));
     $this->register(new CorsServiceProvider());
     // JSON Schema application
     $this->register(new JsonSchemaServiceProvider());
     // Error Handling
     $this->error(new JsonErrorHandler($this));
 }
Esempio n. 16
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();
 }
Esempio n. 17
0
 public function boot()
 {
     ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true);
     if ($trustedProxies = $this->container->getParameter('kernel.trusted_proxies')) {
         Request::setTrustedProxies($trustedProxies);
     }
     if ($this->container->getParameter('kernel.http_method_override')) {
         Request::enableHttpMethodParameterOverride();
     }
     if ($trustedHosts = $this->container->getParameter('kernel.trusted_hosts')) {
         Request::setTrustedHosts($trustedHosts);
     }
 }
Esempio n. 18
0
File: App.php Progetto: stonedz/pff2
 /**
  * Sets error reporting
  */
 public function setErrorReporting()
 {
     if (true === $this->_config->getConfigData('development_environment')) {
         error_reporting(E_ALL);
         ini_set('display_errors', 'On');
         ErrorHandler::register();
     } else {
         error_reporting(E_ALL);
         ini_set('display_errors', 'Off');
         ini_set('log_errors', 'On');
         ini_set('error_log', ROOT . DS . 'tmp' . DS . 'logs' . DS . 'error.log');
     }
 }
Esempio n. 19
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();
 }
Esempio n. 20
0
 /**
  * Loads third party libraries.
  *
  * @since 1.1.0
  *
  * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**>
  */
 public static function loadThirdParty()
 {
     $ds = DIRECTORY_SEPARATOR;
     $vendorDir = sprintf('%1$s%2$svendor%2$s', HOMEPATH, $ds);
     if (file_exists($vendorDir . 'doctrine')) {
         $path = '%1$sdoctrine%2$scommon%2$slib%2$sDoctrine%2$sCommon%2$sClassLoader.php';
         require sprintf($path, $vendorDir, $ds);
         $commonLoader = new \Doctrine\Common\ClassLoader('Doctrine', $vendorDir . 'doctrine' . $ds . 'common' . $ds . 'lib');
         $commonLoader->register();
         $dbalLoader = new \Doctrine\Common\ClassLoader('Doctrine', $vendorDir . 'doctrine' . $ds . 'dbal' . $ds . 'lib');
         $dbalLoader->register();
     }
     if (file_exists($vendorDir . $ds . 'symfony' . $ds . 'debug')) {
         ErrorHandler::register();
     }
 }
Esempio n. 21
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
  */
 public static function enable($errorReportingLevel = null)
 {
     if (static::$enabled) {
         return;
     }
     static::$enabled = true;
     error_reporting(-1);
     ErrorHandler::register($errorReportingLevel);
     if ('cli' !== php_sapi_name()) {
         ExceptionHandler::register();
     } elseif (!ini_get('log_errors') || ini_get('error_log')) {
         ini_set('display_errors', 1);
     }
     if (class_exists('Symfony\\Component\\ClassLoader\\DebugClassLoader')) {
         DebugClassLoader::enable();
     }
 }
Esempio n. 22
0
 /**
  * Sets default exception handler.
  *
  * If shop is in productive mode stick to default OXID exception handler
  * Else register Symfony Debug component's Exception and Error handlers
  *
  * Non-productive eShop mode is intended for eShop installation, configuration, template customization and module debugging phase.
  * As soon as productive mode is turned ON, the cache handling and the error reporting behavior is optimized for the live shop.
  */
 protected function _setDefaultExceptionHandler()
 {
     /**
      * @todo: consider also getEnvironment() function to detect environment
      */
     if (oxRegistry::getConfig()->isProductiveMode()) {
         parent::_setDefaultExceptionHandler();
         return;
     }
     /**
      * Debug::enable() also registers a DebugClassLoader which throw an error because oxid does not care about case when referring to objects
      * symfony is key sensitive:  oxarticlelist != oxArticleList
      */
     //Debug\Debug::enable();
     ini_set('display_errors', 0);
     Debug\ExceptionHandler::register();
     Debug\ErrorHandler::register()->throwAt(0, true);
 }
Esempio n. 23
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;
     error_reporting(-1);
     ErrorHandler::register($errorReportingLevel, $displayErrors);
     if ('cli' !== PHP_SAPI) {
         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);
     }
     if (class_exists('Symfony\\Component\\ClassLoader\\DebugClassLoader')) {
         DebugClassLoader::enable();
     }
 }
Esempio n. 24
0
 /**
  *  Init config
  * 
  * @param Application $app
  */
 private function _iniConfig(Application $app)
 {
     // Setting the sign of the console
     $app['is_console'] = TRUE;
     // Load configurations
     $app->register(new Providers\YamlConfigServiceProvider(array('%base_path%' => BASEPATH, '%log_path%' => BASEPATH . '/data/logs', '%cache_path%' => BASEPATH . '/data/cache')), array('config.dir' => BASEPATH . '/app/Resources/Config', 'config.files' => array('console.yml')));
     //Set debug option
     $app['debug'] = $app['config']['parameters']['debug'];
     //Set basepath option
     $app['basepath'] = $this->app['config']['base_path'];
     //Set Timezone
     if (isset($app['config']['parameters']['timezone'])) {
         date_default_timezone_set($app['config']['parameters']['timezone']);
     }
     // Registering the ErrorHandler
     // It converts all errors to exceptions, and exceptions are then caught by Silex
     ErrorHandler::register();
     ExceptionHandler::register($app['debug']);
 }
Esempio n. 25
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);
     }
 }
 public function register(\Pimple\Container $pimple)
 {
     $pimple['debugbar.http_driver.drupal'] = function (\Pimple\Container $c) {
         return new DrupalHttpDriver();
     };
     $pimple['debugbar.collector.drupal_database'] = function ($c) {
         return new DrupalDbTngCollector();
     };
     $pimple['debugbar.collector.time_data'] = function ($c) {
         return new DrupalTimeDataCollector();
     };
     $pimple['debugbar.collector.menu_item'] = function ($c) {
         $item = menu_get_item();
         if (!$item) {
             $item = array();
         }
         return new \DebugBar\DataCollector\ConfigCollector($item, 'Menu');
     };
     $pimple['debugbar.collector.globals'] = function ($c) {
         return new GlobalsConfigCollector();
     };
     $pimple['debugbar.storage.drupal'] = function ($c) {
         /** @var \PDO $pdo */
         $pdo = $c['db']->getWrappedConnection();
         return new \DebugBar\Storage\PdoStorage($pdo);
     };
     $pimple['debugbar.storage.file'] = function ($c) {
         return new \DebugBar\Storage\FileStorage('var://debugbar');
     };
     $pimple->extend('debugbar', function (\DebugBar\DebugBar $debugbar, \Pimple\Container $c) {
         $debugbar->setStorage($c['debugbar.storage.drupal']);
         $debugbar->setHttpDriver($c['debugbar.http_driver.drupal']);
         \Symfony\Component\Debug\ErrorHandler::setLogger($c['debugbar.collector.messages'], 'scream');
         set_exception_handler(array($c['debugbar.collector.exceptions'], 'addException'));
         return $debugbar;
     });
     $pimple->extend('debugbar.renderer', function (\DebugBar\JavascriptRenderer $renderer, \Pimple\Container $c) {
         $renderer->setOpenHandlerUrl('/debugbar/open');
         return $renderer;
     });
 }
Esempio n. 27
0
 public static function run(ClassLoader $autoloader)
 {
     // Converts warnings to exceptions
     ErrorHandler::register();
     $config = self::loadConfig();
     if (isset($config['extension_autoloader']) && $config['extension_autoloader']) {
         $autoloadFile = $config['extension_autoloader'];
         if (!file_exists($autoloadFile)) {
             throw new \InvalidArgumentException(sprintf('Could not find extension autoload file "%s"', $autoloadFile));
         }
         $autoloader->unregister();
         include $autoloadFile;
         $autoloader->register(true);
     }
     $extensions = $config['extensions'];
     $extensions[] = 'PhpBench\\Extension\\CoreExtension';
     unset($config['extensions']);
     $container = new Container($extensions, $config);
     $container->init();
     $container->get('console.application')->run();
 }
Esempio n. 28
0
 public function testHandle()
 {
     $handler = ErrorHandler::register(0);
     $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, 'foo'));
     restore_error_handler();
     $handler = ErrorHandler::register(3);
     $this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, 'foo'));
     restore_error_handler();
     $handler = ErrorHandler::register(3);
     try {
         $handler->handle(111, 'foo', 'foo.php', 12, 'foo');
     } catch (\ErrorException $e) {
         $this->assertSame('111: foo in foo.php line 12', $e->getMessage());
         $this->assertSame(111, $e->getSeverity());
         $this->assertSame('foo.php', $e->getFile());
         $this->assertSame(12, $e->getLine());
     }
     restore_error_handler();
     $handler = ErrorHandler::register(E_USER_DEPRECATED);
     $this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo'));
     restore_error_handler();
     $handler = ErrorHandler::register(E_DEPRECATED);
     $this->assertTrue($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, 'foo'));
     restore_error_handler();
     $logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $that = $this;
     $warnArgCheck = function ($message, $context) use($that) {
         $that->assertEquals('foo', $message);
         $that->assertArrayHasKey('type', $context);
         $that->assertEquals($context['type'], ErrorHandler::TYPE_DEPRECATION);
         $that->assertArrayHasKey('stack', $context);
         $that->assertInternalType('array', $context['stack']);
     };
     $logger->expects($this->once())->method('warning')->will($this->returnCallback($warnArgCheck));
     $handler = ErrorHandler::register(E_USER_DEPRECATED);
     $handler->setLogger($logger);
     $handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo');
     restore_error_handler();
 }
Esempio n. 29
0
 public function testHandleFatalErrorOnHHVM()
 {
     try {
         $handler = ErrorHandler::register();
         $logger = $this->getMock('Psr\\Log\\LoggerInterface');
         $logger->expects($this->once())->method('log')->with($this->equalTo(LogLevel::CRITICAL), $this->equalTo('Fatal Error: foo'), $this->equalTo(array('type' => 1, 'file' => 'bar', 'line' => 123, 'level' => -1, 'stack' => array(456))));
         $handler->setDefaultLogger($logger, E_ERROR);
         $error = array('type' => E_ERROR + 0x1000000, 'message' => 'foo', 'file' => 'bar', 'line' => 123, 'context' => array(123), 'backtrace' => array(456));
         call_user_func_array(array($handler, 'handleError'), $error);
         $handler->handleFatalError($error);
         restore_error_handler();
         restore_exception_handler();
     } catch (\Exception $e) {
         restore_error_handler();
         restore_exception_handler();
         throw $e;
     }
 }
Esempio n. 30
0
<?php

use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\ExceptionHandler;
require_once __DIR__ . '/../vendor/autoload.php';
$app = (require __DIR__ . '/../src/app.php');
ErrorHandler::register();
ExceptionHandler::register();
require __DIR__ . '/../config/dev.php';
require __DIR__ . '/../src/Http/Routes.php';
$app['capsule'];
$app->run();