Try to get type of a value

@param mixed $value A value needed to guess type

@return string Possible type of a value
428445
static function guessType($value)
    {
        $map = array(
            "float"=>"number",
            "double"=>"number",
            "int"=>"number",
            "integer"=>"number",
            "bool"=>"number",
            "numeric"=>"number",
            "string"=>"string",
        );

        $type = strtolower(gettype($value));
        foreach ($map as $key=>$value) {
            if (strpos($type, $key)!==false) {
                return $value;
            }
        }
        return "unknown";
    }
1099161
private function getPdoType($value): int
    {
        if (is_int($value) === true) {
            $type = PDO::PARAM_INT;
        } elseif (is_bool($value)) {
            $type = PDO::PARAM_BOOL;
        } elseif ($value instanceof DateTimeInterface) {
            $type = PDO::PARAM_STR;
        } else {
            assert(
                $value !== null,
                'It seems you are trying to use `null` with =, >, <, or etc operator. ' .
                'Use `is null` or `not null` instead.'
            );
            assert(is_string($value), "Only strings, booleans and integers are supported.");
            $type = PDO::PARAM_STR;
        }

        return $type;
    }
921309
private static function getTypeStyle($value)
    {
        if (\is_int($value) || \is_float($value)) {
            return 'number';
        } elseif (\is_string($value)) {
            return 'string';
        } elseif (\is_bool($value) || \is_null($value)) {
            return 'bool';
        } else {
            return 'strong'; // @codeCoverageIgnore
        }
    }
719103
protected function checkType($value, $types): ?string
    {
        $type = gettype($value);

        return in_array($type, $types) ? $type : null;
    }
115260
protected function _getType($value)
    {
        if (is_object($value)) {
            try {
                return self::getShortClassname($value);
            } catch (\InvalidArgumentException $e) {
                return null;
            }
        }

        if (is_array($value)) {
            return 'array';
        }

        return 'scalar';
    }
499048
public function getTypeOf($value)
    {
        foreach ($this->getPossibleTypes() as $type) {
            if ($isTypeOf = $type->isTypeOf($value)) {
                return $type;
            }

            if (!isset($isTypeOf)) {
                throw new \Exception(sprintf(
                    'Non-Object Type %s does not implement resolveType and Object ' .
                    'Type %s does not implement isTypeOf. There is no way to ' .
                    'determine if a value is of this type.', $this->getName(), $type->getName()
                ));
            }
        }

        return NULL;
    }
32136
protected function checkType($value)
    {
        if ($value === null) {
            return $value;
        }

        Type::force($value, 'numeric', true);
        return $value === null ? $value : (float)$value;
    }
428391
private function getTypedValue(string $value)
    {
        if (\in_array($value, self::$boolValues, true)) {
            return \in_array($value, self::$truthlyValues, true);
        }

        if (\is_numeric($value)) {
            return $this->getNumericValue($value);
        }

        return $value;
    }
541023
protected function resolveTypeDescription($value): string
    {
        $type = gettype($value);

        if ($type === 'object') {
            return 'an instance of ' . get_class($value);
        }

        if ($type === 'integer') {
            return 'an integer';
        }

        return 'a ' . $type;
    }
930575
public static function getTypeFromValue($value)
    {
        switch (gettype($value)) {
            case 'boolean':
                if ($value) {
                    return Type::getTrue();
                }

                return Type::getFalse();

            case 'integer':
                return Type::getInt(false, $value);

            case 'double':
                return Type::getFloat($value);

            case 'string':
                return Type::getString($value);

            case 'array':
                return Type::getArray();

            case 'NULL':
                return Type::getNull();

            default:
                return Type::getMixed();
        }
    }
100398
protected function determineType($type, $value)
    {
        foreach ((array) $type as $t) {
            if ($t == 'string' && (is_string($value) || (is_object($value) && method_exists($value, '__toString')))) {
                return 'string';
            } elseif ($t == 'object' && (is_array($value) || is_object($value))) {
                return 'object';
            } elseif ($t == 'array' && is_array($value)) {
                return 'array';
            } elseif ($t == 'integer' && is_integer($value)) {
                return 'integer';
            } elseif ($t == 'boolean' && is_bool($value)) {
                return 'boolean';
            } elseif ($t == 'number' && is_numeric($value)) {
                return 'number';
            } elseif ($t == 'numeric' && is_numeric($value)) {
                return 'numeric';
            } elseif ($t == 'null' && !$value) {
                return 'null';
            } elseif ($t == 'any') {
                return 'any';
            }
        }

        return false;
    }
526705
public static function getType($value)
    {
        if (preg_match(self::REGEXP_TCP, $value)) {
            return self::TYPE_TCP;
        }

        if (preg_match(self::REGEXP_SSL, $value)) {
            return self::TYPE_SSL;
        }

        if (preg_match(self::REGEXP_UNIX, $value)) {
            return self::TYPE_UNIX;
        }

        return null;
    }
860535
protected function getType(&$value)
    {
        switch (true) {
            // Punctuation
            case ($value[0] === ','):
                $type = self::T_COMMA;
                break;

            // Recognize numeric values
            case (is_numeric($value)):
                if (strpos($value, '.') !== false || stripos($value, 'e') !== false) {
                    $value = (float)$value;
                    $type = self::T_FLOAT;
                    break;
                }

                $value = (int)$value;
                $type = self::T_INTEGER;
                break;

            // Recognize quoted strings
            case ($value[0] === '"'):
                $value = str_replace('""', '"', substr($value, 1, strlen($value) - 2));

                $type = self::T_STRING;
                break;
            case ($value[0] === "'"):
                $value = str_replace("''", "'", substr($value, 1, strlen($value) - 2));

                $type = self::T_STRING;
                break;

            case (preg_match('/[a-z_][a-z0-9_]*/i', $value)):
                $type = self::T_INPUT_PARAMETER;
                break;

            // Comparison operator
            case ($value === '='):
                $type = self::T_EQUALS;
                break;
            case ($value === '≠'):
            case ($value === '!='):
                $value = '≠';
                $type = self::T_NOT_EQUALS;
                break;
            case ($value === '>'):
                $type = self::T_GREATER_THAN;
                break;
            case ($value === '>='):
            case ($value === '≥'):
                $value = '≥';
                $type = self::T_GREATER_THAN_EQUALS;
                break;
            case ($value === '<'):
                $type = self::T_LOWER_THAN;
                break;
            case ($value === '<='):
            case ($value === '≤'):
                $value = '≤';
                $type = self::T_LOWER_THAN_EQUALS;
                break;

            // Composite operator
            case ($value === '&'):
                $type = self::T_AND;
                break;
            case ($value === '!&'):
                $type = self::T_NOT_AND;
                break;
            case ($value === '|'):
                $type = self::T_OR;
                break;
            case ($value === '!|'):
                $type = self::T_NOT_OR;
                break;
            case ($value === '^|'):
            case ($value === '⊕'):
                $value = '⊕';
                $type = self::T_XOR;
                break;

            // Brace
            case ($value === '('):
                $type = self::T_OPEN_PARENTHESIS;
                break;
            case ($value === ')'):
                $type = self::T_CLOSE_PARENTHESIS;
                break;
            case ($value === '['):
                $type = self::T_OPEN_SQUARE_BRACKET;
                break;
            case ($value === '!['):
                $type = self::T_NOT_OPEN_SQUARE_BRACKET;
                break;
            case ($value === ']'):
                $type = self::T_CLOSE_SQUARE_BRACKET;
                break;
            case ($value === '{{'):
                $type = self::T_DOUBLE_OPEN_CURLY_BRACKET;
                break;
            case ($value === '!{{'):
                $type = self::T_NOT_DOUBLE_OPEN_CURLY_BRACKET;
                break;
            case ($value === '}}'):
                $type = self::T_DOUBLE_CLOSE_CURLY_BRACKET;
                break;

            // Default
            default:
                throw new UnknownTokenTypeException($value);
        }

        return $type;
    }
703614
protected static function GetTypeStr( $value ) : string
   {

      if ( \is_null( $value ) )
      {
         return 'NULL';
      }

      if ( \is_resource( $value ) )
      {
         return \get_resource_type( $value ) . '-Resource';
      }

      if ( \is_string( $value ) )
      {
         if ( \strlen( $value ) > 128 )
         {
            return 'string with value (' . \substr( $value, 0, 126 ) . '…)';
         }
         return 'string with value (' . $value . ')';
      }

      if ( \is_bool( $value ) )
      {
         return 'boolean with value (' . ( $value ? 'true' : 'false' ) . ')';
      }

      if ( \is_int( $value ) )
      {
         return 'integer with value (' . $value . ')';
      }

      if ( \is_float( $value ) )
      {
         return 'float with value (' . $value . ')';
      }

      if ( \is_double( $value ) )
      {
         return 'double with value (' . $value . ')';
      }

      if ( \is_array( $value ) )
      {
         return 'Array: ' . \json_encode( $value );
      }

      if ( \is_object( $value ) )
      {
         return \get_class( $value ) . ' object: ' . \json_encode( $value );
      }

      return \gettype( $value );

   }
1189592
public static function getType($value)
    {
        if (is_int($value)) {
            return MDataType::INT;
        }

        if (is_long($value)) {
            return MDataType::LONG;
        }

        if (is_bool($value)) {
            return MDataType::BOOLEAN;
        }

        if (is_float($value)) {
            return MDataType::FLOAT;
        }

        if (is_double($value)) {
            return MDataType::DOUBLE;
        }

        if (is_string($value)) {
            return MDataType::STRING;
        }

        if ($value == null) {
            return MDataType::NULL;
        }

        if (is_array($value)) {
            return MDataType::__ARRAY;
        }

        if (is_object($value)) {
            return MDataType::OBJECT;
        }

        if (is_resource($value)) {
            return MDataType::RESOURCE;
        }

        return MDataType::UNKNOWN;
    }
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;
    }
239392
public function getTypeFromValue($value = null)
    {
        $value = ($value == null ? $this->value : $value);
        return array_search($this->value, self::$statusList);
    }