Hi Maté,
I was reviewing your Query Parameter RFC as I was also checking the new CSV extension RFC around Type Conversion and I see that currently at least the following behaviour around float
will be changed.
$data = [
'a' => 0.000000000000034,
'b' => 1.0,
'c' => 1e-10,
];
echo http_build_query($data), PHP_EOL;
// a=3.4E-14&b=1&c=1.0E-10
echo json_encode($data);
// {"a":3.4e-14,"b":1,"c":1.0e-10}
with the browsers implementations using URLSearchParams I get
const q = new URLSearchParams({
'a': 0.000000000000034,
'b': 1.0,
'c': 1e-10,
});
console.log(q.toString())
// a=3.4e-14&b=1&c=1e-10
Maybe the conversion rules difference Uppercase/lowercase for scientific notation regarding floats should be expressed in the RFC to avoid surprises.
Best regards,
Ignace
Hi Maté,
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.
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? Best regards,
Ignace
On Thu, Nov 12, 2026 at 9:40 AM ignace nyamagana butera nyamsprod@gmail.com wrote:
Quoted text · 23 lines
Hi Maté,
I was reviewing your Query Parameter RFC as I was also checking the new CSV extension RFC around Type Conversion and I see that currently at least the following behaviour around float
will be changed.$data = [
'a' => 0.000000000000034,
'b' => 1.0,
'c' => 1e-10,
];echo http_build_query($data), PHP_EOL;
// a=3.4E-14&b=1&c=1.0E-10
echo json_encode($data);
// {"a":3.4e-14,"b":1,"c":1.0e-10}with the browsers implementations using URLSearchParams I get
const q = new URLSearchParams({
'a': 0.000000000000034,
'b': 1.0,
'c': 1e-10,
});
console.log(q.toString())
// a=3.4e-14&b=1&c=1e-10Maybe the conversion rules difference Uppercase/lowercase for scientific notation regarding floats should be expressed in the RFC to avoid surprises.
Best regards,
Ignace
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 whole QueryParamBuildingOptions 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é
Hey Ignace,
Quoted text · 18 lines
I was reviewing your Query Parameter RFC as I was also checking the new CSV extension RFC around Type Conversion and I see that currently at least the following behaviour around float will be changed.
$data = [
'a' =>0.000000000000034,
'b' =>1.0,
'c' =>1e-10,
];echo http_build_query($data),PHP_EOL;
// a=3.4E-14&b=1&c=1.0E-10
echo json_encode($data);
// {"a":3.4e-14,"b":1,"c":1.0e-10}with the browsers implementations using URLSearchParams I get const q =new URLSearchParams({
'a':0.000000000000034,
'b':1.0,
'c':1e-10,
});
console.log(q.toString())
// a=3.4e-14&b=1&c=1e-10Maybe the conversion rules difference Uppercase/lowercase for scientific notation regarding floats should be expressed in the RFC to avoid surprises.
I've just updated the RFC based on your and Tim's latest feedback (also, I finally pushed the implementation which is in line with the RFC).
This means that the behavior how the scientific notation as well as non-finite values are handled are explicitly documented in the "Supported Types" section, and generally float handling now follows the behavior of json_encode().
Regards,
Máté