Returns the type of the provided value
@param $value string the type of the value
968745
public static function getType($value)
    {
        if ($value === null) {
            return null;
        }

        $type = gettype($value);
        if (is_array($value) && !empty($value)) {
            $arrayType = null;
            foreach ($value as $entry) {
                if ($arrayType == null) {
                    $arrayType = self::getType($entry);
                } else {
                    return "mixed[]";
                }
            }
            return $arrayType . "[]";
        } elseif ($type == 'object') {
            return get_class($value);
        }

        return self::mapToBuiltInType($type);
    }
575733
protected function parseStringsToNativeTypes($value)
    {
        if (is_array($value)) {
            return array_map([$this, 'parseStringsToNativeTypes'], $value);
        }

        if (! is_string($value)) {
            return $value;
        }

        $parsedValue = json_decode($value, true);

        if (json_last_error() === JSON_ERROR_NONE) {
            return $parsedValue;
        }

        return $value;
    }
1167406
public function getPDOConstantType($value)
    {

        switch (true) {
            case is_int($value):
                $type = PDO::PARAM_INT;
                break;
            case is_bool($value):
                $type = PDO::PARAM_BOOL;
                break;
            case (null === $value):
                $type = PDO::PARAM_NULL;
                break;
            default:
                $type = PDO::PARAM_STR;
        }
        return $type;
    }
155300
public static function getValidTypeFromSample($value) {
        $value = trim((string) $value);

        if (empty($value)) {
            return false;
        }

        foreach (self::$validators as $type => $validator) {
            if ($validator === null) {
                continue;
            }

            if (method_exists(__CLASS__, $validator) && self::$validator($value)) {
                return $type;
            }
        }

        return self::__DEFAULT;
    }
562721
protected function getType(&$value)
    {
        if (is_numeric($value)) {
            $value += 0;

            if (is_int($value)) {
                return self::T_INTEGER;
            }

            return self::T_FLOAT;
        }

        switch ($value) {
            case ':':
                return self::T_COLON;
            case '\'':
            case "\xe2\x80\xb2": // prime
                return self::T_APOSTROPHE;
            case '"':
            case "\xe2\x80\xb3": // double prime
                return self::T_QUOTE;
            case ',':
                return self::T_COMMA;
            case '-':
                return self::T_MINUS;
            case '+':
                return self::T_PLUS;
            case '°':
                return self::T_DEGREE;
            case 'N':
            case 'S':
                return self::T_CARDINAL_LAT;
            case 'E':
            case 'W':
                return self::T_CARDINAL_LON;
            default:
                return self::T_NONE;
        }
    }
1311103
protected function getTypeSwapValue($type, $value)
    {
        switch (strtolower($type)) {
            case 'int':
            case 'integer':
                return (int) $value;
            case 'real':
            case 'float':
            case 'double':
                return (float) $value;
            case 'string':
                return (string) $value;
            default:
                return $value;
        }
    }
552033
protected function typecast($value)
    {
        if ($value === '' && $this->type !== Schema::TYPE_STRING) {
            return null;
        }
        if ($value === null || gettype($value) === $this->phpType || $value instanceof Expression) {
            return $value;
        }
        switch ($this->phpType) {
            case 'resource':
            case 'string':
                return is_resource($value) ? $value : (string) $value;
            case 'int':
            case 'integer':
                return (int) $value;
            case 'bool':
            case 'boolean':
                return (bool) $value;
            case 'double':
                return (double) $value;
        }

        return $value;
    }
1291720
private function inferType($value)
    {
        if (is_integer($value)) {
            return \PDO::PARAM_INT;
        }

        if (is_bool($value)) {
            return \PDO::PARAM_BOOL;
        }

        if (is_array($value)) {
            return is_integer(current($value))
                ? Connection::PARAM_INT_ARRAY
                : Connection::PARAM_STR_ARRAY;
        }

        return \PDO::PARAM_STR;
    }
1112246
protected function inferParamType($value) : int
    {
        if (is_bool($value) || is_int($value)) {
            return  \PDO::PARAM_INT;
        }

        return  \PDO::PARAM_STR;
    }
863593
protected function determineType($value)
    {
        if ($value instanceof Expression || $value instanceof ValueGenerator) {
            return self::TYPE_EXPRESSION;
        }

        switch (gettype($value)) {
            case 'boolean':
                return self::TYPE_BOOLEAN;
            case 'integer':
                return self::TYPE_INTEGER;
            case 'string':
                return self::TYPE_STRING;
            case 'double':
            case 'float':
                return self::TYPE_NUMBER;
            case 'array':
                return self::TYPE_ARRAY;
            case 'NULL':
                return self::TYPE_NULL;
            case 'object':
                return self::TYPE_OBJECT;
            default:
                return self::TYPE_OTHER;
        }
    }
821699
private function getValue($value)
    {
        if ($value === null) {
            return null;
        }

        if ($value instanceof String_ || $value instanceof LNumber || $value instanceof DNumber) {
            return $value->value;
        } elseif ($value instanceof ConstFetch) {
            $value = (string)$value->name;
            if ($value === 'null') {
                return null;
            } elseif ($value === 'true') {
                return true;
            } elseif ($value === 'false') {
                return false;
            }

            return $value;
        } elseif ($value instanceof Array_) {
            return $this->getArray($value);
        }

        return null;
    }
945563
public function typeCast($value)
    {
        if ($value === null) {
            return $value;
        }
        
        switch ($this->type) {
            case 'string':
            case 'text':
            case 'binary':
            default:
                return $value;
            case 'integer':
                return $this->valueToInteger($value);
            case 'float':
                return (float)$value;
            case 'datetime':
            case 'timestamp':
                return $this->stringToTime($value);
            case 'time':
                return $this->stringToDummyTime($value);
            case 'date':
                return $this->valueToDate($value);
            case 'boolean':
                return $this->valueToBoolean($value);
            default:
                return $value;
        }
    }
997964
protected function getTypeOf($value): string
    {
        $type = gettype($value);

        switch ($type) {
            case 'integer':
            case 'boolean':
            case 'string':
                return $type;
            case 'double':
                return 'float';
            case 'array':
                return count(array_filter(array_keys($value), 'is_string')) > 0 ? 'assoc' : 'array';
            case 'object':
                return $value instanceof Traversable ? 'array' :
                    ($value instanceof DateTime ? DateTime::class : 'object');
            default:
                return $type;
        }
    }
817381
public static function getTypeForValue($value): string
    {
        if (is_object($value)) {
            if ($value instanceof Proxy) {
                $type = get_parent_class($value);
            } else {
                $type = get_class($value);
            }
        } else {
            $type = gettype($value);
        }
        return $type;
    }
768958
public static function getQualifiedType($value)
    {
        if (is_null($value))
            return 'NULL';

        if (is_string($value))
            return 'string';
        else if (is_array($value)) {
            if (!empty ($value)) {
                foreach ($value as $val) {
                    $array_type = self::getQualifiedType($val);
                    if ($array_type != null)
                        break;
                }
                return $array_type . '[]';
            } else {
                return 'array';
            }
        } else if (is_int($value))
            return 'int';
        else if (is_bool($value))
            return 'boolean';
        else if (is_float($value))
            return 'float';
        else if (is_object($value))
            return get_class($value);
    }
118935
protected function getType($value)
    {
        if (is_object($value)) {
            return get_class($value);
        } else {
            return gettype($value) === 'double' ? 'float' : gettype($value);
        }
    }
786816
public function isValueValidType($value)
    {
        switch ($this->getType()) {
            case self::TYPE_BOOLEAN:
                $isValid = is_bool($value);
                break;
            case self::TYPE_DATE:
            case self::TYPE_DATETIME:
                $isValid = is_object($value) and get_class($value) == 'DateTime';
                break;
            case self::TYPE_NUMBER:
                $isValid = is_numeric($value);
                break;
            case self::TYPE_STRING:
                $isValid = is_string($value);
                break;
            default:
                $isValid = false;
        }

        return $isValid;
    }