Get back trace
@return array|null
763008
private function getTrace()
    {
        $trace = array();

        if (PHP_VERSION_ID >= 50400) {
            $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10);
        } else if (PHP_VERSION_ID >= 50306) {
            $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        } else {
            $trace = debug_backtrace();
        }
        if (empty($trace)) {
            return '';
        }
        array_shift($trace); // ignore $this->getTrace();
        array_shift($trace); // ignore $this->process()
        $i = 0;
        $returnArray = array();
        while (isset($trace[$i]['class']) && false === strpos($trace[$i]['class'], 'Zend\\Log')
            && false === strpos($trace[$i]['class'], 'DhErrorLogging')) {
            $i++;
            $returnArray[] = array(
                'file'     => isset($trace[$i]['file'])   ? $trace[$i]['file']   : null,
                'line'     => isset($trace[$i]['line'])   ? $trace[$i]['line']   : null,
                'class'    => isset($trace[$i]['class'])    ? $trace[$i]['class']    : null,
                'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null,
            );
        }

        return $returnArray;
    }
127752
public static function getCalledFrom($index = 0)
    {
        $backtrace = debug_backtrace();

        if (!isset($backtrace[$index])) {
            return 'Unknown trace with index: ' . $index;
        }

        return self::getCalledFromTrace($backtrace[$index]);
    }
783557
protected function getBacktrace()
    {
        // Remove the fist step from the backtrace,
        // because that is the internal function in kreXX.
        $backtrace = debug_backtrace();

        // We remove all steps that came from inside the kreXX lib.
        $krexxScr = KREXX_DIR . 'src';
        foreach ($backtrace as $key => $step) {
            if (isset($step[static::TRACE_FILE]) && strpos($step[static::TRACE_FILE], $krexxScr) !== false) {
                unset($backtrace[$key]);
            } else {
                // No need to ga wurther, because we should have passed the
                // kreXX part.
                break;
            }
        }

        // Reset the array keys, because the 0 is now missing.
        return array_values($backtrace);
    }
1190908
public function cleanBacktrace(array $trace): array
    {
        // find first not removable index
        $firstNotRemovable = 0;
        foreach ($trace as $index => $item) {
            if (! $this->shouldRemoveStack($item)) {
                $firstNotRemovable = $index;
                break;
            }
        }

        $trace = array_slice($trace, $firstNotRemovable ?: 0);

        return $trace;
    }
660791
public function renderTrace($trace)
    {
        $output = '<div class="info">';
        $output .= '<h3>Trace</h3>';
        $output .= Backtrace::get_rendered_backtrace($trace);
        $output .= '</div>';

        return $output;
    }
557610
public function getCurrent()
    {
        if (false === $this->pointer || empty($this->ids)) {
            return null;
        }
        return $this->ids[$this->pointer];
    }
452150
protected function getPrev()
    {
        if (!$this->current)
        {
            return null;
        }
        if ($this->prev !== -1)
        {
            return $this->prev;
        }
        $this->load();
        for ($i = 0; $i < count($this->items); $i++)
        {
            if ($this->items[$i]->id == $this->current->id)
            {
                if ($i > 0)
                {
                    $this->prev = $this->items[$i - 1];
                    return $this->prev;
                }
                break;
            }
        }
        return null;
    }
449889
public function backtraceAction(array $backtrace = null)
    {
        if ($this->pool->emergencyHandler->checkMaxCall() === true) {
            // Called too often, we might get into trouble here!
            return $this;
        }

        $this->pool->reset();

        // Find caller.
        $caller = $this->callerFinder->findCaller(static::TRACE_BACKTRACE, array());
        $this->pool->scope->setScope($caller[static::TRACE_VARNAME]);

        $analysis = $this->pool
            ->createClass('Brainworxx\\Krexx\\Analyse\\Routing\\Process\\ProcessBacktrace')
            ->process($backtrace);

        // Detect the encoding on the start-chunk-string of the analysis
        // for a complete encoding picture.
        $this->pool->chunks->detectEncoding($analysis);

        // Now that our analysis is done, we must check if there was an emergency
        // break.
        if ($this->pool->emergencyHandler->checkEmergencyBreak() === true) {
            return $this;
        }

        // Add the caller as metadata to the chunks class. It will be saved as
        // additional info, in case we are logging to a file.
        $this->pool->chunks->addMetadata($caller);

        // We need to get the footer before the generating of the header,
        // because we need to display messages in the header from the configuration.
        $footer = $this->outputFooter($caller);

        $this->outputService
            ->addChunkString($this->pool->render->renderHeader(static::TRACE_BACKTRACE, $this->outputCssAndJs()))
            ->addChunkString($analysis)
            ->addChunkString($footer)
            ->finalize();

        return $this;
    }
1158030
private static function getDebugFile()
    {
        $trace = \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);

        foreach (\array_reverse($trace) as $stackFrame) {
            if (!self::isDebugCall($stackFrame)) {
                continue;
            }

            if (\preg_match('/eval\(/', $stackFrame['file'])) {
                \preg_match_all('/([^\(]+)\((\d+)/', $stackFrame['file'], $matches);

                return $matches[1][0];
            }

            return $stackFrame['file'];
        }
    }
221129
protected function getBacktrace(\Exception $exception)
    {
        $backtrace = array();

        $backtrace[] = '---';
        $backtrace[] = $this->getErrorMessage($exception);
        $backtrace[] = '---';

        // Allow marshalling of the trace: PHP marks getTraceAsString as final :-(
        if (method_exists($exception, 'getPreviousTraceAsString')) {
            $backtrace = array_merge($backtrace, explode("\n", $exception->getPreviousTraceAsString()));
        } else {
            $backtrace = array_merge($backtrace, explode("\n", $exception->getTraceAsString()));
        }

        if (($previous = $exception->getPrevious())) {
            $backtrace = array_merge($backtrace, $this->getBacktrace($previous)); // Recurse
        }

        return $backtrace;
    }
665206
protected function getCallerFromStackTrace()
    {
        $trace = collect(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))->forget(0);

        return $trace->first(function ($frame) {
            if (! isset($frame['file'])) {
                return false;
            }

            return ! Str::contains($frame['file'],
                base_path('vendor'.DIRECTORY_SEPARATOR.$this->ignoredVendorPath())
            );
        });
    }
1194921
private function getBacktraceUse()
    {
        $debugBacktrace = collect(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 30))->filter(function ($backtrace) {
            $backtraceClass = (isset($backtrace['class'])) ? $backtrace['class'] : null;

            return $backtraceClass === $this->listenClass;
        })->first();
        $checkBacktrace = null;
        $backtraceFile = (isset($debugBacktrace['file'])) ? $debugBacktrace['file'] : null;
        $backtraceFunction = (isset($debugBacktrace['function'])) ? $debugBacktrace['function'] : null;
        if (!is_null($debugBacktrace) && str_contains($backtraceFile, 'Illuminate/Database/Eloquent/SoftDeletingScope.php') && $backtraceFunction == 'update') {
            $checkBacktrace = [
                'object'   => $debugBacktrace['object'],
                'function' => $debugBacktrace['function'],
                'args'     => $debugBacktrace['args'][0],
            ];
        }

        return $checkBacktrace;
    }
269950
protected function _backtrackLoop()
    {
        $this->_popParent();

        if (!$this->_hasParents()) {
            return $this->_createIteration(null, null);
        }

        $parent  = &$this->_getCurrentIterable();
        $current = $this->_createCurrentIteration($parent);
        next($parent);

        if ($this->_isMode(R::MODE_CHILD_FIRST)) {
            return $current;
        }

        return $this->_loop();
    }
1201756
public function getTraits()
    {
        $return = parent::getTraits();
        if ($return !== null) {
            foreach ($return as $key => $val) {
                $return[$key] = new static($val->getName());
            }
        }

        return $return;
    }
196701
public static function parseBacktrace()
	{
		$file = '-';
		$line = 0;

		// Loop through the backtrace items
		foreach (self::getBacktrace() as $item)
		{
			// Looking for the last instance of one of the following classes...
			// this will be our indicator of the command that originated this query
			if (isset($item['class'])
			 && ($item['class'] == 'Hubzero\Database\Relational'
			 ||  $item['class'] == 'Hubzero\Database\Relationship\Relationship'
			 ||  $item['class'] == 'Hubzero\Database\Rows'))
			{

				$file = (isset($item['file'])) ? str_replace(PATH_CORE, '', $item['file']) : $file;
				$line = (isset($item['line'])) ? $item['line'] : $line;
			}
		}

		return array($file, $line);
	}
1218946
public function notFound()
    {
        if (isset($this->request->path_array[1])) {
            switch ($this->request->path_array[1]) {
                case 'methods':
                    return $this->getMethods(true);
                    break;
            }
        }

        return null;
    }
1315233
public static function getCalledFromTrace($trace)
    {
        // Get file and line number
        $calledFromFile = '';
        if (isset($trace['file'])) {
            $calledFromFile .= $trace['file'] . ' line ' . $trace['line'];
            $calledFromFile = str_replace('\\', '/', $calledFromFile);
            $calledFromFile = (!empty(self::$documentRoot) ? substr($calledFromFile, strlen(self::$documentRoot)) : $calledFromFile);
            $calledFromFile = trim($calledFromFile, '/');
        }

        // Get function call
        $calledFromFunction = '';
        if (isset($trace['function'])) {
            $calledFromFunction .= (isset($trace['class']) ? $trace['class'] : '');
            $calledFromFunction .= (isset($trace['type']) ? $trace['type'] : '');
            $calledFromFunction .= $trace['function'] . '()';
        }

        // Return called from
        if ($calledFromFile) {
            return $calledFromFile;
        } elseif ($calledFromFunction) {
            return $calledFromFunction;
        } else {
            return 'Unable to get called from trace';
        }
    }