Prints the debug trace in the printable format

@param null|array $trace

@return string
358798
private function _trace($trace = null)
    {
        $trace = $trace ?: debug_backtrace();
        foreach( $trace as $er) {
            $func = isset($er['function'])? $er['function']: '';
            $file = isset($er['file']) ? $er['file'] : '';

            # last two sections of the path
            if ($file) {
                $file  = $this->limitPath($file);
                $line  = isset($er['line'])? $er['line']: '';
                $class = isset($er['class'])? $er['class']: '';
                if ($class == 'IrfanTOOR\Debug' && $func=='_trace')
                    continue;

                $ftag = ($class != '') ? $class . '=>' . $func . '()' : $func . '()';
                $txt = '-- file: ' . $file . ', line: ' . $line . ', ' . $ftag;
                if ($this->terminal)
                    $this->console->writeln( $txt, 'dark');
                else
                    echo '<code style="color:#999">' . $txt . '</code><br>';
            }
        }
    }
1011890
public static function showTrace(array $options = [])
    {
        $options = array_merge([
            'trace_offset' => 0,
            'reverse'      => false,
        ], $options);

        $backtrace = ($options['reverse'] ? array_reverse(debug_backtrace()) : debug_backtrace());

        $output     = '';
        $traceIndex = ($options['reverse'] ? 1 : count($backtrace));
        foreach ($backtrace as $trace) {
            $output .= $traceIndex . ': ';
            $output .= self::getCalledFromTrace($trace);
            $output .= "\n";

            $traceIndex += ($options['reverse'] ? 1 : -1);
        }

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

        return $output;
    }
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;
    }
253977
private static function getFunctionNameForReport(array $trace = null)
    {
        if (null === $trace) {
            return '<unknown function>';
        }
        if (empty($trace[0]['function'])) {
            return '<none>';
        }
        $functionName = [$trace[0]['function']];
        if (isset($trace[0]['type'])) {
            $functionName[] = $trace[0]['type'];
        }
        if (isset($trace[0]['class'])) {
            $functionName[] = $trace[0]['class'];
        }
        return implode('', array_reverse($functionName));
    }
992435
public function humaniceTrace(array $trace) {
        /* @var $html_helper HtmlHelper */
        $html_helper = $this->html;
        $list = [];
        foreach ($trace as $id_trace => $e) {
            $class = explode('\\', key_exists('class', $e) ? $e['class'] : '');
            $type = key_exists('type', $e) ? $e['type'] : '';
            $function = key_exists('function', $e) ? $e['function'] : '';
            $args = key_exists('args', $e) ? $e['args'] : [];
            $file = key_exists('file', $e) ? $e['file'] : [];
            $line = key_exists('line', $e) ? $e['line'] : [];

            $item = $class ? '<span style="color:blue" title="' . implode('\\', $class) . '">' . end($class) . '</span>' : '';
            $item .= $type ? '<span style="color:teal">' . $type . '</span>' : '';
            $item .= $function ? '<span style="color:red">' . $function . '</span>' : '';
            $item .= $args ? 
                    '(' .
                        $html_helper->link(count($args) . ' arg', [], 
                            ['onclick' => 'var a=document.getElementById(\'args_' . $id_trace . '\');'
                                . ' if (a.style.display==\'block\') { a.style.display=\'none\' } else { a.style.display=\'block\' };'
                                . 'return false;']) . 
                    ')' : '()';
            $item .= $file ? ' - <span style="color:lightgray" onmouseover="this.style.color=\'gray\'" '
                    . 'onmouseout="this.style.color=\'lightgray\'" >' . $file . '</span>' : '';
            $item .= $line ? ' <span style="color:salmon">' . $line . '</span>' : '';
            $item .= $args ? '<div style="display:none" id="args_' . $id_trace . '">' . @d($args) . '</div>' : '';
            
            $list[] = $item;
        }
        
        return $html_helper->nestedList($list, [
                'style' => 'font-family: arial; line-height:30px;',
                'reversed' => 'reversed'
            ], [], 'ordered');
    }
6717
public function logDebug()
  {
    if ($this->getVerbosity()>=OutputInterface::VERBOSITY_DEBUG)
    {
      $args   = func_get_args();
      $format = array_shift($args);

      $this->writeln(vsprintf('<info>'.$format.'</info>', $args));
    }
  }
25417
private function format_trace_flags()
  {
    $flags = array();
    if (!$this->already_invoked)
    {
      $flags[] = 'first_time';
    }
    if (!$this->is_needed())
    {
      $flags[] = 'not_needed';
    }

    return (count($flags)) ? '('.join(', ', $flags).')' : '';
  }
82509
public static function getCLIBacktrace($backtrace=null) {
		if(!$backtrace)
			$backtrace = debug_backtrace();

		$r = '';
		$c = count($backtrace);
		for($i=0; $i<$c; $i++) {
			$trace = $backtrace[$i];

			if(isset($trace['file']))
				$r .= $trace['file'].':'.$trace['line']."\n";
		}

		return $r;
	}
1016148
public function debug() {
        echo "filePath    = " . $this->filePath . PHP_EOL;
        echo "startMarker = " . $this->startMarker . PHP_EOL;
        echo "endMarker   = " . $this->endMarker . PHP_EOL;
        echo "startIndex  = " . $this->startIndex . PHP_EOL;
        echo "endIndex    = " . $this->endIndex . PHP_EOL;
        echo "numLines    = " . $this->numLines . PHP_EOL;
        echo "Start       = " . print_r($this->beforeLines, true);
        echo "Auto      = " . print_r($this->autoLines, true);
        echo "End         = " . print_r($this->afterLines, true);
        return $this;
    }
1154730
public function debug()
	{
	    $errorToreturn = '';
		if($this->_debug && $this->hasError() ){
			$message = $this->getMessage();
			$trace = $this->getTrace();
			$critical = $this->getCritical();

			for($i= 0, $count = sizeOf($message); $i<$count;$i++ ) {

				if($critical[$i]){
                    echo '<strong style="color:red">';
				} else  {
					continue;
				}

				CheckoutApi_Utility_Utilities::dump($message[$i] .'==> { ');
				
				foreach($trace[$i] as $errorIndex => $errors) {
                    echo   "<pre>";
                    echo    $errorIndex ."=>  "; print_r($errors);

                    echo   "</pre>";
				}
				
				if($critical[$i])	{
                    echo   '</strong>';
				}
				
				CheckoutApi_Utility_Utilities::dump('} ');
				
			}
			
		}
		return $errorToreturn;
	}
814711
public function debugVariableText($val)
    {
        // Check debug
        if (is_object($val) && ClassInfo::hasMethod($val, 'debug')) {
            return $val->debug();
        }

        // Format as array
        if (is_array($val)) {
            $result = '';
            foreach ($val as $key => $valItem) {
                $valText = $this->debugVariableText($valItem);
                $result .= "$key = $valText\n";
            }
            return $result;
        }

        // Format object
        if (is_object($val)) {
            return print_r($val, true);
        }

        // Format bool
        if (is_bool($val)) {
            return '(bool) ' . ($val ? 'true' : 'false');
        }

        // Format text
        if (is_string($val)) {
            return wordwrap($val, self::config()->columns);
        }

        // Other
        return var_export($val, true);
    }
1072844
public function debug($message)
    {
        if ( ! $this->getOutput()->isDebug()) {
            return null;
        }

        if (func_num_args() > 1) {
            $message = vsprintf($message, array_slice(func_get_args(), 1));
        }

        $this->getOutput()->writeln($message);
    }
788457
private function _formatError($trace, Array $data)
    {
        foreach ($trace as $k => $v) {
            if ($k == 0) continue;
            $data['trace'][] = array(
                'file' => isset($v['file']) ? $v['file'] : null,
                'line' => isset($v['line']) ? $v['line'] : null,
                'method' => array(
                    'class' => isset($v['class']) ? $v['class'] : null,
                    'type' => isset($v['type']) ? $v['type'] : null,
                    'function' => isset($v['function']) ? $v['function'] : null,
                    'args' => isset($v['args']) ? $v['args'] : null,
                ),
            );
        }
        return $data;
    }
1078287
public function getStackTrace()
    {
        if (!isset($this->message[4]) || empty($this->message[4])) {
            return null;
        }

        $traces = array_map(function ($trace) {
            return "in {$trace['file']}:{$trace['line']}";
        }, $this->message[4]);
        return implode("\n", $traces);
    }
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;
    }
1182080
public function getTraceAsString()
    {
        $remove = "Stack trace:\n";
        $len = strpos($this->_toString, $remove);
        if ($len === false) {
            return '';
        }
        return substr($this->_toString, $len + strlen($remove));
    }