Using for beautify output
@param $variable
@param string $spacing
@return string
545545
public static function dumperGet(&$variable, $spacing = "") {
        if (is_array($variable)) {
            $type = "Array[" . count( $variable ) . "]";
        } elseif( is_object( $variable ) ) {
            ob_start();
            print_r($variable);
            return ob_get_clean();

        } elseif( gettype( $variable ) == "boolean" ) {
            return $variable ? "true" : "false";
        } elseif( is_null( $variable ) ) {
            return "NULL";
        } else {
            ob_start();
            var_dump($variable);
            return ob_get_clean();
        }
        $buf = $type;
        $spacing .= "    ";
        for (reset( $variable ); list ( $k, $v ) = each( $variable );) {
            if ($k === "GLOBALS" )
                continue;
            $buf .= "\n".$spacing.'['.$k.'] => ' . self::dumperGet( $v, $spacing);
        }

        return $buf;
    }
666722
public function markdown($var = null)
    {
        $content = $this->content();

        if ($var !== null) {
            $content['markdown'] = (string) $var;
            $this->content($content);
        }

        return $content['markdown'];
    }
1064867
public function prettyVarExport($data, $tabs = 1)
    {
        $spacing = str_repeat(' ', 4 * $tabs);

        $string = '';
        $parts = preg_split('/\R/', var_export($data, true));
        foreach ($parts as $k => $part) {
            if ($k > 0) {
                $string .= $spacing;
            }
            $string .= $part.PHP_EOL;
        }

        return trim($string);
    }
353954
public function show(string $variable, array $params = [])
    {
        $path = $this->buildVariablesPath($variable);

        return $this->get($path, $params);
    }
515956
public static function var_dump($var, $varname = '...', $params = array())
    {
        if (!self::isDebug()) {
            return false;
        }

        // var_dump the variable into a buffer and keep the output
        ob_start();
        var_dump($var);
        $output = ob_get_clean();
        $_this  = self::i();

        // neaten the newlines and indents
        $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
        //if (!extension_loaded('xdebug')) {
        $output = $_this->_htmlChars($output);
        //}

        $_this->_dumpRenderHtml($output, $varname . '::html', $params);

        return $_this;
    }
599333
protected function formatTemplate($template, array $vars)
    {
        $output = $template;
        $token = $this->buildToken();

        foreach ($vars as $key => $value) {
            $replacement = sprintf($token, $key);

            if (!$this->isFlagEnabled(self::ALLOW_NEWLINES)) {
                $value = $this->sanitizeNewlines($value);
            }

            if (false !== strpos($output, $replacement)) {
                $output = str_replace($replacement, $value, $output);
            }
        }

        $output = $this->removeExtraTokens($token, $output);

        return $output;
    }
1035619
protected static function __compileVar($val)
    {
        $parts = explode('.', trim($val));
        $deep = count($parts);
        if ('$widget' == $parts[0]) {
            $ret = "\$this->widget";
        } elseif ('$global' == $parts[0]) {
            $ret = "\$this->globals";
        } elseif ('$' == $parts[0]{0}) {
            $ret = "{$parts[0]}";
        } else {
            return $val;
        }
        $i = 1;
        while ($i < $deep) {
            if (false === filter_var($parts[$i], FILTER_VALIDATE_INT)) {
                $ret .= "['{$parts[$i]}']";
            } else {
                $ret .= "[{$parts[$i]}]";
            }
            $i++;
        }

        return $ret;
    }
947956
public function toRows($var)
    {
        $results = PHP_EOL;

        foreach ($this->getParser()->toArray() as $name => $types) {
            if (in_array($name, $this->ignores)) {
                continue;
            }

            $results .= Stub::create('/scaffold/row.stub', [
                'label' => ucwords($name),
                'column' => $name,
                'var' => $var,
            ])->render();
        }

        return $results.PHP_EOL;
    }
147343
protected function encode($var)
    {
        return (string) YamlParser::dump($var, $this->setting('inline', 5), $this->setting('indent', 2), true, false);
    }
413660
protected function replaceVariablesInTemplate(string $template, array $variables) : string
    {
        $template = preg_replace_callback(
            '/\{\{\s*' . self::REGEX_VARIABLE . '\s*\}\}/i',
            function (array $matches) use ($variables): string {
                return (string) $this->getValue($matches, $variables);
            },
            $template
        );

        return $template;
    }
519680
static private function style($var, $html = true)
    {
        $style='';
        if (is_string($var)){
            $style.='color:#008100;';
            $var = '\''.($html ? htmlspecialchars($var, ENT_COMPAT, 'UTF-8') : $var).'\'';
        }else
        if (is_numeric($var)||is_nan($var)){
            $style.='color:#FF0000;';
        }else
        if (is_bool($var)||is_null($var)){
            $style.='color:#252FFF;';
            if (is_bool($var)) $var = $var ? 'true' : 'false';
            if (is_null($var)) $var = 'null';
        }else{
            return $var;
        }
        return $html ? '<span style="'.$style.'">'.$var.'</span>' : $var;
    }
710567
protected function nospaces(string $template): string
	{
		// Compile regular nospace blocks

		$template = preg_replace_callback('/{%\s*nospace\s*%}(.*?){%\s*endnospace\s*%}/is', function($matches)
		{
			return trim(preg_replace('/>\s+</', '><', $matches[1]));
		}, $template);

		// Compile buffered nospace blocks

		$template = preg_replace('/{%\s*nospace:buffered\s*%}(.*?){%\s*endnospace\s*%}/is', '<?php ob_start(); ?>$1<?php echo trim(preg_replace(\'/>\s+</\', \'><\', ob_get_clean())); ?>', $template);

		return $template;
	}
1143899
public function render(string $view = '', array $variables = []): string
    {
        if (!empty($view)) {
            $this->setView($view);
        }
        $this->assign($variables);
        $content = $this->renderView();
        if (empty($this->layout)) {
            return $content;
        }
        return $this->renderLayout($content);
    }
1072435
public static function dump($var, $echo = true)
    {
        ob_start();
        var_dump($var);

        $output = ob_get_clean();
        $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);

        if (PHP_SAPI == "cli") {
            $output = PHP_EOL . PHP_EOL . $output . PHP_EOL;
        } else {
            $output = "<pre>" . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
        }

        if ($echo) echo($output);

        return $output;
    }
1244435
protected function varToString($var)
    {
        if (is_object($var)) {
            return sprintf('Object(%s)', get_class($var));
        }

        if (is_array($var)) {
            $a = array();
            foreach ($var as $k => $v) {
                $a[] = sprintf('%s => %s', $k, $this->varToString($v));
            }

            return sprintf("Array(%s)", implode(', ', $a));
        }

        if (is_resource($var)) {
            return sprintf('Resource(%s)', get_resource_type($var));
        }

        if (null === $var) {
            return 'null';
        }

        if (false === $var) {
            return 'false';
        }

        if (true === $var) {
            return 'true';
        }

        return (string) "'$var'";
    }
556231
function set_border_spacing($val)
    {
        $arr = explode(" ", $val);

        if (count($arr) == 1) {
            $arr[1] = $arr[0];
        }

        //see __set and __get, on all assignments clear cache, not needed on direct set through __set
        $this->_prop_cache["border_spacing"] = null;
        $this->_props["border_spacing"] = "$arr[0] $arr[1]";
    }
1359643
function fixSpaces($spaces='')
	{
		$count = strlen($spaces);
		if($count == 0) {
			return '';
		}

		$div = floor($count / 2);
		$mod = $count % 2;
		return str_repeat('&nbsp; ', $div).str_repeat('&nbsp;', $mod);
	}