<commit_before><?php

class Kint_Parser
{
    // TODO: Port/new parser plugins
    public static $plugins = array(
        //~ 'Kint_Parser_Callback',
        'Kint_Parser_Plugin_ClassMethods',
        'Kint_Parser_Plugin_ClassStatics',
        'Kint_Parser_Plugin_Closure',
        //~ 'Kint_Parser_Plugin_Color',
        //~ 'Kint_Parser_Plugin_FsPath',
        //~ 'Kint_Parser_Plugin_Json',
        'Kint_Parser_Plugin_Microtime',
        //~ 'Kint_Parser_Plugin_ObjectIterable',
        //~ 'Kint_Parser_Plugin_Smarty',
        //~ 'Kint_Parser_Plugin_SplFileInfo',
        //~ 'Kint_Parser_Plugin_SplObjectStorage',
        //~ 'Kint_Parser_Plugin_StringLength',
        //~ 'Kint_Parser_Plugin_Table',
        //~ 'Kint_Parser_Plugin_Timestamp',
        'Kint_Parser_Plugin_Trace',
        //~ 'Kint_Parser_Plugin_Xml',
    );

    public $caller_class;

    private $marker;
    private $object_hashes = array();

    public function __construct($c = null)
    {
        $this->marker = uniqid("kint\0");
        $this->caller_class = $c;
    }

    public function parse(&$var, Kint_Object $o = null)
    {
        if ($o === null) {
            $o = new Kint_Object();
        }

        $o->type = strtolower(gettype($var));

        switch ($o->type) {
            case 'boolean':
            case 'integer':
            case 'double':
            case 'null':
                $o = $this->parseGeneric($var, $o);
                break;
            case 'string':
            case 'array':
            case 'object':
            case 'resource':
                $o = $this->{'parse'.$o->type}($var, $o);
                break;
            default:
                $o = $this->parseUnknown($var, $o);
                break;
        }

        $this->applyPlugins($var, $o);

        return $o;
    }

    private function parseGeneric(&$var, Kint_Object $o)
    {
        $rep = new Kint_Object_Representation('Contents');
        $rep->contents = $var;
        $o->addRepresentation($rep);

        return $o;
    }

    private function parseString(&$var, Kint_Object $o)
    {
        $string = $o->transplant(new Kint_Object_Blob());
        $string->encoding = Kint_Object_Blob::detectEncoding($var);
        $string->size = Kint_Object_Blob::strlen($var, $string->encoding);

        $rep = new Kint_Object_Representation('Contents');
        $rep->contents = $var;

        $string->addRepresentation($rep);

        return $string;
    }

    private function parseArray(array &$var, Kint_Object $o)
    {
        if (isset($var[$this->marker])) {
            $array = $o->transplant(new Kint_Object_Recursion());
            $array->size = count($var) - 1;

            return $array;
        }

        if (Kint::$max_depth && $o->depth >= Kint::$max_depth) {
            $array = $o->transplant(new Kint_Object_DepthLimit());
            $array->size = count($var);

            return $array;
        }

        $array = $o->transplant(new Kint_Object());
        $array->size = count($var);<commit_msg>Kint_Parser: Bugfix array size on recursion<commit_after><?php

class Kint_Parser
{
    // TODO: Port/new parser plugins
    public static $plugins = array(
        //~ 'Kint_Parser_Callback',
        'Kint_Parser_Plugin_ClassMethods',
        'Kint_Parser_Plugin_ClassStatics',
        'Kint_Parser_Plugin_Closure',
        //~ 'Kint_Parser_Plugin_Color',
        //~ 'Kint_Parser_Plugin_FsPath',
        //~ 'Kint_Parser_Plugin_Json',
        'Kint_Parser_Plugin_Microtime',
        //~ 'Kint_Parser_Plugin_ObjectIterable',
        //~ 'Kint_Parser_Plugin_Smarty',
        //~ 'Kint_Parser_Plugin_SplFileInfo',
        //~ 'Kint_Parser_Plugin_SplObjectStorage',
        //~ 'Kint_Parser_Plugin_StringLength',
        //~ 'Kint_Parser_Plugin_Table',
        //~ 'Kint_Parser_Plugin_Timestamp',
        'Kint_Parser_Plugin_Trace',
        //~ 'Kint_Parser_Plugin_Xml',
    );

    public $caller_class;

    private $marker;
    private $object_hashes = array();

    public function __construct($c = null)
    {
        $this->marker = uniqid("kint\0");
        $this->caller_class = $c;
    }

    public function parse(&$var, Kint_Object $o = null)
    {
        if ($o === null) {
            $o = new Kint_Object();
        }

        $o->type = strtolower(gettype($var));

        switch ($o->type) {
            case 'boolean':
            case 'integer':
            case 'double':
            case 'null':
                $o = $this->parseGeneric($var, $o);
                break;
            case 'string':
            case 'array':
            case 'object':
            case 'resource':
                $o = $this->{'parse'.$o->type}($var, $o);
                break;
            default:
                $o = $this->parseUnknown($var, $o);
                break;
        }

        $this->applyPlugins($var, $o);

        return $o;
    }

    private function parseGeneric(&$var, Kint_Object $o)
    {
        $rep = new Kint_Object_Representation('Contents');
        $rep->contents = $var;
        $o->addRepresentation($rep);

        return $o;
    }

    private function parseString(&$var, Kint_Object $o)
    {
        $string = $o->transplant(new Kint_Object_Blob());
        $string->encoding = Kint_Object_Blob::detectEncoding($var);
        $string->size = Kint_Object_Blob::strlen($var, $string->encoding);

        $rep = new Kint_Object_Representation('Contents');
        $rep->contents = $var;

        $string->addRepresentation($rep);

        return $string;
    }

    private function parseArray(array &$var, Kint_Object $o)
    {
        if (isset($var[$this->marker])) {
            $array = $o->transplant(new Kint_Object_Recursion());
            $array->size = count($var);

            return $array;
        }

        if (Kint::$max_depth && $o->depth >= Kint::$max_depth) {
            $array = $o->transplant(new Kint_Object_DepthLimit());
            $array->size = count($var);

            return $array;
        }

        $array = $o->transplant(new Kint_Object());
        $array->size = count($var);
{'fraction_non_alphanumeric': 0.14516129032258066, 'fraction_numerical': 0.0004937458854509546, 'mean_word_length': 2.021879661859771, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1594953', 'n_tokens_mistral': 1928, 'n_tokens_neox': 1871, 'n_words': 319}