Re: [RFC] [Discussion] Query Parameter Manipulation Support
| From: | Máté Kocsis | Date: | Fri, 20 Nov 2026 15:13:49 +0000 |
| Subject: | Re: [RFC] [Discussion] Query Parameter Manipulation Support | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-133145@lists.php.net to get a copy of this message | ||
Hi Ignace,
I was wondering why |QueryParams| always needs to be instantiated with a |QueryParamBuildingOptions| instance. Why couldn't these options instead be passed as arguments to the |to*()| methods? It feels a little counterintuitive to configure how the query string should be built when constructing the object, rather than specifying that behaviour directly when calling the methods responsible for building it. It also means that if I want to change the behaviour of a |to*()| method, I have to reconstruct the entire |QueryParams| instance. Based on the discussion with Tim, I removed the wholeQueryParamBuildingOptions concept from the proposal.
I also wondered why |QueryParams| cannot be constructed from a list of key/value pairs. You already have |QueryParams::fromArray()| as the counterpart to |QueryParams::toArray()|, but I couldn't find a |QueryParams::fromList()| method to complement |QueryParams::toList()|. Is there a particular design reason behind these choices? I think it's a fair request, I just didn't consider this before.So the updated proposal now contains QueryParams::fromList(). Regards, Máté