class Sorbet::Private::Serialize

def from_method(method)

def from_method(method)
  uniq = 0
  method.parameters.map.with_index do |(kind, name), index|
    if !name
      arg_name = method.name.to_s[0...-1]
      if (!KEYWORDS.include?(arg_name.to_sym)) && method.name.to_s.end_with?('=') && arg_name =~ /\A[a-z_][a-z0-9A-Z_]*\Z/ && index == 0
        name = arg_name
      else
        name = 'arg' + (uniq == 0 ? '' : uniq.to_s)
        uniq += 1
      end
    end
    # Sanitize parameter names that are not valid.
    # Ruby 2.7+ argument forwarding works by expanding `foo(...)`
    # to `foo(**, ****, &&)`, in other words, to a rest parameter named
    # `*`, a keyword rest parameter named `**` and a block argument named
    # `&`. Those are all illegal parameter names which we should NOT
    # generate. (Coincidentally, that is why Ruby 2.7+ uses those names,
    # so that user code cannot mess with the forwarded arguments)
    if ["*", "**", "&"].include?(name.to_s)
      name = 'arg' + (uniq == 0 ? '' : uniq.to_s)
      uniq += 1
    end
    [kind, name]
  end
end