@param mixed $value
@param int   $type

@return mixed
@throws Exception
18480
public function processEscaped($value, $type = CorePDO::PARAM_STR)
    {
        if (!in_array($type, [CorePDO::PARAM_STR, CorePDO::PARAM_LOB])) {
            return $this->process($value, $type);
        }

        return $this->stringEscaped($value);
    }
17158
public function acceptNext(int $type, $value = null) : bool
    {
        if ($this->getNextToken()->getType() === $type) {
            if ($value) {
                if ($this->getNextToken()->getValue() === $value) {
                    return true;
                }

                return false;
            }

            return true;
        }

        return false;
    }
1031501
public function handleTypeConversion($type, $value)
    {
        switch ($type):
            case PropertyTypeEnum::STRING:
                $value = (string) $value;
                break;
            case PropertyTypeEnum::BOOLEAN:
                $value = (boolean) $value;
                break;
            case PropertyTypeEnum::INTEGER:
                $value = (integer) $value;
                break;
            case PropertyTypeEnum::DATETIME;
                $value = new \DateTime($value);
                break;
        endswitch;

        return $value;
    }
457139
public function expect($type, $value = null)
    {
        if (!$this->match($type, $value)) {
            $msg = "Unexpected token {$this->current()->type} '{$this->current()->value}', expected {$type}";
            throw new \UnexpectedValueException($msg);
        }
        $current = $this->current();
        $this->next();
        return $current;
    }
179810
public function set($type, $value) {
        switch ($type) {
            case self::CMD:
                $this->cmd = $value;
                break;
            case self::ENV:
                $this->env = $value;
                break;
            case self::CWD:
                $this->cwd = $value;
                break;
            case self::TYPE:
                if ($value == self::PIPE)
                    $this->descriptor_spec = [['pipe', 'r'], ['pipe', 'w']];
                elseif ($value == self::PTY)
                    //To execute command in pty, PHP_CAN_DO_PTS must be enabled before PHP compile.
                    //See ext/standard/proc_open.c in PHP source directory.
                    $this->descriptor_spec = [['pty'], ['pty']];
                break;
            case self::ON_MESSAGE:
                $this->onMessage = $value;
                break;
            case self::ON_CLOSE:
                $this->onClose = $value;
                break;
            default:
                throw new \Exception("Invalid option.");
        }
        return $this;
    }
209038
public static function cast( $value, $phpType ) {
		if( $phpType === null or $value === null ) return $value;
		
		switch( $phpType ) {
		case 'string': return (string)$value;
		case 'float': return (float)$value;
		case 'int': return (int)$value;
		case 'bool':
			if( is_bool($value) ) return $value;
			if( is_numeric($value) ) {
				if( $value == 1 ) return true;
				if( $value == 0 ) return false;
			}
			if( is_string($value) ) {
				if( in_array($value, array('yes','true','on')) ) return true;
				if( in_array($value, array('no','false','off','')) ) return false;
			}
			throw new Exception("Invalid boolean representation: ".var_export($value,true));
		default:
			throw new Exception("Don't know how to cast to PHP type '$phpType'.");
		}
	}
29906
protected function convert($value, int $type)
    {
        switch ($type) {
            case FieldsInterface::TYPE_INT:
                $result = (int)$value;
                break;
            case FieldsInterface::TYPE_FLOAT:
                $result = (float)$value;
                break;
            case FieldsInterface::TYPE_BOOL:
                $result = is_numeric($value) ? (bool)$value : $value === 't';
                break;
            case FieldsInterface::TYPE_DATE:
                $result = strtotime($value);
                break;
            case FieldsInterface::TYPE_UNIXTIME:
                $result = new \DateTime();
                $result->setTimestamp((int)$value);
                break;
            case FieldsInterface::TYPE_STRING:
                $result = $value ?? '';
                break;
            case FieldsInterface::TYPE_ARRAY:
            default:
                $result = $value;
        }

        return $result;
    }
1018801
public function bind($param, $value, $type = null)
    {
        if (is_null($type)) {
            switch (true) {
                case is_int($value):
                    $type = PDO::PARAM_INT;
                    break;
                case is_bool($value):
                    $type = PDO::PARAM_BOOL;
                    break;
                case is_null($value):
                    $type = PDO::PARAM_NULL;
                    break;
                default:
                    $type = PDO::PARAM_STR;
            }
        }
        //then run PDO bindValue on the statement to bind the values
        self::$statement->bindValue($param, $value, $type);
    }
723219
public function skip(int $type, $value = null) : bool
    {
        if ($this->accept($type, $value)) {
            $this->advance();

            return true;
        }

        return false;
    }
243132
public function convertToPHPValue($value, PlatformInterface $platform)
    {
        if ($value === null) {
            return;
        }

        $val = @unserialize($value);

        if ($val === false) {
            throw TypeException::conversionToPHPFailed($value, $this->getName());
        }

        return $val;
    }
59965
public function setValue($value, $type = null)
    {
        $this->value = $value;
        $this->type  = $type ?: ParameterTypeInferer::inferType($value);
    }
898082
public function bindValue($parameter, $value, $type = \PDO::PARAM_STR)
    {
        $this->bindedValues[$parameter] = $value;

        return $this->bindParam($parameter, $this->bindedValues[$parameter], $type);
    }
408190
public function equals($type, $value = null)
    {
        return $this->is($type) && $value === $this->value;
    }
445009
public static function isTypeOf($value, $type) {
        switch ($type) {
            case self::ARGUMENT_ARRAY:
                ArrayHelper::isArray($value);
                break;
            case self::ARGUMENT_BOOLEAN:
                BooleanHelper::isBoolean($value);
                break;
            case self::ARGUMENT_DATE:
                DateTimeHelper::isDate($value);
                break;
            case self::ARGUMENT_DOUBLE:
                DoubleHelper::isDouble($value);
                break;
            case self::ARGUMENT_FLOAT:
                FloatHelper::isFloat($value);
                break;
            case self::ARGUMENT_INTEGER:
                IntegerHelper::isInteger($value);
                break;
            case self::ARGUMENT_NUMBER:
                NumberHelper::isNumber($value);
                break;
            case self::ARGUMENT_OBJECT:
                ObjectHelper::isObject($value);
                break;
            case self::ARGUMENT_RESOURCE:
                ResourceHelper::isResource($value);
                break;
            case self::ARGUMENT_STRING:
                StringHelper::isString($value);
                break;
            case self::ARGUMENT_TIMESTAMP:
                TimestampHelper::isTimestamp($value);
                break;
            default:
                throw new IllegalArgumentException("The type \"" . $type . "\" is not implemented");
        }
        return true;
    }
1178220
public static function run($value, string $type = null)
    {
        switch ($type) {
            case 'int':
                $regexp = self::compileRegexp(self::INT);
                break;
            case 'float':
                $regexp = self::compileRegexp(self::FLOAT);
                break;
            case 'text':
                $value = self::fixQuotes($value);
                $regexp = self::compileRegexp(self::CHARS_RUS . self::CHARS_ENG);
                break;
            default:
                $value = self::fixQuotes($value);
                $regexp = self::compileRegexp(
                    self::CHARS_RUS . self::CHARS_ENG . self::FLOAT .
                    '—~`@%[]/:<>;?&()_!$^-+=' . self::SUPER
                );
                break;
        }

        return preg_replace($regexp, '', $value);
    }
810149
protected function castToType($value, $type)
    {
        switch ($type) {
            case self::TYPE_CAST_INT:
                $newValue = filter_var($value, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
                $value    = (null === $newValue) ? $value : $newValue;
                break;
            case self::TYPE_CAST_BOOL:
                $newValue = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
                $value    = (null === $newValue) ? $value : $newValue;
                break;
            case self::TYPE_CAST_FLOAT:
                $newValue = filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE);
                $value    = (null === $newValue) ? $value : $newValue;
                break;
        }

        return $value;
    }
787295
protected function convert ($type, $value)
		{
			switch ($type)
			{
				case 'string':
					return (string) $value;

				case 'number':
					return is_float($value)
						? (float) $value
						: (int) $value;

				case 'boolean':
					return $value === true || $value === 'true' || $value === '1' || $value === 'on';

				default:
					if (is_float($value))
					{
						return $this->convert('number', $value);
					}
					if (is_numeric($value))
					{
						return strpos($value, '.') !== FALSE
							? (float) $value
							: (int) $value;
					}
					if ($value === 'true' || $value === 'false')
					{
						return $value === 'true';
					}
					if ($value === '')
					{
						return null;
					}
			}
			return $value;
		}