<commit_before><?php

class Hm_Mock_Session {
    public $loaded = true;
    public $data = array();
    public function get($id, $default) {
        if ($id == 'saved_pages') {
            return array('foo' => array('bar', false));
        }
        elseif (array_key_exists($id, $this->data)) {
            return $this->data[$id];
        }
        return $default;
    }
    public function set($name, $value) {
        $this->data[$name] = $value;
    }
    public function build_fingerprint($request, $site_key) {
        return 'fakefingerprint';
    }
    public function is_active() {
        return $this->loaded;
    }
    public function destroy() {
        return true;
    }
    public function end() {
       return true; 
    }
    public function secure_cookie($request, $name, $value, $lifetime) {
        return true;
    }
}

class Hm_Mock_Memcached_No {
    function addServer($server, $port) {
        return false;
    }
}
class Hm_Mock_Memcached {
    private $data = array();
    public static $set_failure = false;
    function addServer($server, $port) {
        return true;
    }
    function set($key, $val, $lifetime) {
        if (self::$set_failure) {
            return false;
        }
        $this->data[$key] = $val;
        return true;
    }
    function get($key) {
        if (array_key_exists($key, $this->data)) {
            return $this->data[$key];
        }
        return false;
    }
    function delete($key) {
        if (array_key_exists($key, $this->data)) {
            unset($this->data[$key]);
            return true;
        }
        return false;
    }
    function quit() {
        return true;
    }
}
class Hm_Mock_Config {
    public $mods = array();
    public $data = array(
        'user_settings_dir' => './data',
        'default_language' => 'es',
    );
    public function get($id, $default=false) {
        if (array_key_exists($id, $this->data)) {
            return $this->data[$id];
        }
        return $default;
    }
    public function get_modules() {
        return $this->mods;
    }
    public function set($name, $value) {
        $this->data[$name] = $value;
    }
}

class Hm_Mock_Request {

    public $invalid_input_detected;
    public $post = array('hm_page_key' => 'asdf', 'fld1' => '0', 'fld2' => '1');
    public $get = array();
    public $cookie = array();
    public $server = array('SERVER_NAME' => 'test', 'REQUEST_URI' => 'test', 'HTTP_USER_AGENT' => 'android', 'REQUEST_METHOD' => 'GET');
    public $tls = false;
    public $type;
    public $sapi = 'test';
    public $format = 'Hm_Format_HTML5';
    public $path = 'asdf';
    public $method = 'GET';
    public function __construct($type) {
        $this->type = $type;
    }
}
class Hm_Functions {
        public static $rand_bytes = 'good';
        public static $memcache = true;
        public static $exists = true;
        public static $exec_res = '{"unit":"test"}';
        public static function setcookie($name, $value, $lifetime=0, $path='', $domain='', $html_only='') { return true; }
        public static function header($header) { return true; }
        public static function cease() { return true; }
        public static function session_start() { $_SESSION['data'] = '<KEY>'; }
        public static function error_log() { return true; }
        public static function c_init() { return true; }
        public static function c_setopt() { return true; }
        public static function c_exec() { return self::$exec_res; }
        public static function function_exists($func) { return self::$exists; }<commit_msg>try to massage the test to run on PHP versions < 5.6<commit_after><?php

class Hm_Mock_Session {
    public $loaded = true;
    public $data = array();
    public function get($id, $default) {
        if ($id == 'saved_pages') {
            return array('foo' => array('bar', false));
        }
        elseif (array_key_exists($id, $this->data)) {
            return $this->data[$id];
        }
        return $default;
    }
    public function set($name, $value) {
        $this->data[$name] = $value;
    }
    public function build_fingerprint($request, $site_key) {
        return 'fakefingerprint';
    }
    public function is_active() {
        return $this->loaded;
    }
    public function destroy() {
        return true;
    }
    public function end() {
       return true; 
    }
    public function secure_cookie($request, $name, $value, $lifetime) {
        return true;
    }
}

class Hm_Mock_Memcached_No {
    function addServer($server, $port) {
        return false;
    }
}
class Hm_Mock_Memcached {
    private $data = array();
    public static $set_failure = false;
    function addServer($server, $port) {
        return true;
    }
    function set($key, $val, $lifetime) {
        if (self::$set_failure) {
            return false;
        }
        $this->data[$key] = $val;
        return true;
    }
    function get($key) {
        if (array_key_exists($key, $this->data)) {
            return $this->data[$key];
        }
        return false;
    }
    function delete($key) {
        if (array_key_exists($key, $this->data)) {
            unset($this->data[$key]);
            return true;
        }
        return false;
    }
    function quit() {
        return true;
    }
}
class Hm_Mock_Config {
    public $mods = array();
    public $data = array(
        'user_settings_dir' => './data',
        'default_language' => 'es',
    );
    public function get($id, $default=false) {
        if (array_key_exists($id, $this->data)) {
            return $this->data[$id];
        }
        return $default;
    }
    public function get_modules() {
        return $this->mods;
    }
    public function set($name, $value) {
        $this->data[$name] = $value;
    }
}

class Hm_Mock_Request {

    public $invalid_input_detected;
    public $post = array('hm_page_key' => 'asdf', 'fld1' => '0', 'fld2' => '1');
    public $get = array();
    public $cookie = array();
    public $server = array('SERVER_NAME' => 'test', 'REQUEST_URI' => 'test', 'HTTP_USER_AGENT' => 'android', 'REQUEST_METHOD' => 'GET');
    public $tls = false;
    public $type;
    public $sapi = 'test';
    public $format = 'Hm_Format_HTML5';
    public $path = 'asdf';
    public $method = 'GET';
    public function __construct($type) {
        $this->type = $type;
    }
}
class Hm_Functions {
        public static $rand_bytes = 'good';
        public static $memcache = true;
        public static $exists = true;
        public static $exec_res = '{"unit":"test"}';
        public static function setcookie($name, $value, $lifetime=0, $path='', $domain='', $html_only='') { return true; }
        public static function header($header) { return true; }
        public static function cease() { return true; }
        public static function session_start() { $_SESSION['data'] = '<KEY>'; }
        public static function error_log() { return true; }
        public static function c_init() { return true; }
        public static function c_setopt() { return true; }
        public static function c_exec() { return self::$exec_res; }
        public static function function_exists($func) {
            if ((float) substr(phpversion(), 0, 3) < 5.6) {
                return false;
            }
            return self::$exists;
        }
{'fraction_non_alphanumeric': 0.1452293453110113, 'fraction_numerical': 0.002449979583503471, 'mean_word_length': 2.3294064340734026, 'pattern_counts': {'":': 2, '<': 9, '<?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': '203674', 'n_tokens_mistral': 2232, 'n_tokens_neox': 2230, 'n_words': 576}