Renders a dump of the given variable

@param mixed $variable
@param integer $level
@param boolean $plaintext
@param boolean $ansiColors
@return string
490199
public static function renderDump($variable, int $level, bool $plaintext = false, bool $ansiColors = false): string
    {
        if ($level > self::getRecursionLimit()) {
            return 'RECURSION ... ' . chr(10);
        }
        if (is_string($variable)) {
            $croppedValue = (strlen($variable) > 2000) ? substr($variable, 0, 2000) . '…' : $variable;
            if ($plaintext) {
                $dump = 'string ' . self::ansiEscapeWrap('"' . $croppedValue . '"', '33', $ansiColors) . ' (' . strlen($variable) . ')';
            } else {
                $dump = sprintf('\'<span class="debug-string">%s</span>\' (%s)', htmlspecialchars($croppedValue), strlen($variable));
            }
        } elseif (is_numeric($variable)) {
            $dump = sprintf('%s %s', gettype($variable), self::ansiEscapeWrap($variable, '35', $ansiColors));
        } elseif (is_array($variable)) {
            $dump = self::renderArrayDump($variable, $level + 1, $plaintext, $ansiColors);
        } elseif (is_object($variable)) {
            $dump = self::renderObjectDump($variable, $level + 1, true, $plaintext, $ansiColors);
        } elseif (is_bool($variable)) {
            $dump = $variable ? self::ansiEscapeWrap('true', '32', $ansiColors) : self::ansiEscapeWrap('false', '31', $ansiColors);
        } elseif (is_null($variable) || is_resource($variable)) {
            $dump = gettype($variable);
        } else {
            $dump = '[unhandled type]';
        }

        return $dump;
    }
465207
public function render($input, array $vars = [], $filename = null)
    {
        if ($this->stringCanBeLoadedAsFile($input)) {
            return $this->renderFile($input, $vars);
        }

        return $this->renderString($input, $vars, $filename);
    }
53955
public function dump($tpl, array $vars = array())
    {
        $vars['__user__'] = Security::getInstance()->getUser();
        $vars['__admin__'] = Security::getInstance()->getAdmin();
        $vars['__profiles__'] = Security::getCleanProfiles();
        $vars['__flash__'] = Security::getInstance()->getFlashes();
        $vars['__get__'] = Request::getInstance()->getQueryParams();
        $vars['__post__'] = Request::getInstance()->getData();
        $dump = '';
        try {
            $dump = $this->tpl->render($tpl, $vars);
        } catch (\Exception $e) {
            Logger::log($e->getMessage(), LOG_ERR);
        }
        return $dump;
    }
882118
public static function dump( $var, $format = 'html', $back = 0, $options = NULL, $return = FALSE, $max_depth = 6 )
    {
        list( $file, $line ) = self::caller( $back );

        if ( !$options ){
            $options = array();
        }
        $default_options = array(
                'title' => 'system dump',
                'font_size' => 11,
                'max_string_length' => self::DUMP_MAX_LENGTH,
                'type' => 'textarea',
            );
        $options = array_merge( $default_options, $options );

        $title             = $options['title'];
        $font_size         = $options['font_size'];
        $max_string_length = $options['max_string_length'];
        $type              = $options['type'];

        $lines = array();
        $recursion = array();
        self::_dump( '-', $var, 0, $max_string_length, $lines, $max_depth, $recursion );

        switch( $format )
        {
        case "html":
            switch( $type ){
            case 'div':
                $output  = "<div style=\"font-size:12px; margin: 2px\"> $title:" . implode('',$lines) . " @$file($line)</div>";
                break;
            case 'textarea':
            default:
                $output  = "<h3 style=\"font-size:12px; margin: 0; color:black; background-color:white; text-align: left\"> $title @$file($line)</h3>";
                $output .= "<textarea rows=14 style=\"width:100%; font-size:{$font_size}px; margin: 0; color:black; background-color:white; border: 1px solid silver;\">";
                $output .= implode(PHP_EOL,$lines);
                $output .= "</textarea>";
                break;
            }
            break;
        case "shell":
        default:
            $output  = "$title @$file($line)" . PHP_EOL;
            $output .= implode(PHP_EOL,$lines) . PHP_EOL;
            break;
        }

        if ( $return ){
            return $output;
        }
        else{
            echo $output;
            return null;
        }
    }
116849
function dump_dom_levels($node, $level = 0) 
    {
        $class = get_class($node);
        if ($class == "DOMNodeList") {
            echo "Level $level ($class): $node->length items\n";
                foreach ($node as $child_node) {
                echo $level.':'.$child_node->getNodePath() . "\n";
                dump_dom_levels($child_node, $level+1);
            }
        } else {
            $nChildren = 0;
            foreach ($node->childNodes as $child_node) {
                if ($child_node->hasChildNodes()) {
                    $nChildren++;
                }
            }
            if ($nChildren) {
                echo "Level $level ($class): $nChildren children\n";
            }
            foreach ($node->childNodes as $child_node) {
                echo $level.':'.$child_node->getNodePath() . "\n";
                if ($child_node->hasChildNodes()) {
                    dump_dom_levels($child_node, $level+1);
                }
            }
        }
    }
1001852
public function renderTemplateString(string $template, array $variables = []): string
    {
        $output = $this->indexControlStructure($template, 'foreach');
        $output = $this->indexControlStructure($output, 'if', ['else']);

        $output = $this->resolveLoops($output, $variables);
        $output = $this->resolveConditionals($output, $variables);

        return $this->replaceVariablesInTemplate($output, $variables);
    }
407629
public function factory($var, $level = 1)
    {
        $result = null;

        if (null === $var) {
            $result = clone($this->types['type_null']);
        } elseif (is_bool($var)) {
            $result = clone($this->types['type_bool']);
        } elseif (is_string($var)) {
            $result = clone($this->types['type_string']);
        } elseif (is_int($var)) {
            $result = clone($this->types['type_int']);
        } elseif (is_float($var)) {
            $result = clone($this->types['type_float']);
        } elseif (is_array($var)) {
            $result = clone($this->types['type_array']);
        } elseif (is_object($var)) {
            $result = clone($this->types['type_object']);
        } elseif ($this->isResource($var)) {
            $result = clone($this->types['type_resource']);
        }

        /** @var TypeInterface $result */
        $result->load($var, $level);

        return $result;
    }
527409
protected function evalVarDump($variable)
    {
        $dumper = new HtmlDumper;
        $cloner = new VarCloner;

        $output = '<div style="display:none">';
        $output .= $dumper->dump($cloner->cloneVar($variable), true);
        $output .= '</div>';

        return $output;
    }
1140336
public function _print($plain = false, $default_media='') {
		if ($this->output_css && $this->output_css_plain) {
			return;
		}

		$output = '';
		if (!$this->parser->get_cfg('preserve_css')) {
			$this->_convert_raw_css($default_media);
		}

		$template = & $this->template;

		if ($plain) {
			$template = array_map('strip_tags', $template);
		}

		if ($this->parser->get_cfg('timestamp')) {
			array_unshift($this->tokens, array(COMMENT, ' CSSTidy ' . $this->parser->version . ': ' . date('r') . ' '));
		}

		if (!empty($this->charset)) {
			$output .= $template[0] . '@charset ' . $template[5] . $this->charset . $template[6] . $template[13];
		}

		if (!empty($this->import)) {
			for ($i = 0, $size = count($this->import); $i < $size; $i++) {
				if (substr($this->import[$i], 0, 4) === 'url(' && substr($this->import[$i], -1, 1) === ')') {
					$this->import[$i] = '"' . substr($this->import[$i], 4, -1) . '"';
					$this->parser->log('Optimised @import : Removed "url("', 'Information');
				}
				else if (!preg_match('/^".+"$/',$this->import[$i])) {
					// fixes a bug for @import ".." instead of the expected @import url("..")
					// If it comes in due to @import ".." the "" will be missing and the output will become @import .. (which is an error)
					$this->import[$i] = '"' . $this->import[$i] . '"';
				}

				$output .= $template[0] . '@import ' . $template[5] . $this->import[$i] . $template[6] . $template[13];
			}
		}

		if (!empty($this->namespace)) {
			if (($p=strpos($this->namespace,"url("))!==false && substr($this->namespace, -1, 1) === ')') {
				$this->namespace = substr_replace($this->namespace,'"',$p,4);
				$this->namespace = substr($this->namespace, 0, -1) . '"';
				$this->parser->log('Optimised @namespace : Removed "url("', 'Information');
			}
			$output .= $template[0] . '@namespace ' . $template[5] . $this->namespace . $template[6] . $template[13];
		}

		$in_at_out = '';
		$out = & $output;

		foreach ($this->tokens as $key => $token) {
			switch ($token[0]) {
				case AT_START:
					$out .= $template[0] . $this->_htmlsp($token[1], $plain) . $template[1];
					$out = & $in_at_out;
					break;

				case SEL_START:
					if ($this->parser->get_cfg('lowercase_s'))
						$token[1] = strtolower($token[1]);
					$out .= ( $token[1]{0} !== '@') ? $template[2] . $this->_htmlsp($token[1], $plain) : $template[0] . $this->_htmlsp($token[1], $plain);
					$out .= $template[3];
					break;

				case PROPERTY:
					if ($this->parser->get_cfg('case_properties') === 2) {
						$token[1] = strtoupper($token[1]);
					} elseif ($this->parser->get_cfg('case_properties') === 1) {
						$token[1] = strtolower($token[1]);
					}
					$out .= $template[4] . $this->_htmlsp($token[1], $plain) . ':' . $template[5];
					break;

				case VALUE:
					$out .= $this->_htmlsp($token[1], $plain);
					if ($this->_seeknocomment($key, 1) == SEL_END && $this->parser->get_cfg('remove_last_;')) {
						$out .= str_replace(';', '', $template[6]);
					} else {
						$out .= $template[6];
					}
					break;

				case SEL_END:
					$out .= $template[7];
					if ($this->_seeknocomment($key, 1) != AT_END)
						$out .= $template[8];
					break;

				case AT_END:
					$out = & $output;
					$in_at_out = str_replace("\n\n", "\r\n", $in_at_out); // don't fill empty lines
					$in_at_out = str_replace("\n", "\n" . $template[10], $in_at_out);
					$in_at_out = str_replace("\r\n", "\n\n", $in_at_out);
					$out .= $template[10] . $in_at_out . $template[9];
					$in_at_out = '';
					break;

				case IMPORTANT_COMMENT:
				case COMMENT:
					$out .= $template[11] . '/*' . $this->_htmlsp($token[1], $plain) . '*/' . $template[12];
					break;
			}
		}

		$output = trim($output);

		if (!$plain) {
			$this->output_css = $output;
			$this->_print(true);
		} else {
			// If using spaces in the template, don't want these to appear in the plain output
			$this->output_css_plain = str_replace('&#160;', '', $output);
		}
	}
582041
public function render($tpl, array $vars = array(), array $cookies = array())
    {
        Logger::log('Start render response');
        $vars = ResponseHelper::setDebugHeaders($vars);
        $output = $this->dump($tpl, $vars);

        return $this->output($output, 'text/html', $cookies);
    }
646856
static function output($var)
	{
		if(!is_array($var)) self::warn('Error Debug!','Not is a array!');
		$attr['border'] = 1;
		$attr['style'] = 'font-size:14px';

		$table = new HTML_table($var, $attr);
		echo $table->html();
	}
1145022
public function dump($variables = null, $caption = null)
    {
        $this->commentMap = [];
        $this->zebra = 1;
        $info = [];

        if (!is_array($variables)) {
            if ($variables instanceof Paginator) {
                $variables = $this->paginatorToArray($variables);
            }
            elseif (is_object($variables)) {
                $variables = $this->objectToArray($variables);
            }
            else {
                $variables = [$variables];
            }
        }

        $output = [];
        $output[] = '<table>';

        if ($caption) {
            $output[] = $this->makeTableHeader($caption);
        }

        foreach ($variables as $key => $item) {
            $output[] = $this->makeTableRow($key, $item);
        }
        $output[] = '</table>';

        $html = implode(PHP_EOL, $output);

        return '<pre style="' . $this->getContainerCss() . '">' . $html . '</pre>';
    }
746108
private static function toJson(&$var, array $options, int $level = 0)
    {
        if (\is_bool($var) || null === $var || \is_int($var)) {
            return $var;

        }

        if (\is_float($var)) {
            return \is_finite($var)
                ? (\strpos($tmp = \json_encode($var), '.') ? $var : ['number' => "$tmp.0"])
                : ['type' => (string) $var];

        }

        if (\is_string($var)) {
            return self::encodeString($var, $options[self::TRUNCATE]);
        }

        if (\is_array($var)) {
            static $marker;
            if ($marker === null) {
                $marker = \uniqid("\x00", true);
            }
            if (isset($var[$marker]) || $level >= $options[self::DEPTH]) {
                return [null];
            }
            $res = [];
            $var[$marker] = true;
            foreach ($var as $k => & $v) {
                if ($k !== $marker) {
                    $hide = \is_string($k) && isset($options[self::KEYS_TO_HIDE][\strtolower($k)]);
                    $k = \is_int($k) || \preg_match('#^\w{1,50}\z#', $k) ? $k : '"' . self::encodeString($k,
                            $options[self::TRUNCATE]) . '"';
                    $res[] = [$k, $hide ? self::HIDDEN_VALUE : self::toJson($v, $options, $level + 1)];
                }
            }
            unset($var[$marker]);

            return $res;
        }

        if (\is_object($var)) {
            $obj = &self::$liveStorage[\spl_object_hash($var)];
            if ($obj && $obj['level'] <= $level) {
                return ['object' => $obj['id']];
            }

            $editorInfo = null;
            if ($options[self::LOCATION] & self::LOCATION_CLASS) {
                $rc = $var instanceof \Closure ? new \ReflectionFunction($var) : new \ReflectionClass($var);
                $editor = $rc->getFileName() ? Helpers::editorUri($rc->getFileName(), $rc->getStartLine()) : null;
                $editorInfo = $editor ? [
                    'file' => $rc->getFileName(), 'line' => $rc->getStartLine(), 'url' => $editor,
                ] : null;
            }
            static $counter = 1;
            $obj = $obj ?: [
                'id' => self::$livePrefix . '0' . $counter++, // differentiate from resources
                'name' => Helpers::getClass($var),
                'editor' => $editorInfo,
                'level' => $level,
                'object' => $var,
            ];

            if ($level < $options[self::DEPTH] || !$options[self::DEPTH]) {
                $obj['level'] = $level;
                $obj['items'] = [];

                foreach (self::exportObject($var, $options[self::OBJECT_EXPORTERS],
                    $options[self::DEBUGINFO]) as $k => $v) {
                    $vis = 0;
                    if (isset($k[0]) && $k[0] === "\x00") {
                        $vis = $k[1] === '*' ? 1 : 2;
                        $k = \substr($k, \strrpos($k, "\x00") + 1);
                    }
                    $hide = \is_string($k) && isset($options[self::KEYS_TO_HIDE][\strtolower($k)]);
                    $k = \is_int($k) || \preg_match('#^\w{1,50}\z#', $k) ? $k : '"' . self::encodeString($k,
                            $options[self::TRUNCATE]) . '"';
                    $obj['items'][] = [$k, $hide ? self::HIDDEN_VALUE : self::toJson($v, $options, $level + 1), $vis];
                }
            }

            return ['object' => $obj['id']];
        }

        if (\is_resource($var)) {
            $obj = &self::$liveStorage[(string) $var];
            if (!$obj) {
                $type = \get_resource_type($var);
                $obj = ['id' => self::$livePrefix . (int) $var, 'name' => $type . ' resource'];
                if (isset(self::$resources[$type])) {
                    foreach ((self::$resources[$type])($var) as $k => $v) {
                        $obj['items'][] = [$k, self::toJson($v, $options, $level + 1)];
                    }
                }
            }

            return ['resource' => $obj['id']];
        }

        return ['type' => 'unknown type'];
    }
342244
public function markVariable($variable, $type)
    {
        if (isset($this->variables[$variable])) {
            $currentType = $this->variables[$variable];
            if ('undefined' == $currentType) {
                return;
            }
        } else {
            $this->variables[$variable] = $type;

            return;
        }

        switch ($currentType) {
            case 'numeric':
                switch ($type) {
                    case 'int':
                    case 'uint':
                    case 'long':
                    case 'ulong':
                    case 'double':
                        break;
                    default:
                        $this->variables[$variable] = 'undefined';
                        break;
                }
                break;

            case 'bool':
                switch ($type) {
                    case 'bool':
                    case 'numeric':
                        break;
                    default:
                        $this->variables[$variable] = 'undefined';
                        break;
                }
                break;

            case 'double':
                switch ($type) {
                    case 'double':
                    case 'numeric':
                        break;
                    default:
                        $this->variables[$variable] = 'undefined';
                        break;
                }
                break;

            case 'string':
                switch ($type) {
                    case 'string':
                        break;
                    default:
                        $this->variables[$variable] = 'undefined';
                        break;
                }
                break;

            case 'int':
            case 'uint':
            case 'long':
            case 'ulong':
            case 'char':
            case 'uchar':
                switch ($type) {
                    case 'int':
                    case 'uint':
                    case 'long':
                    case 'ulong':
                    case 'char':
                    case 'uchar':
                    case 'numeric':
                        break;
                    default:
                        $this->variables[$variable] = 'undefined';
                        break;
                }
                break;

            case 'null':
                if ('null' != $type) {
                    $this->variables[$variable] = 'undefined';
                }
                break;

            case 'variable':
                $this->variables[$variable] = 'undefined';
                break;

            case 'array':
                $this->variables[$variable] = 'undefined';
                break;

            default:
                // TODO: Find the reason
                echo 'StaticTypeInference=', $currentType, ' ', $type, PHP_EOL;
                break;
        }
    }
960139
public static function print_r($var, $varname = '...', $params = array())
    {
        if (!self::isDebug()) {
            return false;
        }

        $output = print_r($var, true);

        $_this = self::i();
        $_this->_dumpRenderHtml($output, $varname, $params);

        return $_this;
    }
113293
public static function dump( $var, $echo = true, $label = null, $flags = ENT_SUBSTITUTE )
	{
		$response = Response::getInstance()->getResponse();
		$response->write( '<pre>' );
		$response->write( var_export( $var, true ) );
		$response->write( '</pre>' );
	}
561058
public function output($variable): InspectorInterface
    {
        if ($variable === true) {
            $variable = '*TRUE*';
        } else if ($variable === false) {
            $variable = '*FALSE*';
        } else if (is_null($variable)) {
            $variable = '*null*';
        }

        echo '<pre>'.print_r($variable, true).'</pre>';
        return $this;
    }