/** * Formats function call in a backtrace * * @param array $step backtrace step * @param string $separator Arguments separator to use * * @return string */ public static function getFunctionCall($step, $separator) { $retval = $step['function'] . '('; if (isset($step['args'])) { if (count($step['args']) > 1) { $retval .= $separator; foreach ($step['args'] as $arg) { $retval .= "\t"; $retval .= Error::getArg($arg, $step['function']); $retval .= ',' . $separator; } } elseif (count($step['args']) > 0) { foreach ($step['args'] as $arg) { $retval .= Error::getArg($arg, $step['function']); } } } $retval .= ')'; return $retval; }
/** * Process backtrace to avoid path disclossures, objects and so on * * @param array $backtrace backtrace * * @return array */ public static function processBacktrace($backtrace) { $result = array(); $members = array('line', 'function', 'class', 'type'); foreach ($backtrace as $idx => $step) { /* Create new backtrace entry */ $result[$idx] = array(); /* Make path relative */ if (isset($step['file'])) { $result[$idx]['file'] = Error::relPath($step['file']); } /* Store members we want */ foreach ($members as $name) { if (isset($step[$name])) { $result[$idx][$name] = $step[$name]; } } /* Store simplified args */ if (isset($step['args'])) { foreach ($step['args'] as $key => $arg) { $result[$idx]['args'][$key] = Error::getArg($arg, $step['function']); } } } return $result; }