<commit_before><?php

class User{

    //session key
    private static $LOGIN = '_login_';
    private static $USER_ID = '_user_id';
    //cookie key
    private static $AUTO_LOGIN = '_auto_login';

    private $session;
    private $cookie;
    public $is_login = false;
    public $user_id = null;

    private $login_functions = [];
    private $logout_functions = [];

    function __construct($session, $cookie, $check_user_id, $auto_login){
        $this->session = $session;
        $this->cookie = $cookie;
        $tmp = $this->session->get(self::$LOGIN, false) ? $this->session->get(self::$USER_ID, false) : false;
        if($tmp !== false && $check_user_id($tmp)){
            $this->is_login = true;
            $this->user_id = $tmp;
        }else{
            $this->is_login = false;
            $key = $this->cookie->get(self::$AUTO_LOGIN);
            if($key !== null){
                $id = $auto_login($key);
                if($id !== null){
                    $this->login($id);
                }
            }
        }
    }

    function add_function_login($function){
        $this->login_functions[] = $function;
    }

    function add_function_logout($function){
        $this->logout_functions[] = $function;
    }

    function login($user_id){
        $this->session->set(self::$LOGIN, true);
        $this->session->set(self::$USER_ID, $user_id);
        $this->is_login = true;
        $this->user_id = $user_id;
        $this->session->regenerate();
        foreach($this->login_functions as $function){
            $function();
        }
    }

    function logout(){
        $this->session->set(self::$LOGIN, false);
        $this->session->regenerate();
        $this->is_login = false;
        $this->user_id = $user_id;
        $this->cookie->remove(self::$AUTO_LOGIN);
        foreach($this->logout_functions as $function){
            $function();
        }
    }

    function enable_auto_login(){
        if($this->is_login){
            $this->cookie->set(self::$AUTO_LOGIN, $this->create_auto_login_key());
        }
    }

    function is_login(){
        return $this->is_login;
    }

}
<commit_msg>fix the bug undefined variable<commit_after><?php

class User{

    //session key
    private static $LOGIN = '_login_';
    private static $USER_ID = '_user_id';
    //cookie key
    private static $AUTO_LOGIN = '_auto_login';

    private $session;
    private $cookie;
    public $is_login = false;
    public $user_id = null;

    private $login_functions = [];
    private $logout_functions = [];

    function __construct($session, $cookie, $check_user_id, $auto_login){
        $this->session = $session;
        $this->cookie = $cookie;
        $tmp = $this->session->get(self::$LOGIN, false) ? $this->session->get(self::$USER_ID, false) : false;
        if($tmp !== false && $check_user_id($tmp)){
            $this->is_login = true;
            $this->user_id = $tmp;
        }else{
            $this->is_login = false;
            $key = $this->cookie->get(self::$AUTO_LOGIN);
            if($key !== null){
                $id = $auto_login($key);
                if($id !== null){
                    $this->login($id);
                }
            }
        }
    }

    function add_function_login($function){
        $this->login_functions[] = $function;
    }

    function add_function_logout($function){
        $this->logout_functions[] = $function;
    }

    function login($user_id){
        $this->session->set(self::$LOGIN, true);
        $this->session->set(self::$USER_ID, $user_id);
        $this->is_login = true;
        $this->user_id = $user_id;
        $this->session->regenerate();
        foreach($this->login_functions as $function){
            $function();
        }
    }

    function logout(){
        $this->session->set(self::$LOGIN, false);
        $this->session->regenerate();
        $this->is_login = false;
        $this->user_id = null;
        $this->cookie->remove(self::$AUTO_LOGIN);
        foreach($this->logout_functions as $function){
            $function();
        }
    }

    function enable_auto_login(){
        if($this->is_login){
            $this->cookie->set(self::$AUTO_LOGIN, $this->create_auto_login_key());
        }
    }

    function is_login(){
        return $this->is_login;
    }

}

{'fraction_non_alphanumeric': 0.16292004634994206, 'fraction_numerical': 0.0, 'mean_word_length': 2.138909090909091, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 77, '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': '3531562', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1337, 'n_words': 230}