/** * Parse a debug backtrace * * @param array $trace Debug backtrace output * @param $messageName * @return array */ protected static function _parseTrace($trace, $messageName) { $message = array(); for ($i = 0, $len = count($trace); $i < $len; $i++) { $keySet = isset($trace[$i]['class']) && isset($trace[$i]['function']); $selfCall = $keySet && $trace[$i]['class'] == 'FireCake'; if (!$selfCall) { $message = array('Class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : '', 'Type' => isset($trace[$i]['type']) ? $trace[$i]['type'] : '', 'Function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : '', 'Message' => $messageName, 'File' => isset($trace[$i]['file']) ? Debugger::trimPath($trace[$i]['file']) : '', 'Line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : '', 'Args' => isset($trace[$i]['args']) ? FireCake::stringEncode($trace[$i]['args']) : '', 'Trace' => FireCake::_escapeTrace(array_splice($trace, $i + 1))); break; } } return $message; }