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


PHP Exception::getSyntheticTrace方法代码示例

本文整理汇总了PHP中Exception::getSyntheticTrace方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getSyntheticTrace方法的具体用法?PHP Exception::getSyntheticTrace怎么用?PHP Exception::getSyntheticTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exception的用法示例。


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

示例1: getFilteredStacktrace

 /**
  * Filters stack frames from PHPUnit classes.
  *
  * @param  Exception $e
  * @param  boolean   $filterTests
  * @param  boolean   $asString
  * @return string
  */
 public static function getFilteredStacktrace(Exception $e, $filterTests = TRUE, $asString = TRUE)
 {
     if ($asString === TRUE) {
         $filteredStacktrace = '';
     } else {
         $filteredStacktrace = array();
     }
     $groups = array('DEFAULT');
     if (!defined('PHPUNIT_TESTSUITE')) {
         $groups[] = 'PHPUNIT';
     }
     if ($filterTests) {
         $groups[] = 'TESTS';
     }
     if ($e instanceof PHPUnit_Framework_SyntheticError) {
         $eTrace = $e->getSyntheticTrace();
     } else {
         $eTrace = $e->getTrace();
     }
     if (!self::frameExists($eTrace, $e->getFile(), $e->getLine())) {
         array_unshift($eTrace, array('file' => $e->getFile(), 'line' => $e->getLine()));
     }
     foreach ($eTrace as $frame) {
         if (isset($frame['file']) && is_file($frame['file']) && !PHP_CodeCoverage::getInstance()->filter()->isFiltered($frame['file'], $groups, TRUE)) {
             if ($asString === TRUE) {
                 $filteredStacktrace .= sprintf("%s:%s\n", $frame['file'], isset($frame['line']) ? $frame['line'] : '?');
             } else {
                 $filteredStacktrace[] = $frame;
             }
         }
     }
     return $filteredStacktrace;
 }
开发者ID:KnpLabs,项目名称:phpunit-easyinstall,代码行数:41,代码来源:Filter.php

示例2: getFilteredStacktrace

 /**
  * Filters stack frames from PHPUnit classes.
  *
  * @param  Exception $e
  * @param  boolean   $asString
  * @return string
  */
 public static function getFilteredStacktrace(Exception $e, $asString = TRUE)
 {
     if (!defined('PHPUNIT_TESTSUITE')) {
         $blacklist = PHPUnit_Util_GlobalState::phpunitFiles();
     } else {
         $blacklist = array();
     }
     if ($asString === TRUE) {
         $filteredStacktrace = '';
     } else {
         $filteredStacktrace = array();
     }
     if ($e instanceof PHPUnit_Framework_SyntheticError) {
         $eTrace = $e->getSyntheticTrace();
         $eFile = $e->getSyntheticFile();
         $eLine = $e->getSyntheticLine();
     } else {
         $eTrace = $e->getTrace();
         $eFile = $e->getFile();
         $eLine = $e->getLine();
     }
     if (!self::frameExists($eTrace, $eFile, $eLine)) {
         array_unshift($eTrace, array('file' => $eFile, 'line' => $eLine));
     }
     foreach ($eTrace as $frame) {
         if (isset($frame['file']) && is_file($frame['file']) && !isset($blacklist[$frame['file']])) {
             if ($asString === TRUE) {
                 $filteredStacktrace .= sprintf("%s:%s\n", $frame['file'], isset($frame['line']) ? $frame['line'] : '?');
             } else {
                 $filteredStacktrace[] = $frame;
             }
         }
     }
     return $filteredStacktrace;
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:42,代码来源:Filter.php

示例3: getFilteredStacktrace

 /**
  * Filters stack frames from PHPUnit classes.
  *
  * @param  Exception $e
  * @param  boolean   $asString
  * @return string
  */
 public static function getFilteredStacktrace(Exception $e, $asString = TRUE)
 {
     $prefix = FALSE;
     $script = realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);
     if (defined('__PHPUNIT_PHAR__')) {
         $prefix = 'phar://' . __PHPUNIT_PHAR__ . '/';
     }
     if (!defined('PHPUNIT_TESTSUITE')) {
         $blacklist = PHPUnit_Util_GlobalState::phpunitFiles();
     } else {
         $blacklist = array();
     }
     if ($asString === TRUE) {
         $filteredStacktrace = '';
     } else {
         $filteredStacktrace = array();
     }
     if ($e instanceof PHPUnit_Framework_SyntheticError) {
         $eTrace = $e->getSyntheticTrace();
         $eFile = $e->getSyntheticFile();
         $eLine = $e->getSyntheticLine();
     } else {
         if ($e->getPrevious()) {
             $eTrace = $e->getPrevious()->getTrace();
         } else {
             $eTrace = $e->getTrace();
         }
         $eFile = $e->getFile();
         $eLine = $e->getLine();
     }
     if (!self::frameExists($eTrace, $eFile, $eLine)) {
         array_unshift($eTrace, array('file' => $eFile, 'line' => $eLine));
     }
     foreach ($eTrace as $frame) {
         if (isset($frame['file']) && is_file($frame['file']) && !isset($blacklist[$frame['file']]) && ($prefix === FALSE || strpos($frame['file'], $prefix) !== 0) && $frame['file'] !== $script) {
             if ($asString === TRUE) {
                 $filteredStacktrace .= sprintf("%s:%s\n", $frame['file'], isset($frame['line']) ? $frame['line'] : '?');
             } else {
                 $filteredStacktrace[] = $frame;
             }
         }
     }
     return $filteredStacktrace;
 }
开发者ID:jeanCarloMachado,项目名称:challenges,代码行数:51,代码来源:Filter.php

示例4: getFilteredStacktrace

 /**
  * Filters stack frames from PHPUnit classes.
  *
  * @param Exception $e        	
  * @param bool $asString        	
  * @return string
  */
 public static function getFilteredStacktrace(Exception $e, $asString = true)
 {
     $prefix = false;
     $script = realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);
     if (defined('__PHPUNIT_PHAR_ROOT__')) {
         $prefix = __PHPUNIT_PHAR_ROOT__;
     }
     if ($asString === true) {
         $filteredStacktrace = '';
     } else {
         $filteredStacktrace = array();
     }
     if ($e instanceof PHPUnit_Framework_SyntheticError) {
         $eTrace = $e->getSyntheticTrace();
         $eFile = $e->getSyntheticFile();
         $eLine = $e->getSyntheticLine();
     } elseif ($e instanceof PHPUnit_Framework_Exception) {
         $eTrace = $e->getSerializableTrace();
         $eFile = $e->getFile();
         $eLine = $e->getLine();
     } else {
         if ($e->getPrevious()) {
             $e = $e->getPrevious();
         }
         $eTrace = $e->getTrace();
         $eFile = $e->getFile();
         $eLine = $e->getLine();
     }
     if (!self::frameExists($eTrace, $eFile, $eLine)) {
         array_unshift($eTrace, array('file' => $eFile, 'line' => $eLine));
     }
     $blacklist = new PHPUnit_Util_Blacklist();
     foreach ($eTrace as $frame) {
         if (isset($frame['file']) && is_file($frame['file']) && !$blacklist->isBlacklisted($frame['file']) && ($prefix === false || strpos($frame['file'], $prefix) !== 0) && $frame['file'] !== $script) {
             if ($asString === true) {
                 $filteredStacktrace .= sprintf("%s:%s\n", $frame['file'], isset($frame['line']) ? $frame['line'] : '?');
             } else {
                 $filteredStacktrace[] = $frame;
             }
         }
     }
     return $filteredStacktrace;
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:50,代码来源:Filter.php

示例5: printException

 protected function printException($idx, $title, \Exception $ex)
 {
     $indent = str_repeat(' ', strlen("  {$idx}) "));
     if ($ex instanceof \PHPUnit_Framework_SyntheticError) {
         $trace = $ex->getSyntheticTrace();
     } else {
         $trace = $ex->getTrace();
     }
     // Insert exception as first element of the trace
     array_unshift($trace, array('file' => $ex->getFile(), 'line' => $ex->getLine()));
     // Process and filter stack trace
     $last = null;
     $offending = null;
     $stacktrace = array();
     $groups = $this->debug ? array() : array('DEFAULT', 'PHPUNIT');
     $filter = \PHP_CodeCoverage_Filter::getInstance();
     foreach ($trace as $frame) {
         if (isset($frame['file']) && isset($frame['line']) && !$filter->isFiltered($frame['file'], $groups, TRUE)) {
             // Skip duplicated frames
             if (!$this->debug && $last && $last['file'] === $frame['file'] && $last['line'] === $frame['line']) {
                 continue;
             }
             $last = $frame;
             // Skip blacklisted eval frames: /path/to/file(line) : eval()'d code:line
             if (preg_match('/^(.+?)\\([0-9]+\\)\\s:\\seval/', $frame['file'], $m)) {
                 if ($filter->isFiltered($m[1], $groups, TRUE)) {
                     continue;
                 }
             }
             // Check spec files
             if (0 === strpos($frame['file'], Spec::SCHEME . '://')) {
                 $frame['file'] = substr($frame['file'], strlen(Spec::SCHEME . '://'));
                 if (0 !== strpos($frame['file'], '/')) {
                     $frame['file'] = '.' . DIRECTORY_SEPARATOR . $frame['file'];
                 }
                 $lines = file($frame['file']);
                 $offending = trim($lines[$frame['line'] - 1]);
             }
             $stacktrace[] = $frame['file'] . ':' . $frame['line'];
         }
     }
     // Print title
     $this->write("  {$idx}) {$title}" . PHP_EOL);
     // Print exception message
     $msg = str_replace(PHP_EOL, PHP_EOL . $indent, $ex->getMessage());
     $this->write($indent . "[31m{$msg}[0m" . PHP_EOL);
     // Print offending spec line if found
     if ($offending) {
         $ch = $this->colors ? '❯' : '>';
         $this->write($indent . "[33;1m{$ch} {$offending}[0m" . PHP_EOL);
     }
     $ch = '#';
     foreach ($stacktrace as $frame) {
         $this->write("{$indent}[30;1m{$ch} {$frame}[0m" . PHP_EOL);
         if (!$this->verbose && !$this->debug) {
             break;
         }
     }
     $this->write(PHP_EOL);
 }
开发者ID:rafeca,项目名称:Spec-PHP,代码行数:60,代码来源:ResultPrinter.php


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