Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122408 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 1D4671ADFA3 for ; Sat, 17 Feb 2024 13:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1708174824; bh=776cnvvZzPVUdsV8zgk1JExm4XFNCpNIOCKIKd+pvr8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HpH0IdtXQ71YMxU3kll+HuBpTWQLthkZeRSjoPgQWyMxc+a9tX4Aj5/dJuh9eQEzt 0+qmvxFVbcYhtG3JzEhEpLzOZ3khSPEe6ibxDeUezophSbJMaT0YCdtazAnFT04YBn wz6aCIfUoMWb+waN/U+Gu8zPHJtZ87vJEYlme1sYKgpsrtoUEwV52y7MwSD2hLa+sE FM/tDjejhKSPTSLOa6IpyrnDit+3pc07OneH+VKtkfWSk7+kDINJd3Vc1oswIYE3kC Y6nHgT7j/EIhCKU/GIrun9h262jnTu8TPzwhksGSNkUXbBTYYASGemvjS2A5BFBb/X 9EgJlyPu9MCFw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C25381806B4 for ; Sat, 17 Feb 2024 05:00:23 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: ** X-Spam-Status: No, score=2.6 required=5.0 tests=BAYES_50,DATE_IN_PAST_03_06, DMARC_MISSING,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 17 Feb 2024 05:00:23 -0800 (PST) Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-21e2673a206so1946374fac.2 for ; Sat, 17 Feb 2024 05:00:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708174820; x=1708779620; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1TOJp8d/wjPvzIdXPHNSpKU980GqL4hnihmRLI0Hax8=; b=hQdf79gY6vS4ofbk3V+ZgJBvklZczqZY6sQFZc6ePURWddgVADC6nl+0SQ4plb6HPK OeL+D8Ppj7gB9+ER005vR7Da6PPbRg5ENW6gNiw5pAgrwykCP5wGcE8k7oGbMAHxOFKC ABl3uHra6XXfcAGeUBeFt0f/r19LV1Yc65wRqLV1UfwBYjK8MpiT4mrvW24SkKqXM9lz mizE1VQR1Zapxv2h7uNUzXqS3/XvXC2WBTKx7xH8GnGK+BaI0I9IcufaG8DudsnX8i5n 1DCw+avBvLzyn3nBIsFmLK7tclJGnYevA0Y9Nmiu5tpM9etxwuR0XhUv27+0sGKEI6Sm 3GpA== X-Gm-Message-State: AOJu0YwdEGeQU9k9es05TReBIO7PNjd+Yhezsa0vZU0moWvgPVqJbzIP jgKfqVy76fJk8QRVW/scNyEmcT4+sZOGgLLc3gck9Pcymlpr1gbBDMJ1jHNQdwA2Z1Jk+T5lwC5 u5KQhoIQUVqz6rPzCeTLIpV5pO7d+MpyQ X-Google-Smtp-Source: AGHT+IERDr2ZlcE1Q6IxDk8WGPZMSitv22MMrVXRKbhcgY2HEsTEo/5NS0kTuP7EiVviHE1DyeFo+zrQ1i+vh6GW0oY= X-Received: by 2002:a05:6870:9725:b0:21e:8e42:846e with SMTP id n37-20020a056870972500b0021e8e42846emr1087987oaq.26.1708155709951; Fri, 16 Feb 2024 23:41:49 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 17 Feb 2024 09:41:40 +0200 Message-ID: Subject: Re: [PHP-DEV] Re: [RFC] OOP API for cURL extension To: Sara Golemon Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: kalle@php.net (Kalle Sommer Nielsen) Hi Sara Den tors. 15. feb. 2024 kl. 21.08 skrev Sara Golemon : > * Better typing for setOpt() methods. > Comment: Yep, this is a good and fair point. It's going to take a litt= le more dicing up of the current implementation, but hopefully not too roug= h. > Proposal: Keep untyped setOption() method (1/ Easier migration of exist= ing code, 2/ Some options may prove difficult to type), but add: > * CurlHandle::setOptionBool(int $option, bool $value): CurlHandle > * CurlHandle::setOptionInt(int $option, int $value): CurlHandle > * CurlHandle::setOptionString(int $option, string $value): CurlHandle > * etc... as needed, will this get weird when we get to Array since ther= e IS a setOptArray? Maybe we just don't mirror that one, or we call it set= OptionMany(). Yeah, I like Many for the multiple option set, and Array for = the single option of array type. > Internally, the setopt handler will be split by type so that each typed= setting can call explicitly, and the untyped one can call all. What about making the CURL options an enumeration? It would allow us to typehint the setOptions() method and we can also make it backwards compatible with the existing global constants: ```php public function setOption(CurlOption|int $option, mixed $value): static { if (is_int($option)) { $option =3D CurlOption::createFromConstant($option); } // ... } ``` The enumeration would then have a static method to transform the global constant into a native type (which we can do internally). Naming is obvious just TBD. The biggest potential issue I can see with this approach is the many conditionally defined constants from older CURL versions/feature flags from compile time. From the many type variants of setOptions(), I am uncertain about that, because with an enumeration, we would still need to have some sort of whitelisting of what options can be passed into the method. --=20 regards, Kalle Sommer Nielsen kalle@php.net