code: public static function getTypeByValue($value)
      {
          if (is_int($value)) {
              return self::TYPE_INT;
          } elseif (is_string($value)) {
              return self::TYPE_QSTRING;
          } elseif (is_bool($value)) {
              return self::TYPE_BOOL;
          } elseif (self::isList($value)) {
              return self::TYPE_QVARIANT_LIST;
          } elseif (self::isMap($value)) {
              return self::TYPE_QVARIANT_MAP;
          } elseif ($value instanceof \DateTime) {
              return self::TYPE_QDATETIME;
          } else {
              throw new \InvalidArgumentException('Can not guess variant type for type "' . gettype($value) . '"');
          }
      }
docs: Tries to guess the type constant based on the data type of the given value
  
  @param mixed $value
  @return int see TYPE_* constants
  @throws \InvalidArgumentException if type can not be guessed