public static bool curl_setopt_array(
            [ImportValue(ImportValueAttribute.ValueSpec.CallerClass)] RuntimeTypeHandle callerCtx,
            CURLResource ch, PhpArray options)
        {
            if (ch == null || !ch.IsValid)
            {
                PhpException.ArgumentNull(nameof(ch));
                return(false);
            }

            if (options != null)
            {
                var enumerator = options.GetFastEnumerator();
                while (enumerator.MoveNext())
                {
                    var key = enumerator.CurrentKey;

                    if (key.IsInteger && ch.TrySetOption(key.Integer, enumerator.CurrentValue, callerCtx))
                    {
                        // ok
                        continue;
                    }
                    else
                    {
                        // stop on first fail and return FALSE
                        return(false);
                    }
                }
            }

            return(true);
        }
        /// <summary>
        /// Set multiple options for a cURL transfer.
        /// </summary>
        public static bool curl_setopt_array(CURLResource ch, PhpArray options)
        {
            if (ch == null || !ch.IsValid)
            {
                return(false);
            }

            if (options != null)
            {
                var enumerator = options.GetFastEnumerator();
                while (enumerator.MoveNext())
                {
                    if (!enumerator.CurrentKey.IsInteger ||
                        !ch.TrySetOption(enumerator.CurrentKey.Integer, enumerator.CurrentValue))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
 public static bool curl_setopt(
     [ImportValue(ImportValueAttribute.ValueSpec.CallerClass)] RuntimeTypeHandle callerCtx,
     CURLResource ch, int option, PhpValue value)
 {
     return(ch.TrySetOption(option, value, callerCtx));
 }
 /// <summary>
 /// Sets an option on the given cURL session handle.
 /// </summary>
 public static bool curl_setopt(CURLResource ch, int option, PhpValue value) => ch.TrySetOption(option, value);