public static function fromBacktrace($config, $backtrace, $topFile, $topLine) { $stacktrace = new Bugsnag_Stacktrace($config); // PHP backtrace's are misaligned, we need to shift the file/line down a frame foreach ($backtrace as $frame) { if (!self::frameInsideBugsnag($frame)) { $stacktrace->addFrame($topFile, $topLine, isset($frame['function']) ? $frame['function'] : null, isset($frame['class']) ? $frame['class'] : null); } if (isset($frame['file']) && isset($frame['line'])) { $topFile = $frame['file']; $topLine = $frame['line']; } else { $topFile = "[internal]"; $topLine = 0; } } // Add a final stackframe for the "main" method $stacktrace->addFrame($topFile, $topLine, '[main]'); return $stacktrace; }