當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ErrorHandler::handleError方法代碼示例

本文整理匯總了PHP中Symfony\Component\Debug\ErrorHandler::handleError方法的典型用法代碼示例。如果您正苦於以下問題:PHP ErrorHandler::handleError方法的具體用法?PHP ErrorHandler::handleError怎麽用?PHP ErrorHandler::handleError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Debug\ErrorHandler的用法示例。


在下文中一共展示了ErrorHandler::handleError方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handleError

 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);
 }
開發者ID:VOLKERMORD,項目名稱:phpbb,代碼行數:8,代碼來源:error_handler.php

示例2: testHandleDeprecation

 public function testHandleDeprecation()
 {
     $that = $this;
     $logArgCheck = function ($level, $message, $context) use($that) {
         $that->assertEquals(LogLevel::INFO, $level);
         $that->assertArrayHasKey('level', $context);
         $that->assertEquals(E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED, $context['level']);
         $that->assertArrayHasKey('stack', $context);
     };
     $logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $logger->expects($this->once())->method('log')->will($this->returnCallback($logArgCheck));
     $handler = new ErrorHandler();
     $handler->setDefaultLogger($logger);
     @$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, array());
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:15,代碼來源:ErrorHandlerTest.php

示例3: testBootstrappingLogger

 public function testBootstrappingLogger()
 {
     $bootLogger = new BufferingLogger();
     $handler = new ErrorHandler($bootLogger);
     $loggers = array(E_DEPRECATED => array($bootLogger, LogLevel::INFO), E_USER_DEPRECATED => array($bootLogger, LogLevel::INFO), E_NOTICE => array($bootLogger, LogLevel::WARNING), E_USER_NOTICE => array($bootLogger, LogLevel::WARNING), E_STRICT => array($bootLogger, LogLevel::WARNING), E_WARNING => array($bootLogger, LogLevel::WARNING), E_USER_WARNING => array($bootLogger, LogLevel::WARNING), E_COMPILE_WARNING => array($bootLogger, LogLevel::WARNING), E_CORE_WARNING => array($bootLogger, LogLevel::WARNING), E_USER_ERROR => array($bootLogger, LogLevel::CRITICAL), E_RECOVERABLE_ERROR => array($bootLogger, LogLevel::CRITICAL), E_COMPILE_ERROR => array($bootLogger, LogLevel::CRITICAL), E_PARSE => array($bootLogger, LogLevel::CRITICAL), E_ERROR => array($bootLogger, LogLevel::CRITICAL), E_CORE_ERROR => array($bootLogger, LogLevel::CRITICAL));
     $this->assertSame($loggers, $handler->setLoggers(array()));
     $handler->handleError(E_DEPRECATED, 'Foo message', __FILE__, 123, array());
     $expectedLog = array(LogLevel::INFO, 'Foo message', array('type' => E_DEPRECATED, 'file' => __FILE__, 'line' => 123, 'level' => error_reporting()));
     $logs = $bootLogger->cleanLogs();
     unset($logs[0][2]['stack']);
     $this->assertSame(array($expectedLog), $logs);
     $bootLogger->log($expectedLog[0], $expectedLog[1], $expectedLog[2]);
     $mockLogger = $this->getMock('Psr\\Log\\LoggerInterface');
     $mockLogger->expects($this->once())->method('log')->with(LogLevel::WARNING, 'Foo message', $expectedLog[2]);
     $handler->setLoggers(array(E_DEPRECATED => array($mockLogger, LogLevel::WARNING)));
 }
開發者ID:Kyra2778,項目名稱:AMR,代碼行數:16,代碼來源:ErrorHandlerTest.php

示例4: testBootstrappingLogger

 public function testBootstrappingLogger()
 {
     $bootLogger = new BufferingLogger();
     $handler = new ErrorHandler($bootLogger);
     $loggers = array(E_DEPRECATED => array($bootLogger, LogLevel::INFO), E_USER_DEPRECATED => array($bootLogger, LogLevel::INFO), E_NOTICE => array($bootLogger, LogLevel::WARNING), E_USER_NOTICE => array($bootLogger, LogLevel::WARNING), E_STRICT => array($bootLogger, LogLevel::WARNING), E_WARNING => array($bootLogger, LogLevel::WARNING), E_USER_WARNING => array($bootLogger, LogLevel::WARNING), E_COMPILE_WARNING => array($bootLogger, LogLevel::WARNING), E_CORE_WARNING => array($bootLogger, LogLevel::WARNING), E_USER_ERROR => array($bootLogger, LogLevel::CRITICAL), E_RECOVERABLE_ERROR => array($bootLogger, LogLevel::CRITICAL), E_COMPILE_ERROR => array($bootLogger, LogLevel::CRITICAL), E_PARSE => array($bootLogger, LogLevel::CRITICAL), E_ERROR => array($bootLogger, LogLevel::CRITICAL), E_CORE_ERROR => array($bootLogger, LogLevel::CRITICAL));
     $this->assertSame($loggers, $handler->setLoggers(array()));
     $handler->handleError(E_DEPRECATED, 'Foo message', __FILE__, 123, array());
     $logs = $bootLogger->cleanLogs();
     $this->assertCount(1, $logs);
     $log = $logs[0];
     $this->assertSame('info', $log[0]);
     $this->assertSame('Deprecated: Foo message', $log[1]);
     $this->assertArrayHasKey('exception', $log[2]);
     $exception = $log[2]['exception'];
     $this->assertInstanceOf(\ErrorException::class, $exception);
     $this->assertSame('Deprecated: Foo message', $exception->getMessage());
     $this->assertSame(__FILE__, $exception->getFile());
     $this->assertSame(123, $exception->getLine());
     $this->assertSame(E_DEPRECATED, $exception->getSeverity());
     $bootLogger->log(LogLevel::WARNING, 'Foo message', array('exception' => $exception));
     $mockLogger = $this->getMock('Psr\\Log\\LoggerInterface');
     $mockLogger->expects($this->once())->method('log')->with(LogLevel::WARNING, 'Foo message', array('exception' => $exception));
     $handler->setLoggers(array(E_DEPRECATED => array($mockLogger, LogLevel::WARNING)));
 }
開發者ID:ayoah,項目名稱:symfony,代碼行數:24,代碼來源:ErrorHandlerTest.php


注:本文中的Symfony\Component\Debug\ErrorHandler::handleError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。