Wrapper for PHP var_dump function
@param   mixed  $var     The variable to dump
@param   string $varname Echo output if true
@param   array  $params  Additionls params
@return bool|JBDump
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;
    }
144782
function hasVariable( $blockName, $varName )
    {
        // 1. Check if the variable is set in either injected or regular settings.
        if (
            !isset( self::$injectedSettings[$this->FileName][$blockName][$varName] )
            && !isset( $this->BlockValues[$blockName][$varName] )
        )
        {
            return false;
        }

        // 2. Check if injected setting isn't strictly false (false being the default value when a variable doesn't exist).
        if (
            isset( self::$injectedSettings[$this->FileName][$blockName][$varName] )
            && self::$injectedSettings[$this->FileName][$blockName][$varName] === false
        )
        {
            return false;
        }

        return true;
    }
922511
public function dump($var, $options = array()) {
        $options += self::$defaults + array('split' => false, 'trace' => false);
        $this->options = $options;
        $this->current_depth = 0;
        $this->object_references = array();

        if (!$options['trace']) $options['trace'] = debug_backtrace();
        extract($options);
        $location = $this->location($trace);

        $dump = array();
        if ($options['split'] && is_array($var)) {
            $this->current_depth = 0;
            foreach ($var as $one) {
				$dump = array_merge($dump, array($this->dump_it($one), ' - '));
			}
			$dump = array_slice($dump, 0, -1);
        } else
            $dump[] = $this->dump_it($var);

        switch ($mode) {
			case 'FirePHP':
				$locString = \alkemann\hl\debug\util\adapters\FirePHP::locationString($location);
				require_once LITHIUM_LIBRARY_PATH . '/FirePHPCore/FirePHP.class.php';
				$firephp = \FirePHP::getInstance(true);
				if (!$firephp) throw new \Exception('FirePHP not installed');
				$firephp->group($locString, array('Collapsed' => false, 'Color' => '#AA0000'));

				$f = function($o) use ($firephp,&$f) {
					if (is_array($o)) {
						foreach ($o as $r)
							$f($r);
					} else {
						$firephp->log($o);
					}
				};
				$f($dump);
				$firephp->groupEnd();
				return;
				break;
			case 'Json':
				$locString = \alkemann\hl\debug\util\adapters\Json::locationString($location);
				$this->output[] = array('location' => $locString, 'dump' => $dump);
				break;
			case 'Log' :
				$locString = \alkemann\hl\debug\util\adapters\Log::locationString($location);
				\lithium\analysis\Logger::debug($locString . "\n" . implode("\n", $dump));
				return;
				break;
			case 'Html' :
			default :
				$locString = \alkemann\hl\debug\util\adapters\Html::locationString($location);
				$this->output[] = '<div class="debug-dump"><div class="debug-location">' . $locString . '</div>'.
					'<div class="debug-content"> ' . implode("<br>\n", $dump) . '</div></div>';
				break;
		}
		if ($options['echo']) {
			$this->__out();
		}
    }
828320
public static function safe_var_dump($x) {
            ob_start();
            if ( isset($x['secret']) ) $x['secret'] = MD5($x['secret']);
            if ( is_array($x) ) foreach ( $x as &$v ) {
                if ( is_array($v) && isset($v['secret']) ) $v['secret'] = MD5($v['secret']);
            }
            var_dump($x);
            $result = ob_get_clean();
            return $result;
    }
1116066
protected function _dumpRenderLite($data, $varname = '...', $params = array())
    {
        if (is_bool($data)) {
            $data = $data ? 'TRUE' : 'FALSE';
        } elseif (is_null($data)) {
            $data = 'NULL';
        }

        if (is_string($data) && strlen($data) == 0) {
            $printrOut = '""';
        } else {
            $printrOut = print_r($data, true);
        }

        if (!self::isCli()) {
            $printrOut = $this->_htmlChars($printrOut);
        }

        if (self::isAjax()) {
            $printrOut = str_replace('] =&gt;', '] =>', $printrOut);
        }

        $output   = array();
        if (!self::isCli()) {
            $output[] = '<pre>------------------------------' . PHP_EOL;
        }

        $output[] = $varname . ' = ';
        $output[] = rtrim($printrOut, PHP_EOL);

        if (!self::isCli()) {
            $output[] = PHP_EOL . '------------------------------</pre>' . PHP_EOL;
        } else {
            $output[] = PHP_EOL;
        }

        if (!self::isAjax()) {
            echo '<pre class="jbdump" style="text-align: left;">' . implode('', $output) . '</pre>' . PHP_EOL;
        } else {
            echo implode('', $output);
        }
    }
40664
public function dump($var, $or = true)
    {
        $result = '';

        if ($var === null) {
            $result .= $this->dumpNull($or);
        } elseif (is_bool($var)) {
            $result .= $this->dumpBool($var, $or);
        } elseif (is_string($var)) {
            $result .= $this->dumpString($var, $or);
        } elseif (is_int($var)) {
            $result .= $this->dumpInt($var, $or);
        } elseif (is_float($var)) {
            $result .= $this->dumpFloat($var, $or);
        } elseif (is_array($var) || is_object($var)) {
            if ($this->recurseDepth >= $this->maxDepth) {
                $type = is_object($var) ? self::NAME_OBJECT : self::NAME_ARRAY;
                $maxDepthReached = $this->writeStart(false);
                $maxDepthReached .= $this->writeRow('<strong>'.$type.'</strong>');
                $maxDepthReached .= $this->writeRow('<span style="padding-left:10pt;font-style:italic;"><i>'
                    .self::DISPLAY_MAX_DEPTH.'</span>');
                $maxDepthReached .= $this->writeEnd();

                return $maxDepthReached;
            }
            $this->recurseDepth++;
            if (is_array($var)) {
                $result .= $this->dumpArray($var, $or);
            } else {
                $result .= $this->dumpObject($var, $or);
            }
            $this->recurseDepth--;
        } elseif (is_resource($var)) {
            $result .= $this->dumpRes($var, $or);
        } else {
            $result .= '???';
        }

        return $result;
    }
455222
public static function dump(array $parameters)
    {
        $content = '';

        foreach ($parameters as $key => $value) {
            if (is_bool($value)) {
                $value = $value ? 'true' : 'false';
            }
            $content .= "{$key} = {$value}\n";
        }

        return $content;
    }
1042006
public function varDump($var)
    {
        if (is_callable($this->varDumpCallback)) {
            return call_user_func($this->varDumpCallback, $var, $this);
        }

        $message = VarDumper::dumpAsString($var, $this->depth, $this->highlight);

        //don't encode highlighted variables
        if (!$this->highlight) {
            $message = Html::encode($message);
        }

        return $message;
    }
206104
public static function returnDump( $var, $html = true ) {
		$dump = null;
		ob_start();
		var_dump( $var );
		$dump = ob_get_contents();
		ob_end_clean();
		if ( $html ) {
			return '<pre>' . htmlspecialchars( $dump ) . '</pre>';
		}
		return $dump;
	}
69203
function $var(params, fn, envs) {
    if (params == null) {
        return params;
    }
    if (typeof params === 'string') {
        if (envs && envs[params] !== undefined) {
            return envs[params];
        }

        return;
    }
    if (Array.isArray(params) && params.length === 2) {
        const key = params[0];
        if (typeof key === 'string') {
            const value = fn.$var(key, fn, envs);

            return value === undefined ? params[1] : value;
        }
    }
    throw new Error(
        '$var expects a string or an array with two elements of which the first one must be a string'
    );
}
1195668
public static function dumpSimple($var, bool $echo = false, bool $cl = false){
        $type   = self::getType($var);
        $dump   = null;
        
        switch($type){
            case self::T_INTEGER:
            case self::T_FLOAT:
            case self::T_STRING:
            case self::T_BOOLEAN:
                $dump   = var_export($var, true);
                break;
            
            case self::T_ARRAY:
                $dump   = count($var);
                break;
            
            case self::T_OBJECT:
                $dump   = get_class($var);
                break;
            
            case self::T_RESOURCE:
                $dump   = get_resource_type($var);
                break;
        }
        
        $return = $type . ($dump !== null ? "({$dump})" : "");
        
        if($echo){
            echo $return . $cl ? PHP_EOL : "";
            return;
        }
        
        return $return;
    }
181741
public static function it($var,
                              $method = AbstractDumper::PRINT_R,
                              $continue = false,
                              $hide = false,
                              $return = false)
    {

        if (self::$Enabled === false) {
            return null;
        }
        //detect console or ajax
        if (php_sapi_name() == 'cli') {
            //no custom dumper?
            if (self::$DumperClass == self::DEFAULT_DUMPER) {
                self::$DumperClass = self::CONSOLE_DUMPER;
            }
        } elseif (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
            if (self::$DumperClass == self::DEFAULT_DUMPER) {
                self::$DumperClass = self::AJAX_DUMPER;
            }
        }

        try {
            $Stop = new self::$DumperClass($hide, $continue, $return);
        } catch (\Exception $exc) {
            error_log($exc->getMessage());
            //fallback
            $default = self::DEFAULT_DUMPER;
            $Stop = new $default($hide, $continue, $return);
        }

        if ($method == AbstractDumper::PRINT_R) {
            return $Stop->print_r($var);
        }
        if ($method == AbstractDumper::GET_TYPE) {
            return $Stop->get_type($var);
        }
        return $Stop->var_dump($var);
    }
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>' );
	}
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'";
    }
7856
protected function _dump_php(&$var) {
		$scope = false;
		$prefix = 'unique';
		$suffix = 'value';

		if ($scope) $vals = $scope;
		else $vals = $GLOBALS;

		$old = $var;
		$var = $new = $prefix.rand().$suffix; $vname = false;
		foreach ($vals as $key => $val) {
			if ($val === $new) $vname = $key;
		}
		$var = $old;

		$output = '<div class="args">';
		$output .= $this->_dump_php_recursive($var, '$'.$vname);
		$output .= "</div>";
		
		return $output;
	}
537860
public static function dump( $var, $format = null ) {

		if( !static::isDebug() )
			return;

		$dumpers = [
			static::DUMP_HTML     => '\\yolk\\debug\\HTMLDumper',
			static::DUMP_TERMINAL => '\\yolk\\debug\\TerminalDumper',
			static::DUMP_TEXT     => '\\yolk\\debug\\TextDumper',
		];

		// auto-detect format if unknown or none specified
		if( !isset($dumpers[$format]) )
			$format = static::isCLI() ? static::DUMP_TERMINAL : static::DUMP_HTML;

		$dumpers[$format]::dump($var);

	}
1340161
static function dump($var, $trace = true)
    {
        $d = Debug::getInstance();

        if ($d->level < 1) {
            return;
        }

        if ($d->terminal) {
            $c = $d->console;

            if (!is_array($var)) {
                $c->writeln(print_r($var, 1), 'blue');
            } else {
                $lines = explode("\n", print_r($var, 1));
                foreach ($lines as $line) {
                    preg_match_all('|(.*)\[(.*)\] \=\>(.*)|', $line, $m);
                    
                    if (!isset($m[0][0])) {
                        $c->writeln($line);
                    } else {
                        $c->write($m[1][0] . '[', 'blue');
                        $c->write($m[2][0], 'light_red');
                        $c->write('] =>', 'blue');
                        $c->writeln($m[3][0], 'blue');
                    }
                }
            }

        } else {
            $txt = preg_replace('/\[(.*)\]/u', '[<span style="color:#d00">$1</span>]', print_r($var, 1));
            echo '<pre style="color:blue">' . $txt . "</pre>";
        }

        if ($trace)
            $d->_trace();
    }