Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130627 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 3E80D1A00BC for ; Mon, 13 Apr 2026 22:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1776119261; bh=XQWuSTkTRvKDd//B4j5C9L7SJFUHK9TzW8fIE8nP1QE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ZFgtOsFB4OPqfwTEmfdgF/KVeSvtFBXa23ez9IFvAqd4zcgDEfzv7y7yoUVCLd64H Yz5pnncFpozMyRY6dqXBZqMtdRPGptfqs6P0LWANq8tyluvczQqq0EgFgNwneqHDmU 0mWVlb7cn/zWzG7g/hQLv5BgPWfRcnutqBYQ/PIHuDc1x3iOqS56es/fNfVSt97tu9 NxzGsXpuL5OtWTBLThh/DQqNXzqqPOL9L3DuB/2qY7BbXBYQKQcll/FDqJhJsDS96j 4MnX3mYR4SsGHjhdKbzoo4IaauMsYKhe9ov5GEZqvseIxwL/DM113IDOZIB5aXdlHD 0ctAmBaWJ63ow== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2812C180061 for ; Mon, 13 Apr 2026 22:27:36 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Mon, 13 Apr 2026 22:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1776119249; bh=rbarClC+eKTWNTIBmdTtNBmtAyn+z0MQtdHDLftHN/o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=mP22xCyKRkkiPyuBVt2v+qQnnICRjeHiysA/7NeGCkUca6yTT5tnD6SCzf9+s0dmc 5RMjoPyY/cN6Rn4x0XAObd46P7+gX2ILxiS4Q+ryFrmSkIb2rLdK4PYfwOLXFkzuxR NYD7gre0ZWmXqAFpH+JV+VP+rkTdfeSgKLqRWivb4OFfr1ZGJ2zpNhcVvwFxqMdUAl ps9V/WUXe2iqr7gMQDoubAbXB6CkzDpR6D9olwhHheaDHisOlCr9z/vKP9/qBvALs5 Bq+wiU3KTv39ACcclyHAwzgCSxt9q91dhSCYVQPdjM3e5rzVF/1LwxQc9A7G/mPMzF f76+6RP/Mtpug== Message-ID: <1fee2f46-27b7-4eb2-908f-b38f8c78d8c9@bastelstu.be> Date: Tue, 14 Apr 2026 00:27:28 +0200 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] [Discussion] Followup Improvements for ext/uri To: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= , ignace nyamagana butera Cc: PHP Internals List References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 3/13/26 10:38, Máté Kocsis wrote: > Personally - and I may be in the minority - I don't see an issue with > having two static methods on Uri/Url. As I had previously mentioned in private, I also (very strongly) believe that making these static methods on the URI class is not the correct design. Classes are not intended to be “pseudo-namespaces” and any (public) functionality on a class should directly relate to it, otherwise you're just polluting the API surface, which makes autocompletion and discoverability worse and documentation more complex. In practice this means that public static methods should be limited to “named constructors”. > Uri::percentEncode() and Uri::percentDecode() as well as > Url::percentEncode() and Url::percentDecode() > could indeed be implemented via a dedicated UriPercentEncoder and > UrlPercentEncoder class, or even a > shared PercentEncoder one, but: > > - Its methods would still be static > - I don't think it's worth to add one or two dedicated classes just for > this purpose I agree here: A dedicated class with static methods would still be a pseudo-namespace. It would be … > I also got feedback that these functions could be free-standing in the URI > namespace. But I really don't like free standing functions, … equivalent to free-standing functions but worse. Personal preference should not play a role here: PHP supports namespacing functions and within PHP's standard library we should embrace this capability. A big benefit of free-standing functions is that they would be easy to polyfill, particularly when we need additional of them in future PHP versions. > So all in all... As far as I can see, not even a Uri\Rfc3986\UriComponent > enum could provide a complete solution for the custom > percent-encoding/decoding part of the proposal. If we used a > Uri\Rfc3986\UriEncoding enum name instead, then there would be no issue > with the various kinds of encoding/decoding modes not referring to URI > components, but the naming would probably still not be right, > as I wouldn't expect a class name with "ing" suffix to perform > percent-encoding/decoding itself. But I'm happy to be corrected by > native English speakers :) enum Uri\Rfc3986\PercentEncoder enum Uri\WhatWg\PercentEncoder with *non*-static encode() and decode() methods would work for me. I don't have a strong preference between “instance methods on an enum” and “free-standing functions”, but I have a strong preference against “static methods”. Best regards Tim Düsterhus