src/Neutrino/Debug/VarDump.php
private function varDump($var)
    {
        $this->lvl++;

        if ($this->lvl > 128) {
            $dump = '<span>** MAX DUMP LVL **</span>';
            $this->lvl--;

            return $dump;
        }

        $id = $this->getVarId($var);

        if (is_array($var) && isset($this->dumpRefs[$id])) {
            $dump = '<code  class="nuc-array">';
            $dump .= 'array:' . count($var) . ' </code> <span class="nuc-closure">[</span><span class="nuc-toggle nuc-toggle-array" data-target="nuc-ref-' . $id . '">#' . $id . '</span>';
            $dump .= '<span class="nuc-closure nuc-close">]</span>';
            $this->lvl--;

            return $dump;
        }

        if (is_object($var) && isset($this->dumpRefs[$id])) {
            $class = get_class($var);
            $className = $this->getClassName($class);
            $dump = '<code title="' . $className . '" class="nuc-object">';
            $short = (preg_replace('/.*\\\\(\w+)$/', '$1', $className));
            $dump .= $short . '</code> <span class="nuc-closure">{</span><span class="nuc-toggle nuc-toggle-object" data-target="nuc-ref-' . $id . '">#' . $id . '</span>';
            $dump .= '<span class="nuc-closure nuc-close">}</span>';
            $this->lvl--;

            return $dump;
        }

        if (is_resource($var) && isset($this->dumpRefs[$id])) {
            $type = get_resource_type($var);
            $resId = intval($var);
            $label = "@$resId";
            $dump = '<code class="nuc-resource">resource(' . $label . ' ' . $type . ')</code> ';
            $dump .= '<span class="nuc-closure">{</span><span class="nuc-toggle nuc-toggle-array" data-target="nuc-ref-' . $id . '">' . $label . '</span>';
            $dump .= '<span class="nuc-closure nuc-close">}</span>';
            $this->lvl--;

            return $dump;
        }

        if (is_null($var)) {
            $dump = '<code class="nuc-const">null</code>';
        } elseif (is_bool($var)) {
            $dump = '<code class="nuc-const">' . ($var ? 'true' : 'false') . '</code>';
        } elseif (is_string($var)) {
            $dump = '<span class="nuc-sep">"</span><code class="nuc-string" title="' . strlen($var) . ' characters">' . htmlentities($var) . '</code><span class="nuc-sep">"</span>';
        } elseif (is_scalar($var)) {
            $dump = '<code class="nuc-' . gettype($var) . '">' . $var . '</code>';
        } elseif (is_resource($var)) {
            $type = get_resource_type($var);
            $resId = intval($var);
            $label = "@$resId";
            $dump = '<code class="nuc-resource">resource(' . $label . ' ' . $type . ')</code>';
            switch ($type) {
                case 'stream':
                    $this->dumpRefs[$id] = true;
                    $dump .= '<span class="nuc-closure">{</span>';
                    $dump .= $this->arrayDump(stream_get_meta_data($var), $id, $label);
                    $dump .= '<span class="nuc-closure nuc-close">}</span>';
                    break;
                case 'process':
                    $this->dumpRefs[$id] = true;
                    $dump .= '<span class="nuc-closure">{</span>';
                    $dump .= $this->arrayDump(proc_get_status($var), $id, $label);
                    $dump .= '<span class="nuc-closure nuc-close">}</span>';
                    break;
                case 'curl':
                    $this->dumpRefs[$id] = true;
                    $dump .= '<span class="nuc-closure">{</span>';
                    $dump .= $this->arrayDump(curl_getinfo($var), $id, $label);
                    $dump .= '<span class="nuc-closure nuc-close">}</span>';
                    break;
            }
        } elseif (is_array($var)) {
            $dump = '<code class="nuc-array">array:' . count($var) . '</code> <span class="nuc-closure">[</span>';
            if (!empty($var)) {
                if (!is_null($id)) {
                    $this->dumpRefs[$id] = true;
                }

                $dump .= $this->arrayDump($var, $id);
            }
            $dump .= '<span class="nuc-closure nuc-close">]</span>';
        } elseif (is_object($var)) {
            $this->dumpRefs[$id] = true;

            $class = get_class($var);
            $className = $this->getClassName($class);

            $dump = '<code class="nuc-object" title="' . $className . '">' . (preg_replace('/.*\\\\(\w+)$/', '$1', $className)) . '</code> ';
            $dump .= '<span class="nuc-closure">{</span>';

            $prop = '';
            $properties = Reflexion::getReflectionProperties($var);
            $dumpedProperties = [];
            foreach ($properties as $property) {
                $dumpedProperties[] = $name = $property->getName();
                $isStatic = $property->isStatic();
                $val = Reflexion::get($isStatic ? $class : $var, $name);

                if ($property->isPrivate()) {
                    $type = 'private';
                    $mod = '-';
                } elseif ($property->isProtected()) {
                    $type = 'protected';
                    $mod = '#';
                } else {
                    $type = 'public';
                    $mod = '+';
                }
                $ctype = str_replace(' ', '-', gettype($val));
                $vtype = $ctype === 'object' ? $this->getClassName(get_class($val)) : $ctype;
                $title = $type . ' ' . ($isStatic ? 'static ' : '') . $name . ':' . $vtype;
                $prop .= '<li class="nuc-' . $ctype . ($this->canHasChild($val) ? ' nuc-close' : '') . '">';
                $prop .= '<code class="nuc-key" title="' . $title . '"><small class="nuc-modifier">' . $mod . '</small> ' . ($isStatic ? '::' : '') . $name . '</code>: ';
                $prop .= $this->varDump($val);
                $prop .= '</li>';
            }
            foreach ($var as $key => $val) {
                if (!in_array($key, $dumpedProperties, true)) {
                    $ctype = str_replace(' ', '-', gettype($val));
                    $vtype = $ctype === 'object' ? $this->getClassName(get_class($val)) : $ctype;
                    $prop .= '<li class="nuc-' . $ctype . ($this->canHasChild($val) ? ' nuc-close' : '') . '">';
                    $prop .= '<code class="nuc-key" title="public ' . $key . ':' . $vtype . '"><small class="nuc-modifier">+</small> ' . $key . '</code>: ';
                    $prop .= $this->varDump($val);
                    $prop .= '</li>';
                }
            }
            if (!empty($prop)) {
                $dump .= '<span class="nuc-toggle nuc-toggle-object" data-target="nuc-ref-' . $id . '">#' . $id . '</span>';
                $dump .= '<ul class="nuc-object" id="nuc-ref-' . $id . '">';
                $dump .= $prop;
                $dump .= '</ul>';
            }
            $dump .= '<span class="nuc-closure">}</span>';
        } else {
            $dump = '<code class="nuc-unknown">' . gettype($var) . '</code>';
        }

        $this->lvl--;

        return $dump;
    }
private function varDump($var)
    {
        $this->lvl++;

        if ($this->lvl > 128) {
            $dump = '<span>** MAX DUMP LVL **</span>';
            $this->lvl--;

            return $dump;
        }

        $id = $this->getVarId($var);

        if (is_array($var) && isset($this->dumpRefs[$id])) {
            $dump = '<code  class="nuc-array">';
            $dump .= 'array:' . count($var) . ' </code> <span class="nuc-closure">[</span><span class="nuc-toggle nuc-toggle-array" data-target="nuc-ref-' . $id . '">#' . $id . '</span>';
            $dump .= '<span class="nuc-closure nuc-close">]</span>';
            $this->lvl--;

            return $dump;
        }

        if (is_object($var) && isset($this->dumpRefs[$id])) {
            $class = get_class($var);
            $className = $this->getClassName($class);
            $dump = '<code title="' . $className . '" class="nuc-object">';
            $short = (preg_replace('/.*\\\\(\w+)$/', '$1', $className));
            $dump .= $short . '</code> <span class="nuc-closure">{</span><span class="nuc-toggle nuc-toggle-object" data-target="nuc-ref-' . $id . '">#' . $id . '</span>';
            $dump .= '<span class="nuc-closure nuc-close">}</span>';
            $this->lvl--;

            return $dump;
        }

        if (is_resource($var) && isset($this->dumpRefs[$id])) {
            $type = get_resource_type($var);
            $resId = intval($var);
            $label = "@$resId";
            $dump = '<code class="nuc-resource">resource(' . $label . ' ' . $type . ')</code> ';
            $dump .= '<span class="nuc-closure">{</span><span class="nuc-toggle nuc-toggle-array" data-target="nuc-ref-' . $id . '">' . $label . '</span>';
            $dump .= '<span class="nuc-closure nuc-close">}</span>';
            $this->lvl--;

            return $dump;
        }

        if (is_null($var)) {
            $dump = '<code class="nuc-const">null</code>';
        } elseif (is_bool($var)) {
            $dump = '<code class="nuc-const">' . ($var ? 'true' : 'false') . '</code>';
        } elseif (is_string($var)) {
            $dump = '<span class="nuc-sep">"</span><code class="nuc-string" title="' . strlen($var) . ' characters">' . htmlentities($var) . '</code><span class="nuc-sep">"</span>';
        } elseif (is_scalar($var)) {
            $dump = '<code class="nuc-' . gettype($var) . '">' . $var . '</code>';
        } elseif (is_resource($var)) {
            $type = get_resource_type($var);
            $resId = intval($var);
            $label = "@$resId";
            $dump = '<code class="nuc-resource">resource(' . $label . ' ' . $type . ')</code>';
            switch ($type) {
                case 'stream':
                    $this->dumpRefs[$id] = true;
                    $dump .= '<span class="nuc-closure">{</span>';
                    $dump .= $this->arrayDump(stream_get_meta_data($var), $id, $label);
                    $dump .= '<span class="nuc-closure nuc-close">}</span>';
                    break;
                case 'process':
                    $this->dumpRefs[$id] = true;
                    $dump .= '<span class="nuc-closure">{</span>';
                    $dump .= $this->arrayDump(proc_get_status($var), $id, $label);
                    $dump .= '<span class="nuc-closure nuc-close">}</span>';
                    break;
                case 'curl':
                    $this->dumpRefs[$id] = true;
                    $dump .= '<span class="nuc-closure">{</span>';
                    $dump .= $this->arrayDump(curl_getinfo($var), $id, $label);
                    $dump .= '<span class="nuc-closure nuc-close">}</span>';
                    break;
            }
        } elseif (is_array($var)) {
            $dump = '<code class="nuc-array">array:' . count($var) . '</code> <span class="nuc-closure">[</span>';
            if (!empty($var)) {
                if (!is_null($id)) {
                    $this->dumpRefs[$id] = true;
                }

                $dump .= $this->arrayDump($var, $id);
            }
            $dump .= '<span class="nuc-closure nuc-close">]</span>';
        } elseif (is_object($var)) {
            $this->dumpRefs[$id] = true;

            $class = get_class($var);
            $className = $this->getClassName($class);

            $dump = '<code class="nuc-object" title="' . $className . '">' . (preg_replace('/.*\\\\(\w+)$/', '$1', $className)) . '</code> ';
            $dump .= '<span class="nuc-closure">{</span>';

            $prop = '';
            $properties = Reflexion::getReflectionProperties($var);
            $dumpedProperties = [];
            foreach ($properties as $property) {
                $dumpedProperties[] = $name = $property->getName();
                $isStatic = $property->isStatic();
                $val = Reflexion::get($isStatic ? $class : $var, $name);

                if ($property->isPrivate()) {
                    $type = 'private';
                    $mod = '-';
                } elseif ($property->isProtected()) {
                    $type = 'protected';
                    $mod = '#';
                } else {
                    $type = 'public';
                    $mod = '+';
                }
                $ctype = str_replace(' ', '-', gettype($val));
                $vtype = $ctype === 'object' ? $this->getClassName(get_class($val)) : $ctype;
                $title = $type . ' ' . ($isStatic ? 'static ' : '') . $name . ':' . $vtype;
                $prop .= '<li class="nuc-' . $ctype . ($this->canHasChild($val) ? ' nuc-close' : '') . '">';
                $prop .= '<code class="nuc-key" title="' . $title . '"><small class="nuc-modifier">' . $mod . '</small> ' . ($isStatic ? '::' : '') . $name . '</code>: ';
                $prop .= $this->varDump($val);
                $prop .= '</li>';
            }
            foreach ($var as $key => $val) {
                if (!in_array($key, $dumpedProperties, true)) {
                    $ctype = str_replace(' ', '-', gettype($val));
                    $vtype = $ctype === 'object' ? $this->getClassName(get_class($val)) : $ctype;
                    $prop .= '<li class="nuc-' . $ctype . ($this->canHasChild($val) ? ' nuc-close' : '') . '">';
                    $prop .= '<code class="nuc-key" title="public ' . $key . ':' . $vtype . '"><small class="nuc-modifier">+</small> ' . $key . '</code>: ';
                    $prop .= $this->varDump($val);
                    $prop .= '</li>';
                }
            }
            if (!empty($prop)) {
                $dump .= '<span class="nuc-toggle nuc-toggle-object" data-target="nuc-ref-' . $id . '">#' . $id . '</span>';
                $dump .= '<ul class="nuc-object" id="nuc-ref-' . $id . '">';
                $dump .= $prop;
                $dump .= '</ul>';
            }
            $dump .= '<span class="nuc-closure">}</span>';
        } else {
            $dump = '<code class="nuc-unknown">' . gettype($var) . '</code>';
        }

        $this->lvl--;

        return $dump;
    }
Dump any var

@param mixed $var

@return string