src/ErrorHandler/ErrorHandler.php
public function backtrace($error = null)
    {
        $exception = null;
        $isFatalError = false;
        if ($error instanceof \Exception) {
            $exception = $error;
        } elseif ($error) {
            // array or Event
            $exception = $error['exception'];
            $isFatalError = \in_array($error['type'], $this->errCategories['fatal']);
        }
        if ($exception) {
            $backtrace = $exception->getTrace();
            \array_unshift($backtrace, array(
                'file' => $exception->getFile(),
                'line' => $exception->getLine(),
            ));
        } elseif ($isFatalError && \extension_loaded('xdebug')) {
            $backtrace = \xdebug_get_function_stack();
            $backtrace = \array_reverse($backtrace);
            $backtrace = $this->backtraceRemoveInternal($backtrace);
            $errorFileLine = array(
                'file' => $error['file'],
                'line' => $error['line'],
            );
            \array_pop($backtrace);   // pointless entry that xdebug_get_function_stack() includes
            if (empty($backtrace)) {
                return array();
            }
            if (\array_intersect_assoc($errorFileLine, $backtrace[0]) !== $errorFileLine) {
                \array_unshift($backtrace, $errorFileLine);
            }
        } elseif ($isFatalError) {
            // backtrace unavailable
            $backtrace = array();
        } else {
            $backtrace = \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
            $backtrace = $this->backtraceRemoveInternal($backtrace);
        }
        return $this->normalizeTrace($backtrace);
    }
public function backtrace($error = null)
    {
        $exception = null;
        $isFatalError = false;
        if ($error instanceof \Exception) {
            $exception = $error;
        } elseif ($error) {
            // array or Event
            $exception = $error['exception'];
            $isFatalError = \in_array($error['type'], $this->errCategories['fatal']);
        }
        if ($exception) {
            $backtrace = $exception->getTrace();
            \array_unshift($backtrace, array(
                'file' => $exception->getFile(),
                'line' => $exception->getLine(),
            ));
        } elseif ($isFatalError && \extension_loaded('xdebug')) {
            $backtrace = \xdebug_get_function_stack();
            $backtrace = \array_reverse($backtrace);
            $backtrace = $this->backtraceRemoveInternal($backtrace);
            $errorFileLine = array(
                'file' => $error['file'],
                'line' => $error['line'],
            );
            \array_pop($backtrace);   // pointless entry that xdebug_get_function_stack() includes
            if (empty($backtrace)) {
                return array();
            }
            if (\array_intersect_assoc($errorFileLine, $backtrace[0]) !== $errorFileLine) {
                \array_unshift($backtrace, $errorFileLine);
            }
        } elseif ($isFatalError) {
            // backtrace unavailable
            $backtrace = array();
        } else {
            $backtrace = \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
            $backtrace = $this->backtraceRemoveInternal($backtrace);
        }
        return $this->normalizeTrace($backtrace);
    }
Get backtrace

To get trace from within shutdown function utilizes xdebug_get_function_stack() if available

@param array|Event|Exception $error (optional) error details if getting error backtrace

@return array