<commit_before><?php

	class Argument {
		var $value;
		var $name;
                var $type;

		var $isValid;
		var $errorMessage;

                var $column_operation;

                var $_value; // Caches escaped and toString value so that the parsing won't happen multiple times;

		function Argument($name, $value){
                        $this->value = $value;
			$this->name = $name;
			$this->isValid = true;
		}

                function getType(){
                    if(isset($this->type)) return $this->type;
                    if(is_string($this->value)) return 'column_name';
                    return 'number';
                }

                function setColumnType($value){
                    $this->type = $value;
                }

                function setColumnOperation($operation){
                    $this->column_operation = $operation;
                }

		function getName(){
			return $this->name;
		}

		function getValue(){
                    if(!isset($this->_value)){
			$value = $this->getEscapedValue();
			$this->_value = $this->toString($value);
                    }
                    return $this->_value;
		}

                function getColumnOperation(){
                    return $this->column_operation;
                }

                function getEscapedValue(){
                    return $this->escapeValue($this->value);
                }

		function getUnescapedValue(){
                        return $this->value;
		}

		function toString($value){
			if(is_array($value)){
                            if(count($value) === 0) return '';
                            if(count($value) === 1 && $value[0] === '') return '';
                            return '('.implode(',', $value).')';
                        }
			return $value;
		}

		function escapeValue($value){
			$column_type = $this->getType();
			if($column_type == 'column_name'){
				$dbParser = DB::getParser();
				return $dbParser->parseExpression($value);
			}
			if(!isset($value)) return null;
			
			if(in_array($column_type, array('date', 'varchar', 'char','text', 'bigtext'))){
				if(!is_array($value))
					$value = $this->_escapeStringValue ($value);
				else {
					$total = count($value);
					for($i = 0; $i < $total; $i++)
                                            $value[$i] = $this->_escapeStringValue($value[$i]);
						//$value[$i] = '\''.$value[$i].'\'';
				}
			}
			if($column_type == 'number')
				$value = (int)$value;
			
			return $value;
		}

                function _escapeStringValue($value){
                    $db = &DB::getInstance();
                    $value = $db->addQuotes($value);
                    return '\''.$value.'\'';

                }

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

		function getErrorMessage(){
			return $this->errorMessage;
		}

		function ensureDefaultValue($default_value){
			if(!isset($this->value) || $this->value == '')
				$this->value = $default_value;
		}

		function checkFilter($filter_type){
			if(isset($this->value) && $this->value != ''){
                                global $lang;
				$val = $this->value;
				$key = $this->name;<commit_msg>if value is array, type cast modify<commit_after><?php

	class Argument {
		var $value;
		var $name;
                var $type;

		var $isValid;
		var $errorMessage;

                var $column_operation;

                var $_value; // Caches escaped and toString value so that the parsing won't happen multiple times;

		function Argument($name, $value){
                        $this->value = $value;
			$this->name = $name;
			$this->isValid = true;
		}

                function getType(){
                    if(isset($this->type)) return $this->type;
                    if(is_string($this->value)) return 'column_name';
                    return 'number';
                }

                function setColumnType($value){
                    $this->type = $value;
                }

                function setColumnOperation($operation){
                    $this->column_operation = $operation;
                }

		function getName(){
			return $this->name;
		}

		function getValue(){
                    if(!isset($this->_value)){
			$value = $this->getEscapedValue();
			$this->_value = $this->toString($value);
                    }
                    return $this->_value;
		}

                function getColumnOperation(){
                    return $this->column_operation;
                }

                function getEscapedValue(){
                    return $this->escapeValue($this->value);
                }

		function getUnescapedValue(){
                        return $this->value;
		}

		function toString($value){
			if(is_array($value)){
                            if(count($value) === 0) return '';
                            if(count($value) === 1 && $value[0] === '') return '';
                            return '('.implode(',', $value).')';
                        }
			return $value;
		}

		function escapeValue($value){
			$column_type = $this->getType();
			if($column_type == 'column_name'){
				$dbParser = DB::getParser();
				return $dbParser->parseExpression($value);
			}
			if(!isset($value)) return null;
			
			if(in_array($column_type, array('date', 'varchar', 'char','text', 'bigtext'))){
				if(!is_array($value))
					$value = $this->_escapeStringValue ($value);
				else {
					$total = count($value);
					for($i = 0; $i < $total; $i++)
                                            $value[$i] = $this->_escapeStringValue($value[$i]);
						//$value[$i] = '\''.$value[$i].'\'';
				}
			}
			if($column_type == 'number')
			{
				if(is_array($value))
				{
					foreach($value AS $key=>$val)
					{
						$value[$key] = (int)$val;
					}
				}
				else
				{
					$value = (int)$value;
				}
			}
			
			return $value;
		}

                function _escapeStringValue($value){
                    $db = &DB::getInstance();
                    $value = $db->addQuotes($value);
                    return '\''.$value.'\'';

                }

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

		function getErrorMessage(){
			return $this->errorMessage;
		}

		function ensureDefaultValue($default_value){
			if(!isset($this->value) || $this->value == '')
				$this->value = $default_value;
		}

		function checkFilter($filter_type){
			if(isset($this->value) && $this->value != ''){
                                global $lang;
				$val = $this->value;
				$key = $this->name;
{'fraction_non_alphanumeric': 0.15842800122812403, 'fraction_numerical': 0.0012281240405280934, 'mean_word_length': 1.643002028397566, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 68, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5706213', 'n_tokens_mistral': 2138, 'n_tokens_neox': 1772, 'n_words': 350}