public static function PHPUnit_Util_Filter::getFilteredStacktrace in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpunit/phpunit/src/Util/Filter.php \PHPUnit_Util_Filter::getFilteredStacktrace()
Filters stack frames from PHPUnit classes.
Parameters
Exception $e:
bool $asString:
Return value
string
12 calls to PHPUnit_Util_Filter::getFilteredStacktrace()
- PHPUnit_Framework_Exception::__toString in vendor/
phpunit/ phpunit/ src/ Framework/ Exception.php - PHPUnit_Framework_ExceptionWrapper::__toString in vendor/
phpunit/ phpunit/ src/ Framework/ ExceptionWrapper.php - PHPUnit_Util_Log_JSON::addError in vendor/
phpunit/ phpunit/ src/ Util/ Log/ JSON.php - An error occurred.
- PHPUnit_Util_Log_JSON::addFailure in vendor/
phpunit/ phpunit/ src/ Util/ Log/ JSON.php - A failure occurred.
- PHPUnit_Util_Log_JSON::addIncompleteTest in vendor/
phpunit/ phpunit/ src/ Util/ Log/ JSON.php - Incomplete test.
File
- vendor/
phpunit/ phpunit/ src/ Util/ Filter.php, line 25
Class
- PHPUnit_Util_Filter
- Utility class for code filtering.
Code
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;
}