Get last function name and it params from backtrace
@param   array $trace Backtrace
@return  string
544678
protected function _getSourceFunction($trace)
    {
        $lastTrace = $this->_getLastTrace($trace);

        if (isset($lastTrace['function']) || isset($lastTrace['class'])) {

            $args = '';
            if (isset($lastTrace['args'])) {
                $args = '( ' . count($lastTrace['args']) . ' args' . ' )';
            }

            if (isset($lastTrace['class'])) {
                $function = $lastTrace['class'] . ' ' . $lastTrace['type'] . ' ' . $lastTrace['function'] . ' ' . $args;
            } else {
                $function = $lastTrace['function'] . ' ' . $args;
            }

            return 'Function: ' . $function . '<br />';
        }

        return '';
    }
106618
protected function getTwigInfo($trace)
    {
        $file = $trace['object']->getTemplateName();

        if (isset($trace['line'])) {
            foreach ($trace['object']->getDebugInfo() as $codeLine => $templateLine) {
                if ($codeLine <= $trace['line']) {
                    return [$file, $templateLine];
                }
            }
        }

        return [$file, -1];
    }
642282
static private function getTextBackTrace($backtrace) {
		$str = '';
	
		foreach ($backtrace as $step) {
			if ($step['function']!='getTextBackTrace' && $step['function']!='handle_error')
			{
				if (isset($step['file']) && isset($step['line'])) {
					$str .= "In ".$step['file'] . " at line ".$step['line'].": ";
				}
				if (isset($step['class']) && isset($step['type']) && isset($step['function'])) {
					$str .= $step['class'].$step['type'].$step['function'].'(';
				}
	
				if (is_array($step['args'])) {
					$drawn = false;
					$params = '';
					foreach ( $step['args'] as $param)
					{
						$params .= self::getPhpVariableAsText($param);
						//$params .= var_export($param, true);
						$params .= ', ';
						$drawn = true;
					}
					$str .= $params;
					if ($drawn == true)
					$str = substr($str, 0, strlen($str)-2);
				}
				$str .= ')';
				$str .= "\n";
			}
		}
	
		return $str;
	}
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]);
    }
283501
public static function backtrace($return = false, $html = true, $withArgs = true)
        {
            $trace  = debug_backtrace();
            return static::trace($trace, $return, $html, $withArgs);
        }
616807
public static function message($backtrace)
    {
        if (static::isThrowable($backtrace)) {
            $name = get_class($backtrace);
            $code = $backtrace->getCode();
            return "`{$name}` Code({$code}): " . $backtrace->getMessage();
        } elseif (isset($backtrace['message'])) {
            $code = isset($backtrace['code']) ? $backtrace['code'] : 0;
            $name = static::errorType($code);
            return "`{$name}` Code({$code}): " . $backtrace['message'];
        }
    }
83235
private function buildTrace($exception)
    {
        $_trace = [];
        foreach ($exception->getTrace() as $key => $item) {
            $_trace[$key] = [
                'file' => isset($item['file']) ? $item['file'] : null,
                'line' => isset($item['line']) ? $item['line'] : null,
                'function' => isset($item['function']) ? $item['function'] : null,
                'class' => isset($item['class']) ? $item['class'] : null,
            ];
        }
        
        return $_trace;
    }
1140894
public static function format_backtrace($backtrace) {
		global $CFG;
		$html = '';
		$i = count($backtrace);
		foreach ($backtrace as $trace) {
			$file = (isset($trace['file'])) ? str_replace($CFG->base_absroot, '', $trace['file']) : 'unknown';
			$line = 'Line: '. ((isset($trace['line'])) ? $trace['line'] : '-');
			$func = ((isset($trace['function'])) ? $trace['function'] : '');
			ini_set('html_errors', 0);
			$argstr = [];
			if (!empty($trace['args']) && is_array($trace['args'])) {
				foreach ($trace['args'] as $arg) {
					ob_start();
					var_dump($arg);
					$stringval = ob_get_contents();
					ob_end_clean();
					$argstr[] = $stringval;
				}
			}
			$args = implode(', ', $argstr);
			$func .= '('.$args.')';
			if (\pdyn\base\Utils::is_cli_env() === true) {
				$html .= $i."\t".$file."\t".$line."\t".$func."\n";
			} else {
				$html .= '<tr>';
					$html .= '<td style="vertical-align:top">'.$i.'</td>';
					$html .= '<td style="vertical-align:top">'.$file.'</td>';
					$html .= '<td style="vertical-align:top">'.$line.'</td>';
					$html .= '<td><pre style="margin:0;">'.$func.'</pre></td>';
				$html .= '</tr>';
			}
			$i--;
		}
		return (\pdyn\base\Utils::is_cli_env() === true)
			? "**********\n".$html."**********\n"
			: '<table cellspacing="5" style="color:inherit">'.$html.'</table>';
	}
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;
    }
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;
    }
1084121
function formatDebugTrace(array $backtrace)
    {
        $rV = '';

        foreach ($backtrace as $trace) {
            $functionName = $traceStr = $trace['function'];
            $args = \join(', ', $trace['args']);
            $className = empty($trace['class'])
                ? ''
                : $traceStr = $trace['class'] . '::';
            $parameters = \count($trace['args']) > 0
                ? '( ' . $args . ' )'
                : '()';

            $rV .= "\n" . $className . $functionName . $parameters;
        }

        $rV .= "\n";

        return $rV;
    }
294855
private function traceHTML(array $trace) {
            ?>
            <table class="table" border="1">
                <thead>
                <tr>
                    <th>#</th>
                    <th>Method</th>
                    <th>Args</th>
                    <th>File</th>
                    <th>Line</th>
                </tr>
                </thead>
                <tbody><?php
                    foreach ($trace as $k => $v) {
                        $func = $loc = $line = '';
                        self::formatTraceLine($v, $func, $loc, $line);

                        if (isset($v['args']) && !empty($v['args'])) {
                            $args = Dump::html($v['args']);
                        } else {
                            $args = '<span class="label label-default">[none]</span>';
                        }

                        ?>
                        <tr>
                            <td><?= $k ?></td>
                            <td><?= $func ?></td>
                            <td class="text-center"><?= $args ?></td>
                            <td><?= $loc ? $loc : '<span class="label label-default">???</label>' ?></td>
                            <td><?= ($line == 0 || trim($line)) ? $line :
                                    '<span class="label label-default">???</span>' ?></td>
                        </tr>

                        <?php
                    }
                ?>
                </tbody>
            </table>
            <?php
        }
794594
public function renderTrace($debug_backtrace)
    {
        $renderTrace = '';
        $renderTrace .= '<span class="fs-label">';
        foreach ($debug_backtrace as $index => $trace) {
            $renderTrace .= '#' . $index . ' ';
            if (!empty($trace['file'])) {
                $renderTrace .= $trace['file'];
            }
            if (!empty($trace['line'])) {
                $renderTrace .= '(' . $trace['line'] . ') ';
            }
            if (!empty($trace['class'])) {
                $renderTrace .= $trace['class'] . '::';
            }
            $renderTrace .= $trace['function'] . '()'
                . '<br>';
        }
        $renderTrace .= '</span>';
        return $renderTrace;
    }
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);
    }
476044
protected function renderBacktrace($backtrace)
    {
        $output = '';
        if ($this->backtraceRenderer !== null) {
            $output = $this->backtraceRenderer->__invoke($backtrace);
        }

        return $output;
    }
265930
public function getTrace($trace = array())
    {
        $traceMessage = '';
        foreach ($trace as $t) {
            $traceMessage .= sprintf('  at %s line %s', $t['file'], $t['line']) . "\n";
        }

        return $traceMessage;
    }