Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117961 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93472 invoked from network); 16 Jun 2022 06:54:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Jun 2022 06:54:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DCFDD18050B for ; Thu, 16 Jun 2022 01:41: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.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8412 83.65.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mail02.x-net.at (mail02.x-net.at [83.65.141.138]) (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 ; Thu, 16 Jun 2022 01:41:56 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail02.x-net.at (Postfix) with ESMTP id EFD973804DC; Thu, 16 Jun 2022 10:41:53 +0200 (CEST) Received: from mail02.x-net.at ([127.0.0.1]) by localhost (mail02.x-net.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id kRDNTu2CAX3c; Thu, 16 Jun 2022 10:41:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail02.x-net.at (Postfix) with ESMTP id 4FABD3804EE; Thu, 16 Jun 2022 10:41:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at x-t.at Received: from mail02.x-net.at ([127.0.0.1]) by localhost (mail02.x-net.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id X8WAKaK_e0cc; Thu, 16 Jun 2022 10:41:51 +0200 (CEST) Received: from [127.0.0.1] (178.165.172.124.wireless.dyn.drei.com [178.165.172.124]) by mail02.x-net.at (Postfix) with ESMTPSA id 0A2343804DC; Thu, 16 Jun 2022 10:41:50 +0200 (CEST) Date: Thu, 16 Jun 2022 10:41:50 +0200 To: internals@lists.php.net, Pierrick Charron User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: <9B8C259B-D872-45CE-9606-DC1D677BD2FB@dafert.at> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: =?US-ASCII?Q?Re=3A_=5BPHP-DEV=5D_Discussion_about_new_C?= =?US-ASCII?Q?url_URL_API_and_ext/curl_improvements?= From: mel@dafert.at (Mel Dafert) On 16 June 2022 09:10:08 CEST, Pierrick Charron wrote: > [=2E=2E=2E] >- For consistency expose the new Curl URL API as functions mapped one to >one to libcurl functions : > >function curl_url(?string $url =3D null): CurlUrl|false {} >function curl_url_set(CurlUrl $url, int $part, string $content, int $flag= s >=3D 0): bool {} >function curl_url_get(CurlUrl $url, int $part, int $flags =3D 0): >string|false {} >function curl_url_errno(CurlUrl $url): int {} >function curl_url_strerror(int $error_code): ?string {} > >- Add methods to the CurlUrl object to make it less opaque and expose an >object oriented style API=2E I would keep it minimal and let userlanAd AP= I >provide higher level APIs as guzzle for example=2E (You can see the curre= nt >implementation [5]) > >final class CurlUrl implements Stringable >{ > public function __construct(?string $url =3D null) {} > public function get(int $part, int $flags =3D 0): string {} > public function set(int $part, string $content, int $flags =3D 0): vo= id {} > public function getErrno(): int {} > public function __toString(): string {} > public function __clone() {} >} Hello, When IntlDatePatternGenerator was implemented, I initially also supplied b= oth a procedural and OO-style API, but was told that this duplication was hist= orical and not necessary for new APIs=2E See the thread following this message: [1] I would argue that this also applies to curl, and that it might make sense= to only supply the OO-style API here as well=2E (With `curl_url_strerror` being exposed as either a static method on `Curl= Url` or as `getErrorMessage`, I suppose=2E) >- It would also be nice to add this object oriented API for existing >CurlHandle, CurlMultiHandle and CurlShareHandle classes=2E For example th= e >CurlHandle class would look like that (First implementation [6]) I think this would be a good idea either way=2E Regards, Mel [1] https://externals=2Eio/message/114473#114658