本文整理汇总了PHP中Exception::getClassname方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getClassname方法的具体用法?PHP Exception::getClassname怎么用?PHP Exception::getClassname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getClassname方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printExceptionTrace
public function printExceptionTrace(\Exception $e)
{
static $limit = 10;
$class = $e instanceof \PHPUnit_Framework_ExceptionWrapper ? $e->getClassname() : get_class($e);
if ($this->rawStackTrace) {
$this->message(\PHPUnit_Util_Filter::getFilteredStacktrace($e, true, false))->writeln();
return;
}
$trace = \PHPUnit_Util_Filter::getFilteredStacktrace($e, false);
$i = 0;
foreach ($trace as $step) {
if ($i >= $limit) {
break;
}
$i++;
$message = $this->message($i)->prepend('#')->width(4);
if (!isset($step['file'])) {
foreach (['class', 'type', 'function'] as $info) {
if (!isset($step[$info])) {
continue;
}
$message->append($step[$info]);
}
$message->writeln();
continue;
}
$message->append($step['file'] . ':' . $step['line']);
$message->writeln();
}
$prev = $e->getPrevious();
if ($prev) {
$this->printExceptionTrace($prev);
}
}
示例2: exceptionToString
/**
* Returns a description for an exception.
*
* @param Exception $e
* @return string
* @since Method available since Release 3.2.0
*/
public static function exceptionToString(Exception $e)
{
if ($e instanceof PHPUnit_Framework_SelfDescribing) {
$buffer = $e->toString();
if ($e instanceof PHPUnit_Framework_ExpectationFailedException && $e->getComparisonFailure()) {
$buffer = $buffer . $e->getComparisonFailure()->getDiff();
}
if (!empty($buffer)) {
$buffer = trim($buffer) . "\n";
}
} elseif ($e instanceof PHPUnit_Framework_Error) {
$buffer = $e->getMessage() . "\n";
} elseif ($e instanceof PHPUnit_Framework_ExceptionWrapper) {
$buffer = $e->getClassname() . ': ' . $e->getMessage() . "\n";
} else {
$buffer = get_class($e) . ': ' . $e->getMessage() . "\n";
}
return $buffer;
}
示例3: printException
public function printException(\Exception $e)
{
static $limit = 10;
$class = $e instanceof \PHPUnit_Framework_ExceptionWrapper ? $e->getClassname() : get_class($e);
$this->message("[%s] %s")->with($class, $e->getMessage())->block('error')->writeln($e instanceof \PHPUnit_Framework_AssertionFailedError ? OutputInterface::VERBOSITY_DEBUG : OutputInterface::VERBOSITY_VERBOSE);
if ($this->rawStackTrace) {
$this->message($e->getTraceAsString())->writeln();
return;
}
$trace = \PHPUnit_Util_Filter::getFilteredStacktrace($e, false);
$i = 0;
foreach ($trace as $step) {
if ($i >= $limit) {
break;
}
$i++;
$message = $this->message($i)->prepend('#')->width(4);
if (!isset($step['file'])) {
foreach (['class', 'type', 'function'] as $info) {
if (!isset($step[$info])) {
continue;
}
$message->append($step[$info]);
}
$message->writeln();
continue;
}
$message->append($step['file'] . ':' . $step['line']);
$message->writeln();
}
$prev = $e->getPrevious();
if ($prev) {
$this->printException($prev);
}
}