当前位置: 首页>>代码示例>>PHP>>正文


PHP Debug\ErrorHandler类代码示例

本文整理汇总了PHP中Symfony\Component\Debug\ErrorHandler的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler类的具体用法?PHP ErrorHandler怎么用?PHP ErrorHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ErrorHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testConfigure

 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]);
 }
开发者ID:alexbogo,项目名称:symfony,代码行数:26,代码来源:DebugHandlersListenerTest.php

示例2: testConsoleEvent

 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());
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:30,代码来源:DebugHandlersListenerTest.php

示例3: injectLogger

 public function injectLogger()
 {
     if (null !== $this->logger) {
         ErrorHandler::setLogger($this->logger, $this->channel);
         $this->logger = null;
     }
 }
开发者ID:GeorgeBroadley,项目名称:caffeine-vendor,代码行数:7,代码来源:ErrorsLoggerListener.php

示例4: testStacking

 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;
     }
 }
开发者ID:anthrotech,项目名称:laravel_sample,代码行数:31,代码来源:DebugClassLoaderTest.php

示例5: __construct

 /**
  * 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();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:36,代码来源:CLI.php

示例6: boot

 /**
  * @return void
  * @author Michaël VEROUX
  */
 public function boot()
 {
     if ('prod' === $this->container->getParameter('kernel.environment')) {
         $handler = ErrorHandler::register();
         $handler->setExceptionHandler(array($this, 'handle'));
     }
 }
开发者ID:phpmike,项目名称:MvErrorLogBundle,代码行数:11,代码来源:MvErrorLogBundle.php

示例7: testStacking

 /**
  * @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();
 }
开发者ID:romainneutron,项目名称:symfony,代码行数:38,代码来源:DebugClassLoaderTest.php

示例8: bootstrap

 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();
 }
开发者ID:cmsilex,项目名称:cmsilex,代码行数:59,代码来源:Application.php

示例9: register

 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;
 }
开发者ID:jacobjjc,项目名称:PageKit-framework,代码行数:10,代码来源:ExceptionServiceProvider.php

示例10: __construct

 /**
  * 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';
         }
     }
 }
开发者ID:schnello,项目名称:volkszaehler.org,代码行数:14,代码来源:Router.php

示例11: register

 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);
         }
     });
 }
开发者ID:izziaraffaele,项目名称:webcomposer,代码行数:12,代码来源:ErrorHandlerServiceProvider.php

示例12: __construct

 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();
 }
开发者ID:nawrasg,项目名称:tvguide,代码行数:12,代码来源:Application.php

示例13: run

 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();
 }
开发者ID:lmaslowski,项目名称:phpbench,代码行数:12,代码来源:PhpBench.php

示例14: __construct

 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));
 }
开发者ID:jdesrosiers,项目名称:resourceful,代码行数:12,代码来源:Resourceful.php

示例15: 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();
 }
开发者ID:keboola,项目名称:syrup,代码行数:13,代码来源:Debug.php


注:本文中的Symfony\Component\Debug\ErrorHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。