/** * Cleans up a trace array * * @param array $trace * @param int $skipLines * @param null $basePath * * @return null|string */ protected static function _cleanTrace(array &$trace, $skipLines = null, $basePath = null) { $_trace = array(); $_basePath = $basePath ?: \Kisma::get('app.base_path'); // Skip some lines if (!empty($skipLines) && count($trace) > $skipLines) { $trace = array_slice($trace, $skipLines); } foreach ($trace as $_index => $_code) { $_traceItem = array(); Scalar::sins($trace[$_index], 'file', 'Unspecified'); Scalar::sins($trace[$_index], 'line', 0); Scalar::sins($trace[$_index], 'function', 'Unspecified'); $_traceItem['file_name'] = trim(str_replace(array($_basePath, "\t", "\r", "\n", PHP_EOL, 'phar://'), array(null, ' ', null, null, null, null), $trace[$_index]['file'])); $_args = null; if (isset($_code['args']) && !empty($_code['args'])) { foreach ($_code['args'] as $_arg) { if (is_object($_arg)) { $_args .= get_class($_arg) . ', '; } else { if (is_array($_arg)) { $_args .= '[array], '; } else { if (is_bool($_arg)) { if ($_arg) { $_args .= 'true, '; } else { $_args .= 'false, '; } } else { if (is_numeric($_arg)) { $_args .= $_arg . ', '; } else { if (is_scalar($_arg)) { $_args .= '"' . $_arg . '", '; } else { $_args .= '"' . gettype($_arg) . '", '; } } } } } } } $_traceItem['line'] = $trace[$_index]['line']; if (isset($_code['type'])) { $_traceItem['function'] = (isset($_code['class']) ? $_code['class'] : null) . $_code['type'] . $_code['function']; } else { $_traceItem['function'] = $_code['function']; } $_traceItem['function'] .= '(' . ($_args ? ' ' . trim($_args, ', ') . ' ' : null) . ')'; $_traceItem['index'] = $_index; $_trace[] = $_traceItem; } return $_trace; }