Outputs dump of $data in browser

@param mixed $data
@param bool  $clean

@throws \RuntimeException
516896
public static function dump($data, bool $clean = true)
    {
        if ($clean) {
            /** @noinspection PhpStatementHasEmptyBodyInspection */
            /** @noinspection PhpUsageOfSilenceOperatorInspection */
            while (ob_get_level() && @ob_end_clean() !== false) {
                // Do nothing, just clean buffer
            }
        }

        // Represent supplied data
        switch (gettype($data)) {
            case 'boolean':

                echo 'Boolean: ' . ($data ? 'true' : 'false') . '<br>' . PHP_EOL;

                break;

            case 'string':

                echo 'String: ' . $data . '<br>'. PHP_EOL;

                break;

            case 'double':

                echo 'Double: ' . $data . '<br>'. PHP_EOL;

                break;

            case 'integer':

                echo 'Integer: ' . $data . '<br>'. PHP_EOL;

                break;

            case 'object':

                $methods = get_class_methods($data);

                if ($methods) {

                    natsort($methods);

                    $html = ['<table style="margin-left:50px">'];

                    foreach ($methods as $v) {
                        $html[] = '<tr><td>' . htmlspecialchars($v) . '()</td></tr>';
                    }

                    $html[] = '</table>';

                    $methods = implode('', $html);
                }

                $vars = get_object_vars($data);

                if ($vars) {

//                    natsort($vars);

                    $html = ['<table style="margin-left:50px">'];

                    foreach ($vars as $k => $v) {
                        $html[] = '<tr><td>' . htmlspecialchars((string)$k) . '</td><td>' . (is_string($v) ? htmlspecialchars($v) : '') . '</td></tr>';
                    }

                    $html[] = '</table>';

                    $vars = implode('', $html);
                }

                echo 'Object: <strong>' . get_class($data) . '</strong>' . ($methods ? '<br><br><strong>Methods</strong>: ' . $methods : '') . ($vars ? '<br><br><strong>Variables</strong>: ' . $vars : '') . '<br><br><strong>Data</strong>:<br><pre>' . print_r($data, true) . '</pre>';

                break;

            case 'resource':

                echo 'Resource: ' . get_resource_type($data) . '<br>'. PHP_EOL;

                break;

            case 'NULL':

                echo 'NULL'. PHP_EOL . '<br>';

                break;

            case 'array':

                echo '<pre>' . print_r($data, true) . '</pre>' . '<br>'. PHP_EOL;

                break;

            default:

                throw new \RuntimeException('Supplied data type is not supported');
        }

        self::outputDebugStackTable();

        // Show
        if (Settings::get('debug_panel')) {
            Stats::getView();
        }

        // No more output
        if ($clean) {
            exit;
        }
    }
1006298
public function sendDataAsHtml($data) {
    $this->disableView();
    if (extension_loaded('xdebug')) {
      ob_start();
      var_dump($data);
      $output = ob_get_clean();
    }
    else {
      $output = sprintf(
          '<pre><code>%s</code></pre>',
          json_encode($data,JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT)
      );
    }
    $this->setContent($output);
    $this->send();
  }
806880
private function prepareResultPage($data)
    {
        /* convert service data object into stdClass/array */
        $type = $this->getOutDataType();
        $stdObj = $this->outputProcessor->convertValue($data, $type);
        /* prepare result page with JSON data */
        $result = $this->resultFactory->create(AResultFactory::TYPE_JSON);
        $result->setData($stdObj);
        return $result;
    }
51023
public static function dump( $data, int $deep = 10 ) {

    if( --$deep < 0 ) return '...';
    else if( !Collection::is( $data ) ) return $data;
    else {

      // handle custom classes
      $_data = Collection::copy( $data, false );
      if( is_object( $data ) && !( $data instanceof \StdClass ) ) try {
        if( \method_exists( $data, '__debugInfo'  ) ) $_data = $data->__debugInfo();
        else {

          $reflection = new \ReflectionClass( $data );
          $tmp        = [ '__CLASS__' => $reflection->getName() ];

          foreach( $reflection->getProperties() as $property ) {
            if( !$property->isStatic() ) {
              $property->setAccessible( true );

              $key                                = $property->isPrivate() ? '-' : ( $property->isProtected() ? '#' : '+' );
              $tmp[ $key . $property->getName() ] = $property->getValue( $data );
            }
          }

          $_data = $tmp;
        }

      } catch( \ReflectionException $_ ) {
        // can't do anything
      }

      //
      foreach( $_data as &$value ) $value = static::dump( $value, $deep );
      return $_data;
    }
  }
662233
protected function cleanSaveData(
        &$data
    ) {
        if (empty($data)) {
            return;
        }

        if (is_array($data)) {
            ksort($data);

            foreach ($data as &$arrayData) {
                $this->cleanSaveData($arrayData);
            }

            return;
        }

        if (is_string($data)) {
            $data = trim(
                str_replace(
                    [
                        "\n",
                        "\t",
                        "\r"
                    ],
                    "",
                    $data
                )
            );
        }

        return;
    }
986586
public static function dump($data, $varname = '...', $params = array())
    {
        if (!self::isDebug()) {
            return false;
        }

        $_this = self::i();

        if (self::isAjax()) {
            $_this->_dumpRenderLite($data, $varname, $params);

        } elseif (self::$_config['dump']['render'] == 'lite') {
            $_this->_dumpRenderLite($data, $varname, $params);

        } elseif (self::$_config['dump']['render'] == 'html') {
            $_this->_dumpRenderHtml($data, $varname, $params);

        } elseif (self::$_config['dump']['render'] == 'log') {
            $_this->_dumpRenderLog($data, $varname, $params);

        } elseif (self::$_config['dump']['render'] == 'mail') {
            $_this->_dumpRenderMail($data, $varname, $params);

        } elseif (self::$_config['dump']['render'] == 'print_r') {
            $_this->_dumpRenderPrintr($data, $varname, $params);

        } elseif (self::$_config['dump']['render'] == 'var_dump') {
            $_this->_dumpRenderVardump($data, $varname, $params);
        }

        if (self::$_config['dump']['die']) {
            die('JBDump_die');
        }

        return $_this;
    }
197306
public static function output($message, $data = null)
    {
        if (static::$mode == "html") {
            static::html($message, $data);
        } else {
            static::text($message, $data);
        }
    }
672305
public function update(array $cleanData, $isInit = false)
    {
        if ($isInit) {
            $attrs = $this->getAttrs();
            foreach ($cleanData as $key => $value) {
                if (($value instanceof Model) && isset($attrs[$key]) && isset($attrs[$key]['type'])
                    && ( $attrs[$key]['type'] == self::DATA_TYPE_REFERENCE || $attrs[$key]['type'] == self::DATA_TYPE_REFERENCES )
                ) {
                    $value = $this->setRef($key, $value);
                }
                $this->cleanData[$key] = $value;
            }
        } else {
            foreach ($cleanData as $key => $value) {
                $this->$key = $value;
            }
        }

        return true;
    }
621614
public static function dump($string, $color = null, $debug = true)
    {
        if ($debug) {
            print self::formatOutput($string, $color);
            static::flush();
        }
    }
783232
private function doXssClean($data)
    {
        if (is_array($data) && count($data)) {
            foreach ($data as $k => &$v) {
                $v = $this->doXssClean($data[$k]);
            }

            return $data;
        }

        if (trim($data) === '') {
            return $data;
        }

        // xss_clean function from Kohana framework 2.3.1
        $data = str_replace(['&amp;', '&lt;', '&gt;'], ['&amp;amp;', '&amp;lt;', '&amp;gt;'], $data);
        $data = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $data);
        $data = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $data);
        /** @noinspection CallableParameterUseCaseInTypeContextInspection */
        $data = html_entity_decode($data, ENT_COMPAT, 'UTF-8');

        // Remove any attribute starting with "on" or xmlns
        $data = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu', '$1>', $data);

        // Remove javascript: and vbscript: protocols
        $data = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([`\'"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu',
            '$1=$2nojavascript...', $data);
        $data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu',
            '$1=$2novbscript...', $data);
        $data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#u',
            '$1=$2nomozbinding...', $data);

        // Only works in IE: <span style="width: expression(alert('Ping!'));"></span>
        $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i',
            '$1>', $data);
        $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i',
            '$1>', $data);
        $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*+>#iu',
            '$1>', $data);

        // Remove namespaced elements (we do not need them)
        $data = preg_replace('#</*\w+:\w[^>]*+>#i', '', $data);

        do {
            // Remove really unwanted tags
            $old_data = $data;
            $data = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i',
                '', $data);
        } while ($old_data !== $data);

        return $data;
    }
661230
public function render($template, array $data = array(), $output = false)
    {
        foreach ($data as $k => $v) {
            $this->assign($k, $v);
        }
        ob_start();
        include $this->compiled($template);
        return $output ? ob_end_flush() : ob_get_clean();
    }
441146
public static function dump($data, $second = '')
    {
        if (static::isCli()) {
            $args = func_get_args();
            krumo::cli_dump($args);

            return true;
        }

        // If we're capturing call dump() with just data and capture the output
        if ($second === KRUMO_RETURN) {
            ob_start();

            static::dump($data);

            $str = ob_get_clean();

            return $str;
        // If we were given expand all, set the global variable
        } elseif ($second === KRUMO_EXPAND_ALL) {
            static::$expand_all = true;
            static::dump($data);

            return true;
        } elseif ($second === KRUMO_NO_SORT) {
            self::$sort = false;
            Krumo::dump($data);

            return true;
        } elseif ($second === KRUMO_SORT) {
            self::$sort = true;
            Krumo::dump($data);

            return true;
        }

        $clearObjectRecursionProtection   = false;
        if (static::$objectRecursionProtection === null) {
            static::$objectRecursionProtection = array();
            $clearObjectRecursionProtection  = true;
        }

        // disabled
        if (!static::_debug()) {
            return false;
        }

        // more arguments
        if (func_num_args() > 1) {
            $_ = func_get_args();
            $result = true;
            foreach ($_ as $d) {
                $result = $result && static::dump($d);
            }

            return $result;
        }

        // find caller
        $_ = debug_backtrace();
        while ($d = array_pop($_)) {
            $callback = static::$lineNumberTestCallback;
            $function = strToLower($d['function']);
            if (in_array($function, array("krumo","k","kd")) || (strToLower(@$d['class']) == 'krumo') || (is_callable($callback) && call_user_func($callback, $d))) {
                break;
            }
        }

        $showVersion  = static::_config('display', 'show_version', true);
        $showCallInfo = static::_config('display', 'show_call_info', true);
        $krumoUrl     = 'https://github.com/mmucklo/krumo';

        //////////////////////
        // Start HTML header//
        //////////////////////
        print "<div class=\"krumo-root\">\n";
        print "\t<ul class=\"krumo-node krumo-first\">\n";

        // The actual item itself
        static::_dump($data);

        if ($showVersion || $showCallInfo) {
            print "\t\t<li class=\"krumo-footnote\">\n";

            if ($showCallInfo && isset($d['file']) && $d['file']) {
                print "<span class=\"krumo-call\" style=\"white-space:nowrap;\">";
                print "Called from <strong><code>" . $d['file'] . "</code></strong>, ";
                print "line <strong><code>" . $d['line'] . "</code></strong></span>";
            }

            if ($showVersion) {
                $version = static::version();
                print "<span class=\"krumo-version\" style=\"white-space:nowrap;\">\n";
                print "<strong class=\"krumo-version-number\">Krumo version $version</strong> | <a href=\"$krumoUrl\" target=\"_blank\">$krumoUrl</a>\n";
                print "</span>\n";
            }

            print "</li>";
        }

        print "</ul></div>\n";
        print "<!-- Krumo - HTML -->\n\n";

        // Output the CSS and JavaScript AFTER the HTML
        static::_css();
        ////////////////////
        // End HTML header//
        ////////////////////

        // flee the hive
        $_recursion_marker = static::_marker();
        if ($hive =& static::_hive($dummy)) {
            foreach ($hive as $i => $bee) {
                if (is_object($bee)) {
                    if (($hash = spl_object_hash($bee)) && isset(static::$objectRecursionProtection[$hash])) {
                        unset(static::$objectRecursionProtection[$hash]);
                    }
                } elseif (isset($hive[$i]->$_recursion_marker)) {
                    unset($hive[$i][$_recursion_marker]);
                }
            }
        }

        if ($clearObjectRecursionProtection) {
            static::$objectRecursionProtection = null;
        }
        return true;
    }
1329683
static public function dump($data, $line=true)
	{
	    if (is_string($data)) {
	        $data = json_decode(str_replace(["\r\n"], "", $data), true);
	    }
	    
	    if (is_array($data)) {
	        $isPureArray = false;
	        $keys = array_keys($data);
	        foreach ($keys as $k) {
	            if (!is_numeric($k)) {
	                $isPureArray = false;
	                break;
	            }
	        }
	        
	        $line      = $line ? PHP_EOL : '';
	        $str       = "";
	        $s_data    = [];
	        
	        foreach ($data as $name => $value) {
	            if (is_scalar($value)) {
	                $s_data[] = (!$isPureArray ? '"' . $name . '": ' : '') . (is_string($value) ? '"' . $value . '"' : $value);
	            } else {
	                $s_data[] = (!$isPureArray ? '"' . $name . '": ' : '') . static::dump($value, $line);
	            }
	        }
	        $str .= implode(',' . $line , $s_data);
	        
	        $str = $isPureArray ? '[' . $line . $str . $line . ']' : '{' . $line . $str . $line . '}';
	        return $str;
	    }
	    
	    return $data;
	}
395138
public function dump($key, array $data)
    {
        $data = Hash::flatten($data);
        array_walk($data, [$this, '_persist'], $key);
        array_filter($data);

        return (bool)$data;
    }
1306594
private static function _dump(&$data, $name='...')
	{

		// object ?
		//
		if (is_object($data))
		{
			return self::_object($data, $name);
		}

		// array ?
		//
		if (is_array($data))
		{
			return self::_array($data, $name);
		}

		// resource ?
		//
		if (is_resource($data))
		{
			return self::_resource($data, $name);
		}

		// scalar ?
		//
		if (is_string($data))
		{
			return self::_string($data, $name);
		}

		if (is_float($data))
		{
			return self::_float($data, $name);
		}

		if (is_integer($data))
		{
			return self::_integer($data, $name);
		}

		if (is_bool($data))
		{
			return self::_boolean($data, $name);
		}

		// null ?
		//
		if (is_null($data))
		{
			return self::_null($name);
		}
	}
947794
public static function dump($data = null, $export = false) {

		if(false === is_bool($export)) {
 			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type boolean, "%s" given', __METHOD__, gettype($export)), E_USER_ERROR);
		}

		if($data === null || (true === is_string($data) && trim($data) === '') || true === is_bool($data)) {

			if($export) {
				return var_export($data);
			}

			echo '<pre>' . var_dump($data) . '</pre>';

			return;
		}
		
		if($export) {
			return print_r($data, true);
		}

		echo '<pre>' . print_r($data, true) . '</pre>';
	}
277211
public static function fetch($data)
	{
		// disabled ?
		//
		if (!self::_debug())
		{
			return false;
		}

		ob_start();
                call_user_func_array(
			array(__CLASS__, 'dump'),
			func_get_args()
			);

                return ob_get_clean();
	}