Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117999 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 81409 invoked from network); 19 Jun 2022 00:50:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jun 2022 00:50:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6A021180210 for ; Sat, 18 Jun 2022 19:39:19 -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=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 ; Sat, 18 Jun 2022 19:39:18 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id e17so9470599lfq.8 for ; Sat, 18 Jun 2022 19:39:18 -0700 (PDT) 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:cc; bh=knCneYk4h7LZ+W6NintTf+mcjTAr9ViPikHg5P3kdYw=; b=J01P6N8SSPBNwqr6Y8F9dQpD65GeAdSS+xJhQIIPHU2UzbvaT0r/VkQTnbAcKm/2NP N+8NU47y8J6Jg11ErkapkuWIGtr8gb19RVByK/V9yncGH+HPKiux39JX/bgtxYdp8Xp7 hVRG9WyEFRwgrg4TqNSKFdeEoPB7Bzew+ak33UC2lmf6Bx0q3IoGqvFMCOoiWryXxl3i fQ5NU3S+6MyGJROzXHaMYvC+l7BCAOItYQVId8fxK/tYAvb9feDb+4HVdt5QyYd6s8rI XiWyWKSZiq6p3UAnwKyDapxyiDve7KliTifYugvlraq0cCF9fNsVs4FIxOp7U5YzfPmB fOuQ== X-Gm-Message-State: AJIora+oO4IMrQ3ybHbUkMhoyHk/JTCuEpbmCloczNUniEi7gqUCbVpC i+vnN5SrfGK7dbs4GCKGB4d6u/rPNuc/xGLJrWoi0A== X-Google-Smtp-Source: AGRyM1sKHNrv91xE9VJ+Xhm37qIf2f0eYHx2oteV51JZB2gowgKDZ+klDdB+8Lafr5ziGyqFoLCDbajYGiWFch3+BZU= X-Received: by 2002:a05:6512:118f:b0:47f:69ef:91b4 with SMTP id g15-20020a056512118f00b0047f69ef91b4mr620180lfr.100.1655606357124; Sat, 18 Jun 2022 19:39:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 18 Jun 2022 22:39:06 -0400 Message-ID: To: Rowan Tommins Cc: php internals Content-Type: multipart/alternative; boundary="000000000000ce04b505e1c3e4fd" Subject: Re: [PHP-DEV] Discussion about new Curl URL API and ext/curl improvements From: pierrick@php.net (Pierrick Charron) --000000000000ce04b505e1c3e4fd Content-Type: text/plain; charset="UTF-8" Hi Rowan, all, Thanks for your responses and comments. > I think it's perfectly reasonable for CurlUrl to be designed the same way, > regardless of what else we do with the extension. > As suggested by most of you, I created a new version of the proposed new URL API with a friendlier interface [1]. A quick descriptions of the changes I made : - The curl_url_* procedural API was removed - The CurlUrl::set() and ::get() methods with the CURLUPART_ constants were replaced by more explicit setters and getters (ex: setHost() and getHost()). - All the CURLU_* constants are now CurlUrl class constants (ex: CURLU_GUESS_SCHEME => CurlUrl::GUESS_SCHEME) - All the CURLUE_* constants are now CurlUrlException class constants (ex: CURLUE_MALFORMED_INPUT => CurlUrlException::MALFORMED_INPUT) Does it look more like what you were expecting ? Any other improvements that should be made ? This feels like a very small gain, since users can already type "curl_" and > get a list of all curl functions. It also has real costs: users may be > confused why there are two ways of writing the same thing; and it sets the > precedent that methods on CurlHandle should mirror curl_* functions, even > though we know those have terrible usability. > This is not the only change that I would like to introduce with a new OO API. One other change that I would like to introduce is a better type checking of `CurlHandle::setOpt()` when declaring strict_types to 1 (I know Sara once opened a PR about this [2]). The current signature of the procedural API is `curl_setopt(CurlHandle $handle, int $option, mixed $value): bool`. The 3rd argument being mixed never throws any TypeError, and adding this to the current procedural API would be a breaking change. If we add a new OOP API this kind of change is possible and we can improve the error message like : "Argument 2 passed to CurlHandle::setOpt() for option CURLOPT_BUFFERSIZE must be of type int, string given" However, knowing that the feature freeze for 8.2 is in a month, I will put more emphasis on the Curl URL API than on a new OO API for existing Curl API. Thanks again for your feedback Pierrick [1] https://github.com/adoy/php-src/pull/1/files [2] https://github.com/php/php-src/pull/2495 --000000000000ce04b505e1c3e4fd--