Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118087 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40314 invoked from network); 24 Jun 2022 13:46:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Jun 2022 13:46:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 23F1C180545 for ; Fri, 24 Jun 2022 08:36:56 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, 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=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 24 Jun 2022 08:36:55 -0700 (PDT) Received: by mail-pg1-f178.google.com with SMTP id a14so2727443pgh.11 for ; Fri, 24 Jun 2022 08:36:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=kQ3Q5NyE4nwKcA9rsP4Lm4aXSwHzE8IUbtcZFXCKdps=; b=Z+cHfH4ARJrmkroUo6xbvm5sHXYjhRo5Ife0sOTZWFtcyiT7FY/XhNWvZFrCAoyUDP Omhd4J7/FRHTiJ4lPRz2TlvHX6m+2gGRjjYy8mnXgSbUPA3F+O6uyXQxdClaRPIPtzLv OABixzY7R3hK7jARsy4vZOh7P6EWK9X1cZT4PFG32wyjZGJVew8aijrHbHVKiYLQmcTT a/HCeAQfE9R1CClqyBhg0Ns6P01y1Jg/AKBTz6LIUZZMWeWJloSoqoApnZ0ivFvFwpM+ pGUwa1iIDsG57IeiMqKRV9V1gzjjfrEdByhIBp30AJzYs//3dPurn34Zh+WBhnqL/7Lm u/Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=kQ3Q5NyE4nwKcA9rsP4Lm4aXSwHzE8IUbtcZFXCKdps=; b=C05dNK8w3T38OTWQLfe7fEgGZEMJ1KM79Op6o4j+bAuqn+PxpTwd1EZEcT59tqX85v ya+YpQD4Je/Sp0Sj8w44voxPlpJUTPaNDVDx0XGvg4tVP0GelkiqZcVUKoUWxWqExJjq Wczc0uX9gEicIl4wr9WLIRwhTtvBRBeH4nontnCLsIKs8MIpiS1x90oKrBSnL/ah8mzC olYzFLs9qpS0+jU88klOFRMyMZcLsL4cdds4a4bmwET+cZW9bZAtLMb+B0srFTbMKLH9 TSCZGwGogXeZ4Qo8Dw1I6183r/UGyADVz8VfTb4lZZCeS9KFtl2qUq2u+cJWRs3xhkqd 9EQw== X-Gm-Message-State: AJIora/6D74UF7DLuNGEZDQAl6slxawmU93ArJZROV+THDQSTMZr2ik/ MDoRBFT5yWJQPVbi1lFBSNOt2UC0oKS1yKfs02vPINjUPNk= X-Google-Smtp-Source: AGRyM1vPYDYqg4WAbG383ggKjacqEj8r4vSAqGOKKR17Dtd9P8usWkNAIBQUAnLu/CqeIQdVQadaENDIPz2YL9kJJyA= X-Received: by 2002:a05:6a00:15d2:b0:525:79c8:d4cb with SMTP id o18-20020a056a0015d200b0052579c8d4cbmr2590268pfu.23.1656085014396; Fri, 24 Jun 2022 08:36:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 24 Jun 2022 16:36:42 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000000446505e2335761" Subject: Re: [PHP-DEV] [RFC] [Under Discussion] New Curl URL API From: rowan.collins@gmail.com (Rowan Tommins) --00000000000000446505e2335761 Content-Type: text/plain; charset="UTF-8" On Fri, 24 Jun 2022 at 15:05, Jeffrey Dafoe wrote: > A thin wrapper would be the most flexible. Someone can always write a > "friendlier" class using your thin wrapper, as you mentioned, but one > cannot easily go the other direction. > I think this argument has some validity when talking about the entire API of a library like curl. But we're not, we're talking about a tiny bounded context. The underlying implementation consists of 6 functions, 4 of which are trivial: * An argument-less "constructor" https://curl.se/libcurl/c/curl_url.html * An equivalent to PHP "clone" https://curl.se/libcurl/c/curl_url_dup.html * A cleanup method, which would be automatic in any PHP implementation https://curl.se/libcurl/c/curl_url_cleanup.html * A function for looking up error strings from codes https://curl.se/libcurl/c/curl_url_strerror.html That leaves the main getter and setter functions https://curl.se/libcurl/c/curl_url_get.html and https://curl.se/libcurl/c/curl_url_set.html which take the same arguments: * A resource handle * The URL part to handle * The new value for set, or an output parameter for get * A set of flags If we really believe the goal is to expose the C API in PHP, the get function would look like this: /** * @return int Error code */ function curl_url_get(resource $url, int $what, string &$part, int $flags): int That would be ... awful, and I hope nobody's really suggesting that. So we have to map each part to some concept in PHP, which is what the proposal does: * The resource handle becomes $this * The $what argument becomes the method name * The output parameter becomes the return value * The error code becomes an exception There's no "flexibility" which has been lost, and no "future changes" which are being prevented. The only other change is a few renamed constants, which I suggested on the PR. I can see an argument for making them match the library exactly; but it's the *values* that actually matter, so I don't see why we shouldn't choose our own names if they're descriptive of the functionality. Regards, -- Rowan Tommins [IMSoP] --00000000000000446505e2335761--