<commit_before><?php

class Eigenclass extends Klass {

    protected $_object;

    function __construct(&$object) {
        $this->_object = $object;
        parent::__construct(get_class($object), null, false);
    }

    function __include($modules, $instance = false) {
        if (!is_array($modules)) $modules = func_get_args();
        if (is_bool(end($modules))) $instance = array_pop($modules);
        $method = $instance ? 'parent::__include' : array($this->reference(), '__include');
        return call_user_func_array($method, $modules);
    }

    function ancestors() {
        if ($this->is_class()) {
            // $ancestors = array_merge($this->_object->extended_modules(), array($this->_object));
            $ancestors = array($this->_object);
            if ($this->_object->superclass()) {
                $ancestors = array_merge($ancestors, $this->_object->superclass()->__class()->ancestors());
            } else {
                $ancestors = array_merge($ancestors, Klass::instance(__CLASS__)->ancestors());
            }
            $ancestors = array_reverse(array_unique(array_reverse($ancestors), SORT_REGULAR));
        } else {
            $ancestors = parent::ancestors();
        }
        return $ancestors;
    }

    function callee($method, &$caller = null) {
        $ancestors = $this->ancestors();
        if ($caller && in_array($caller, $ancestors)) $ancestors = array_slice($ancestors, array_search($caller, $ancestors) + 1);
        foreach ($ancestors as $ancestor) {
            $methods_type = $this->is_class() && ($this->_object == $ancestor || in_array($ancestor->name(), class_parents($this->_object->name()))) ? 'class' : 'instance';
            $methods = $ancestor->reflection()->{$methods_type.'_methods'}(false);
            if (isset($methods[$method])) return $methods[$method];
        }
    }

    function is_class() {
        return get_class($this->_object) == get_parent_class(__CLASS__);
    }

    function object() {
        return $this->_object;
    }

    function reference() {
        return parent::instance($this->_name);
    }

}<commit_msg>dont recursively remove duplicate ancestors in Eigenclass either<commit_after><?php

class Eigenclass extends Klass {

    protected $_object;

    function __construct(&$object) {
        $this->_object = $object;
        parent::__construct(get_class($object), null, false);
    }

    function __include($modules, $instance = false) {
        if (!is_array($modules)) $modules = func_get_args();
        if (is_bool(end($modules))) $instance = array_pop($modules);
        $method = $instance ? 'parent::__include' : array($this->reference(), '__include');
        return call_user_func_array($method, $modules);
    }

    function ancestors($unique = true) {
        if ($this->is_class()) {
            // $ancestors = array_merge($this->_object->extended_modules(), array($this->_object));
            $ancestors = array($this->_object);
            if ($this->_object->superclass()) {
                $ancestors = array_merge($ancestors, $this->_object->superclass()->__class()->ancestors(false));
            } else {
                $ancestors = array_merge($ancestors, Klass::instance(__CLASS__)->ancestors(false));
            }
            if ($unique) $ancestors = array_reverse(array_unique(array_reverse($ancestors), SORT_REGULAR));
        } else {
            $ancestors = parent::ancestors($unique);
        }
        return $ancestors;
    }

    function callee($method, &$caller = null) {
        $ancestors = $this->ancestors();
        if ($caller && in_array($caller, $ancestors)) $ancestors = array_slice($ancestors, array_search($caller, $ancestors) + 1);
        foreach ($ancestors as $ancestor) {
            $methods_type = $this->is_class() && ($this->_object == $ancestor || in_array($ancestor->name(), class_parents($this->_object->name()))) ? 'class' : 'instance';
            $methods = $ancestor->reflection()->{$methods_type.'_methods'}(false);
            if (isset($methods[$method])) return $methods[$method];
        }
    }

    function is_class() {
        return get_class($this->_object) == get_parent_class(__CLASS__);
    }

    function object() {
        return $this->_object;
    }

    function reference() {
        return parent::instance($this->_name);
    }

}
{'fraction_non_alphanumeric': 0.16539967749366505, 'fraction_numerical': 0.00046072333563695, 'mean_word_length': 2.9472727272727273, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, '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': '2532154', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1259, 'n_words': 222}