Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129492 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 92D611A00BC for ; Mon, 1 Dec 2025 22:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764627263; bh=huCTetNuRw7N8Os+/3NgSjig1U8rro11nz9iWhcOJBQ=; h=References:In-Reply-To:From:Date:Subject:To:From; b=KwuNnGl+rjvvSq0TMvtS1T38U+glASTbvIes1Phty1aneiV/2pVKDijbrgFxvuYgw 5vNiB7GppiaCQE3ntXwV28vMxnAXT8cF7iTpl9slUuD53E1tDMnPKgD+irNMsgVgtn IP1+gM1MPIMCKnDwpQV6Ot6RHUEZ3RL3Xq8yltd8/tIyF/VvX5getiApgm85O4bBAI j2NTok0JWM2hhW7OSe4B3sXZUplThiAS3rbpl9b8lYAzK74XmgwWV+lB+VSvZWwDtk 9oGjo8dZxLF73+7GQtCLS5Vn5OsUsiDumpk5e6HiIgB8uR9BnuTQOGLd5qM8hyx9qC ZDyVttJo40c5A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E39D9180056 for ; Mon, 1 Dec 2025 22:14:18 +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,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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, 1 Dec 2025 22:14:18 +0000 (UTC) Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-7c75b829eb6so3195705a34.1 for ; Mon, 01 Dec 2025 14:14:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764627253; x=1765232053; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=TC9cw1RZd9oBdZnbPnzFINhmUfk1TxkZvBWKxgLA9LM=; b=YB4CLHI36OUEwJUobGdn9s1bJoTd67MhubWItCgeqQbMa2Gv/myOuZgoBQsJrVl/dR DSbv3qKDOXSoQ0thVjLZ3kGffu/k+V64Cm3zltXKnpe+QMBUJk+DYSmln2/bGBoe/dTl ZzDZ8bCvDTtRCYRCxwFChE9ThOoY10fgQ9khImhMtj21CMVJNMd7qGHTPvpuWf5XU+l5 NaK+OgOckqczkG08qa7xuStmMgQVWmtmKEKBiifkmUEOmju0/nP4wNv7jIECTpKw27Um usoOeOnpI+5x5V+rqWuit+o0PpAS58UjObQe0cGO6jaoz9iNkue3ExjYtrMX1Iympj4y SODg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764627253; x=1765232053; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TC9cw1RZd9oBdZnbPnzFINhmUfk1TxkZvBWKxgLA9LM=; b=lZVPIn3K4Djmsg+VJdJbk0VFh04/sUjKH85n9flQjfoRw/TxW2ziuCHwfsSZNytKEy tBrV2U9IKsDUidvhvxIRi2UTUyyqt5QKt5zcjEuL7Uj/HToUa/ZXqcknKwUsLcFqyngl mQyfnnVXBuVdj3pZhsmRD6rAseFG0465LnHX3Rcm36YaFFhIQ/1O9hhspcY3sROSDcqr uTzFTx1SuehEiKH5rLGOzc4PcwJfZyHvUUoinCoSzN6VIqBdYgwc+UyA1+W8OaPewueh jNfBS61kJS5Ao2nMKtVrvnCBzPeYChpObDt4PV+xXx13EbgGb623rvc6gbSdAymYcCiM QX2Q== X-Forwarded-Encrypted: i=1; AJvYcCVbq1iv/pSUPSXpei7brO02JPoO1bRWiKyhI5RZWLaQtd5SYMURJPXU86VJfK4Q9FbNkeOqsWNMrPs=@lists.php.net X-Gm-Message-State: AOJu0YyiXKZ2w9yTgQewMPn5fkpbM+BWKNNkqk6pVXyKP9MP3kbHDQc8 YFsiii9Pml4l1V9HmGlxGu8f7ObqYxr+7v7O4clczcayJHUn7xiSyzFiGh7YzkR0AUTSJrWM2BM CACeCgZw56AgBPC0xCvQZOhsjQLcD+DA= X-Gm-Gg: ASbGncuzrco4Zp/CKo04C2EloqUkx8bi8j0N+dS+EwXvaBpYxCJQJf+v1Q9lM5t2xb0 +IiRj2lfKqxyzCwvvr++KoT1F7TrGyXLHb0mpTl6na2Xjsq07SH0xRoXfTW/eHqd1Hr7GQSUaEh pAFGGda4MpOx3Xfvz5poOJXhQwvrX6HpY147s9YuOavkYrvVq3wBcSldRP01HK+8yy8tGHi15BK rqZGIsNJLFbBAUzAlb48Qx+TBcw1JSGs7qeG79eq7WPu+8QHb+ayjd21/Vj9AGVXIglt+6MxQJR 9nUqdmj4IiMQxhpfA4zZMlQv2RgFqw== X-Google-Smtp-Source: AGHT+IEC4aQTOG9Tun4zzIQKMLtqWpW0gg6u1svGRE7Rw8zbDSYcU1/P2CP+Dryzbie3ZEcZyKwafx9ZCy3Dl0xGn10= X-Received: by 2002:a05:6808:3507:b0:44d:ae36:dd7a with SMTP id 5614622812f47-45115cb85dcmr17165871b6e.66.1764627252754; Mon, 01 Dec 2025 14:14:12 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 1 Dec 2025 23:14:01 +0100 X-Gm-Features: AWmQ_blBTbK3KiHfWCTofMx-TLQa0mYozFV8xXk703z6JPKhqCfQ8jMdeBudq3Y Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Followup Improvements for ext/uri To: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= , PHP Internals List Content-Type: multipart/alternative; boundary="0000000000008fbcfb0644eb4c31" From: nyamsprod@gmail.com (ignace nyamagana butera) --0000000000008fbcfb0644eb4c31 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi M=C3=A1t=C3=A9, Once again thanks for this follow up RFC. While there are a lot to digest I wanted to point out your reservation around implementing the IteratorAggregate interface for Query Manipulation, The UriQueryParams and UrlQueryParams classes could implement the > IteratorAggregate interface in theory. However, it's not possible to do s= o > due to query components that share the same name, e.g.: > param=3Dfoo¶m=3Dbar¶m=3Dbaz. In this case, the same key (param) w= ould be > repeated 3 times - and it's actually not possible to support with iterato= rs. > > When building the Query component in league URI I was able to use the Countable and IteratorAggregate interface using a different representation of the query pair see https://uri.thephpleague.com/components/7.0/query/#countable-and-iteratorag= gregate TL;DR instead of using your proposed structure [['name' =3D> 'value'],...] I used the following [['name', 'value'], ...] While both format IMHO can allow implementing the IteratorAggregate interface, the latter allows for a more predictable API ```php $uri =3D new Uri('https://example.com?param=3Dfoo¶m=3Dbar¶m=3Dbaz')= ; foreach ($uri->getQueryParams() as $key =3D> $pair) { //first iteration $pair['param'] =3D 'foo' //second iteration $pair['param'] =3D 'bar' //third iteration $pair['param'] =3D 'baz' } ``` The user needs to know beforehand the name of the pair which is counter intuitive if you do not know the exact position of the pair. In contrast, using the league URI query syntax you will have the following: $uri =3D new Uri('https://example.com?param=3Dfoo¶m=3Dbar¶m=3Dbaz')= ; Query::fromUri($uri); foreach (Query::fromUri($uri) as $key =3D> $pair) { //first iteration $pair[0] =3D 'param'; $pair[1] =3D 'foo' //second iteration $pair[0] =3D 'param'; $pair[1] =3D 'baz' //third iteration $pair[0] =3D 'param'; $pair[1] =3D 'bar' } ``` The user will always get the parameter name using $pair[0] and the value using $pair[1] regardless of their content and value. What do you think ? This IMHO would solve your issue but it is indeed a stronger departure to how query strings are parsed in PHP currently. Best regards. On Mon, Dec 1, 2025 at 9:53=E2=80=AFPM M=C3=A1t=C3=A9 Kocsis wrote: > Hi Everyone, > > I'd like to introduce my latest RFC that I've been working on for a while > now: https://wiki.php.net/rfc/uri_followup. > > It proposes 5 followup improvements for ext/uri in the following areas: > - URI Building > - Query Parameter Manipulation > - Accessing Path Segments as an Array > - Host Type Detection > - URI Type Detection > - Percent-Encoding and Decoding Support > > I did my best to write an RFC that was at least as extensive as > https://wiki.php.net/rfc/url_parsing_api had become by the end. Despite > my efforts, > there are still a couple things which need a final decision, or which > need to be polished/improved. Some examples: > > - How to support array/object values for constructing query strings? ( > https://wiki.php.net/rfc/uri_followup#type_support) > - How to make the UriQueryParams and UrlQueryParams classes more > interoperable with the query string component (mainly with respect to > percent-encoding)? ( > https://wiki.php.net/rfc/uri_followup#percent-encoding_and_decoding) > - Exactly how the advanced percent-decoding capabilities should work? Doe= s > it make sense to support all the possible modes (UriPercentEncodingMode) > for percent-decoding as well ( > https://wiki.php.net/rfc/uri_followup#percent-encoding_and_decoding_suppo= rt > ) > - etc. > > Regards, > M=C3=A1t=C3=A9 > --0000000000008fbcfb0644eb4c31 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi=C2=A0M=C3=A1t=C3=A9,
Once again thanks for this fol= low up RFC. While there are a lot to digest I wanted to point out your rese= rvation around implementing the IteratorAggregate interface for Query Manip= ulation,=C2=A0

The UriQueryParams and UrlQueryParams classes could implement th= e IteratorAggregate interface in theory. However, it's not possible to = do so due to query components that share the same name, e.g.: param=3Dfoo&a= mp;param=3Dbar&param=3Dbaz. In this case, the same key (param) would be= repeated 3 times - and it's actually not possible to support with iter= ators.

=C2=A0
When building the Query co= mponent in league=C2=A0URI I was able to use the Countable and IteratorAggr= egate interface using a different representation of the query pair see=C2= =A0https://uri.thephpleague.com/components/7.0/query/#c= ountable-and-iteratoraggregate
TL;DR instead of using your pr= oposed structure=C2=A0

[['name' =3D> &#= 39;value'],...]

I used the following

[['name', 'value'], ...]

While both format IMHO can allow implementing the IteratorAggregate = interface, the latter allows for a more predictable=C2=A0API

=
```php
$uri =3D new Uri('https://example.com?para= m=3Dfoo&param=3Dbar&param=3Dbaz');
foreach ($uri->get= QueryParams() as $key =3D> $pair) {
=C2=A0 =C2=A0 //first iteration $= pair['param'] =3D 'foo'
=C2=A0 =C2=A0 //second iteration= $pair['param'] =3D 'bar'
=C2=A0 =C2=A0 //third iteratio= n $pair['param'] =3D 'baz'
}
```

The user nee= ds to know beforehand the name of the pair which is counter intuitive if yo= u do not know the exact position
of the pair. In contrast, using the le= ague URI query syntax you will have the following:

$uri =3D n= ew Uri('https://example.com?param=3Dfoo&param=3Dbar&param= =3Dbaz');
Query::fromUri($uri);
foreach (Query::fromUri($uri)= as $key =3D> $pair) {
=C2=A0 =C2=A0 //first iteration $pair[0] =3D &= #39;param'; $pair[1] =3D 'foo'
=C2=A0 =C2=A0 //second iterat= ion $pair[0] =3D 'param'; $pair[1] =3D 'baz'
=C2=A0 =C2= =A0 //third iteration $pair[0] =3D 'param'; $pair[1] =3D 'bar&#= 39;
}
```

The user will always g= et the parameter name using $pair[0] and the value using $pair[1] regardles= s of their content and value.

What do you think ? = This IMHO would solve your issue but it is indeed a stronger departure to h= ow query strings are parsed in PHP currently.

Best= regards.

On Mon, Dec 1, 2025 at 9:5= 3=E2=80=AFPM M=C3=A1t=C3=A9 Kocsis <kocsismate90@gmail.com> wrote:
Hi Everyone,

I'd like to introduce my latest RFC that I've been working on for= a while now: https://wiki.php.net/rfc/uri_followup.

= It proposes 5=C2=A0followup=C2=A0improvements for ext/uri in the following = areas:
- URI Building
- Query Parameter Manipulation
- Acce= ssing Path Segments as an Array
- Host Type Detection
- URI Type Dete= ction
- Percent-Encoding and Decoding Support

I= did my best to write an RFC that was at least as extensive as=C2=A0https://wik= i.php.net/rfc/url_parsing_api had become by the end. Despite my efforts= ,
there are still a couple things which need=C2=A0a final decisio= n, or which need=C2=A0to be polished/improved. Some examples:
- How to support array/object values for constructing query str= ings? (https://wiki.php.net/rfc/uri_followup#type_support)
<= div>- How to make the UriQueryParams and=C2=A0UrlQueryParams classes more i= nteroperable with the query string component (mainly with respect to percen= t-encoding)? (https://wiki.php.net/rfc/uri_followup#= percent-encoding_and_decoding)
- Exactly how the advanced per= cent-decoding capabilities should work? Does it make sense to support all t= he possible modes (UriPercentEncodingMode) for percent-decoding as well (https://wiki.php.net/rfc/uri_followup#percent-= encoding_and_decoding_support)
- etc.

Regards,
M=C3=A1t=C3=A9
--0000000000008fbcfb0644eb4c31--