Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127771 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 lists.php.net (Postfix) with ESMTPS id 9002B1A00BC for ; Fri, 27 Jun 2025 14:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751034474; bh=9scUbWbrOqlKR9PTMRqxC+yQzGH7DSKoHzvGTejYa7A=; h=Date:From:To:In-Reply-To:References:Subject:From; b=Wgr3G5BeMJG5WbIPF0BjAv1J7jo4YGGupHYrpe89wjq+qm3M+Cd4NOZYkCl1aURpv igVFEgPMJ12J2OQ1rfuCOO+4zEfWD26D8GS4FtVq4uJfUzv9WyIkJKaaCmyEyyolM9 f5i7Dw4sf7L32O1JFWMyLQNEgg++aW5xi3V2/8Uk4HM0cRAvsAoASdouizaHB/KUXL F/gAsijaXgEBjZHQxN7X+GdApip9C/sgsJK25XWWKSjFg+OCGTw48RaRXDCj0S9S4x SqkiQnw9NVy6ZrOW03CMFojUs31mtrAW2fhAf9gMdlGln0b9H0FxlIQgenFEEn/GrX 6UmXEnSsh3SEw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D0FA218006C for ; Fri, 27 Jun 2025 14:27:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fout-b4-smtp.messagingengine.com (fout-b4-smtp.messagingengine.com [202.12.124.147]) (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 ; Fri, 27 Jun 2025 14:27:53 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id E6F161D000E1 for ; Fri, 27 Jun 2025 10:29:47 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Fri, 27 Jun 2025 10:29:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm2; t=1751034587; x=1751120987; bh=ajKTdDtkl3wo9n5dSug+z qgdj2m3rf20XDZ6eFDX+po=; b=Gs+uE+jRsP0utjegDTKZUkUxVsW1VKYyhBTCd rbfgYjYiCVnDtT+b61hFKANRtAzgBjCJxcDoiwALmPF7DQE8H6q4WhAow5h2ZcOP y5cu9OZtHirl+H9Xw3GK5NomQGISyZtIaWCFfqODU81fe7TikJnMjUK/edYGZtGX IeVXuH28cnLksRFZ/4ZHBbtHitRJPuziHMGhTSbnejXZPn956KlKON6NghG2zO5T L90My0dh25JZq535rVBU/2IOLyC+nveQLhR032bsDMCvk/fxDCEfm+UIFa/vFi5t kTUNYSi9S/nvyBAgGs1DssvzD72fjxTI/57Q8Eafbz5Q1rrcw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1751034587; x=1751120987; bh=a jKTdDtkl3wo9n5dSug+zqgdj2m3rf20XDZ6eFDX+po=; b=PnZuVwd5Y5hBpUua4 Mbv7muT3kaPZuXF9BeTngV7bmQ25QccbR4STprpeqTWWimV9XAbeoo5Vc2GbzJ1N Y/jF4vUdfuTKTzLKG1r5XPtO2ron7cb72p4uPtlssv2ptigpp2wzODsR80l3eDcB uSDVhHirw+Qmm+QBSCLHBUdf7kCzNs1HcTmTAruY5IR6GYR+C89WaU4IFf1MwZ7J /br3QuGSc0nNGl7j6cKFyhGgZ/DDhHMSuWIU13PCBzNALKnVGETtsPyfRBXy/tRY I0jiOj4ih0z2p30pAVUUyUTs7uX0/YqtuQ22jL7bl2MyeMOAj3Aek59vdWMp15Kq 810lw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdeffedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhihucfi rghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqeenuc ggtffrrghtthgvrhhnpeffudetleeuudetkeeiudfghfetveeitdevfeejudefgfffiedu jeegudehveejheenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhsvghlugdrsggvne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhr hiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvg epshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhp rdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 3B0A4700063; Fri, 27 Jun 2025 10:29:47 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T6541924c602fb011 Date: Fri, 27 Jun 2025 09:29:27 -0500 To: "php internals" Message-ID: In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Object-oriented curl API v2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Fri, Jun 27, 2025, at 8:01 AM, Deleu wrote: > On Fri, Jun 27, 2025 at 9:24=E2=80=AFAM Jordi Boggiano wrote: >> On 26.06.2025 18:25, Eric Norris wrote: >> > - uses enumerations for curl options and other curl constants >>=20 >> Overall I think the RFC is a good opportunity to clean up a few legac= y=20 >> oddities in the curl API, but I need to throw in my 2c about enum usa= ge=20 >> here, as someone that has actually implemented some complexish=20 >> curl-based client [1]. >>=20 >> Currently the API is: >>=20 >> curl_setopt($h, CURLOPT_SMTH, 3); >>=20 >> Now moving this into multiple enums to me brings one major issue, tha= t I=20 >> first have to think about which type the option has to then know on=20 >> which enum I find it. >>=20 >> I understand this brings type safety on the value side if you have=20 >> multiple setOptionInt etc, but that does not seem worth the trade-off= to=20 >> me. Type safety can already be done in static analyzers as they can s= ee=20 >> which option you pass in, they know which value should be allowed. >>=20 >> Then on top of that, assuming we'd put all options in one enum.. I am=20 >> still wondering what the added value is compared to simply having the=20 >> global constants (they could be namespaced if anything...). It's long= er=20 >> to type, and does not provide any better autocompletion.=20 >> \Curl\Option::ConnectTimeout vs CURLOPT_CONNECT_TIMEOUT sounds ok to = me=20 >> if people feel strongly pro-enum, but I do really hope it is then a=20 >> single enum + setOption() call. >>=20 >> Best, >> Jordi >>=20 >> [1]=20 >> https://github.com/composer/composer/blob/main/src/Composer/Util/Http= /CurlDownloader.php >>=20 >> Jordi Boggiano >> @seldaek - https://seld.be > > Reading this I can't help but feel like there's some cognitive bias=20 > *because* you have written a Curl class yourself. The author of a PHP=20 > Class that wraps Curl needs to know about every option and how to=20 > translate them back-and-forth, which is really the insight I take from=20 > your message. As a PHP developer making HTTP requests, I would never=20 > have guessed 270 options for Curl configurations and having them split=20 > into multiple Enums gives me smaller "boxes" that are easier to=20 > mentally parse individually. With that said, splitting enumerations by=20 > type rather than context does weaken the argument of split enums. I=20 > wouldn't be instinctively looking for "what enum do I need that is an=20 > int?" or "what enum do I need that is a string?" unless I already know=20 > the implementation details by heart. The Info and Pause enumerations=20 > seem more useful in that regard as they reduce the scope in which I=20 > need to understand, process and decide.=20 I will agree here. Splitting enums by type doesn't add much value. Spl= itting them by topic might, if the topics are sufficiently distinct that= a separate method makes sense. I don't know Curl's API well enough to = make specific recommendations there. --Larry Garfield