本文整理汇总了PHP中Exception::getSyntheticFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getSyntheticFile方法的具体用法?PHP Exception::getSyntheticFile怎么用?PHP Exception::getSyntheticFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getSyntheticFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}