Debug formatté

@example pre("Title: ", $tbArray, object, ...)

@param mixed

@return string
545543
public static function pre()
    {
        $nbArgs = func_num_args();
        
        $content = '';
        for ($i = 0; $i < $nbArgs; $i++) {
            $mixed = func_get_arg($i);
            
            $content .= print_r($mixed, 1);
        }
        
        if (php_sapi_name() == 'cli') {
            $output = $content;
        }
        else {
            $output = '<pre class="debug">' . $content . '</pre>';
        }
        
        return $output;
    }
806073
public function formatTemplateData($viewData = [])
    {
        $log = '';
        reset($viewData);
        foreach ($viewData as $viewName => $viewDataObject) {
            // show debbuging information
            $log .= "TemplateData[$viewName] : <br />\n";
            $log .= print_r($viewDataObject, 1);
        }

        return $log;
    }
243256
public function output($type = 'array')
    {
        $debug = Arrays\RemoveElement::first($this->debug, 2);
        $debug = array_merge([(array) $this->current()], $debug);

        if( is_numeric($type) )
        {
            return (object) ( $debug[$type] ?? $this->_default() );
        }
        elseif( $type === 'array' )
        {
            return $debug;
        }
        elseif( $type === 'string' )
        {
            return output($debug, [], true);
        }
        else
        {
            return $this->_default();
        }
    }
217016
public function getDebugMessage()
    {
        $message = '<font color="red">DEBUG START</font><br>';
        foreach ($this->debugMessage as $items) {
            if (is_array($items) || is_object($items)) {
                $message .= "<pre>";
                $message .= print_r($items, true) . '<br/>';
                $message .= "</pre>";
            } elseif (!is_array($items) && !is_object($items)) {
                if (strpos($items, 'form action=') !== false) {
                    $message .= highlight_string($items, true) . '<br/>';
                } else {
                    $message .= $items . '<br/>';
                }
            }
        }

        if ($this->commMethod == 'liveupdate') {
            $message .= "-----------------------------------------------------------------------------------<br>";
            $message .= 'HASH FIELDS ' . print_r($this->hashFields, true);

            $message .= "-----------------------------------------------------------------------------------<br>";
            $message .= 'HASH DATA ' . print_r($this->hashData, true);

            $message .= "-----------------------------------------------------------------------------------<br>";
            $message .= highlight_string(@$this->luForm, true) . '<br/>';

            $message .= "-----------------------------------------------------------------------------------<br>";
            $message .= 'HASH CHECK ' . "<a href='http://hash.online-convert.com/md5-generator'>ONLINE HASH CONVERTER</a><br>";
        }
        $message .= "-----------------------------------------------------------------------------------<br>";
        $message .= '<font color="red">DEBUG END</font><br>';
        iconv(mb_detect_encoding($message, mb_detect_order(), true), "UTF-8", $message);
        return $message;
    }
1229376
function _createFormat() {
    $objectname                   = null;
    switch( $this->format ) {
      case 'xcal':
        $objectname               = ( isset( $this->timezonetype )) ?
                                 strtolower( $this->timezonetype )  :  strtolower( $this->objName );
        $this->componentStart1    = $this->elementStart1 = '<';
        $this->componentStart2    = $this->elementStart2 = '>';
        $this->componentEnd1      = $this->elementEnd1   = '</';
        $this->componentEnd2      = $this->elementEnd2   = '>'.$this->nl;
        $this->intAttrDelimiter   = '<!-- -->';
        $this->attributeDelimiter = $this->nl;
        $this->valueInit          = null;
        break;
      default:
        $objectname               = ( isset( $this->timezonetype )) ?
                                 strtoupper( $this->timezonetype )  :  strtoupper( $this->objName );
        $this->componentStart1    = 'BEGIN:';
        $this->componentStart2    = null;
        $this->componentEnd1      = 'END:';
        $this->componentEnd2      = $this->nl;
        $this->elementStart1      = null;
        $this->elementStart2      = null;
        $this->elementEnd1        = null;
        $this->elementEnd2        = $this->nl;
        $this->intAttrDelimiter   = '<!-- -->';
        $this->attributeDelimiter = ';';
        $this->valueInit          = ':';
        break;
    }
    return $objectname;
  }
288343
public static function arrayPrettyPrint($array, $raw = false){
        if (!$array) {
            return '';
        }
        $parentOptions = ['tag' => 'dl', 'class' => 'dl-horizontal'];
        $labelOptions = ['tag' => 'dt'];
        $valueOptions = ['tag' => 'dd'];
        $content = [];
        foreach ($array as $key => $value) {
            $value = is_array($value) ? "&nbsp" . static::arrayPrettyPrint($value) : $value;
            $content[] = Html::tag($labelOptions['tag'], $key, $labelOptions);
            $content[] = Html::tag($valueOptions['tag'], $value, $valueOptions);
        }
        return Html::tag($parentOptions['tag'], implode('', $content), $parentOptions);
    }
512546
public function getDebugQuery($r = null)
    {
        if ($r === null) {
            $r = $this->_render();
        }

        $d = $r;
        $pp = array();
        $d = preg_replace('/`([^`]*)`/', '`<font color="black">\1</font>`', $d);
        foreach (array_reverse($this->params) as $key => $val) {
            if (is_string($val)) {
                $d = preg_replace('/'.$key.'([^_]|$)/', '"<font color="green">'.
                    htmlspecialchars(addslashes($val)).'</font>"\1', $d);
            } elseif (is_null($val)) {
                $d = preg_replace(
                    '/'.$key.'([^_]|$)/',
                    '<font color="black">NULL</font>\1',
                    $d
                );
            } elseif (is_numeric($val)) {
                $d = preg_replace(
                    '/'.$key.'([^_]|$)/',
                    '<font color="red">'.$val.'</font>\1',
                    $d
                );
            } else {
                $d = preg_replace('/'.$key.'([^_]|$)/', $val.'\1', $d);
            }

            $pp[] = $key;
        }

        return $d." <font color='gray'>[".
            implode(', ', $pp).']</font>';
    }
444334
public function debugf()
    {
        $args = func_get_args();
        $format = array_shift($args);
        $this->debug(vsprintf($format, $args));
    }
493487
public function textToCode(array $details)
    {
        $formatted = array();

        if (isset($details['foreground'])) {
            $formatted['foreground'] = $this->color->getForeground($details['foreground']);
        }

        if (isset($details['background'])) {
            $formatted['background'] = $this->color->getBackground($details['background']);
        }

        return $formatted;
    }
738681
private function tableBody(array $dependencyArray)
    {
        $output = '<tbody>';
        $numIndex = 1;
        foreach ($dependencyArray as $dependencyRow => $dependencies) {
            $output .= "<tr><th>$numIndex: $dependencyRow</th>";
            foreach ($dependencies as $dependencyHeader => $count) {
                if ($dependencyRow === $dependencyHeader) {
                    $output .= '<td>X</td>';
                } else {
                    $output .= '<td>' . $count . '</td>';
                }
            }
            $output .= '</tr>';
            $numIndex += 1;
        }
        $output .= '</tbody>';
        return $output;
    }
812028
public function ___debugInfo()
    {
        return array(
            'name'  => isset($this->propertyNode) ? $this->propertyNode->name->toString() : 'unknown',
            'class' => $this->className
        );
    }
719374
function output($debug=0){

    if ($debug){
        // turn compression off
        $this->options['compression']=0;
    }

    if ($this->arc4_objnum){
        $this->ARC4_init($this->encryptionKey);
    }

    $this->checkAllHere();

    $xref=array();
    $content="%PDF-1.3\n%����\n";
//  $content="%PDF-1.3\n";
    $pos=strlen($content);
    foreach($this->objects as $k=>$v){
        $tmp='o_'.$v['t'];
        $cont=$this->$tmp($k,'out');
        $content.=$cont;
        $xref[]=$pos;
        $pos+=strlen($cont);
    }
    $content.="\nxref\n0 ".(count($xref)+1)."\n0000000000 65535 f \n";
    foreach($xref as $p){
        ++$p;
        $content.=substr('0000000000',0,10-strlen($p)).$p." 00000 n \n";
    }
    $content.="\ntrailer\n  << /Size ".(count($xref)+1)."\n     /Root 1 0 R\n     /Info ".$this->infoObject." 0 R\n";
    // if encryption has been applied to this document then add the marker for this dictionary
    if ($this->arc4_objnum > 0){
        $content .= "/Encrypt ".$this->arc4_objnum." 0 R\n";
    }
    if (strlen($this->fileIdentifier)){
        $content .= "/ID[<".$this->fileIdentifier."><".$this->fileIdentifier.">]\n";
    }
    $content .= "  >>\nstartxref\n".($pos+1)."\n%%EOF\n";

    return $content;
    }
36413
function dumpDebugArray($debug_log) {
        if ( ! is_array($debug_log) ) return;

        foreach ( $debug_log as $k => $v ) {
            if ( count($v) > 1 ) {
                $this->togglePre($v[0], $v[1]);
            } else if ( is_array($v) ) {
                line_out($v[0]);
            } else if ( is_string($v) ) {
                line_out($v);
            }
        }
    }
875011
public function getFormatters(): ArrayObject
    {
        $arr = new ArrayObject();
        foreach ($this->columns as $key => $column) {
            if (($formatter = $column->getFormatter()) !== null) {
                $arr->offsetSet($key, $formatter);
            }
        }

        return $arr;
    }
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;
    }
194496
public function get_debug_vars($obj)
    {
        $config_vars = array();
        foreach ($obj->config_vars as $key => $var) {
            $config_vars[$key]['value'] = $var;
            if ($obj->_objType == 2) {
                $config_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
            } elseif ($obj->_objType == 4) {
                $tpl_vars[$key]['scope'] = $obj->dataObjectName;
            } else {
                $config_vars[$key]['scope'] = 'Smarty object';
            }
        }
        $tpl_vars = array();
        foreach ($obj->tpl_vars as $key => $var) {
            foreach ($var as $varkey => $varvalue) {
                if ($varkey == 'value') {
                    $tpl_vars[$key][$varkey] = $varvalue;
                } else {
                    if ($varkey == 'nocache') {
                        if ($varvalue == true) {
                            $tpl_vars[$key][$varkey] = $varvalue;
                        }
                    } else {
                        if ($varkey != 'scope' || $varvalue !== 0) {
                            $tpl_vars[$key]['attributes'][$varkey] = $varvalue;
                        }
                    }
                }
            }
            if ($obj->_objType == 2) {
                $tpl_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
            } elseif ($obj->_objType == 4) {
                $tpl_vars[$key]['scope'] = $obj->dataObjectName;
            } else {
                $tpl_vars[$key]['scope'] = 'Smarty object';
            }
        }

        if (isset($obj->parent)) {
            $parent = $this->get_debug_vars($obj->parent);
            foreach ($parent->tpl_vars as $name => $pvar) {
                if (isset($tpl_vars[$name]) && $tpl_vars[$name]['value'] === $pvar['value']) {
                    $tpl_vars[$name]['scope'] = $pvar['scope'];
                }
            }
            $tpl_vars = array_merge($parent->tpl_vars, $tpl_vars);

            foreach ($parent->config_vars as $name => $pvar) {
                if (isset($config_vars[$name]) && $config_vars[$name]['value'] === $pvar['value']) {
                    $config_vars[$name]['scope'] = $pvar['scope'];
                }
            }
            $config_vars = array_merge($parent->config_vars, $config_vars);
        } else {
            foreach (Smarty::$global_tpl_vars as $key => $var) {
                if (!array_key_exists($key, $tpl_vars)) {
                    foreach ($var as $varkey => $varvalue) {
                        if ($varkey == 'value') {
                            $tpl_vars[$key][$varkey] = $varvalue;
                        } else {
                            if ($varkey == 'nocache') {
                                if ($varvalue == true) {
                                    $tpl_vars[$key][$varkey] = $varvalue;
                                }
                            } else {
                                if ($varkey != 'scope' || $varvalue !== 0) {
                                    $tpl_vars[$key]['attributes'][$varkey] = $varvalue;
                                }
                            }
                        }
                    }
                    $tpl_vars[$key]['scope'] = 'Global';
                }
            }
        }

        return (object) array('tpl_vars' => $tpl_vars, 'config_vars' => $config_vars);
    }
428477
public static function debugBacktraceString($trace = null) {
		$result = [];
		if (!\Debug::$debug) return $result;
		$i = 1;
		// if trace is not provided
		if (empty($trace)) {
			$trace = debug_backtrace();
			unset($trace[0]);
		}
		foreach($trace as $v) {
			$stack = '#' . $i . ' ' . (isset($v['file']) ? $v['file'] : 'Unknown');
			if (isset($v['line'])) {
				$stack.= '(' . $v['line'] . ')';
			}
			// do not show error handler
			if (!(isset($v['class']) && $v['class'] == 'error' && $v['function'] == 'error_handler')) {
				$stack.= ': ';
				if(isset($v['class'])) {
					$stack.= $v['class'] . $v['type'];
				}
				$params = [];
				if (isset($v['args'])) {
					foreach ($v['args'] as $v2) {
						if (gettype($v2) == 'string') {
							$params[] = str_replace(["\n", "\r", "\t"], ' ', $v2);
						} else if (is_array($v2)) {
							$temp = var_export_condensed($v2, ['skip_objects' => true]);
							$params[] = substr($temp, 0, 100) . '...';
						} else {
							$params[] = var_export_condensed($v2, ['skip_objects' => true]);
						}
					}
				}
				$stack.= $v['function'] . '(' . implode(', ', $params) . ');';
			}
			$i++;
			$result[] = $stack;
		}
		return $result;
	}