Hi Máté,

After thinking about it and trying some different logics I believe  the
following rules should be applied during conversion from array to query
string.


   - *object*: invalid mapping, throws a TypeError
   - *resource*: invalid mapping, throws a TypeError
   - *array*: if a resource or an object is present in the array it should
   throw a ValueError
   - *null*:  should be allowed (['a' => null] should return "&a" (no `=`
   sign added). Currently entries with null values are skipped.

Currently in PHP, when using parse_str ,  &a is converted to ['a' => '']   I
presume this behaviour was done so that the variable `$a` could still be
accessible in a PHP script with an empty string as value instead of being
the value null. Since we will be dealing with arrays the following rules
could be updated when parsing the string using PHP behaviour:


   - no mangled data should occur on parsing
   - "&a" should be converted to ['a' => null]
   - the removal of the presence of indices if the array is a list. (would
   be a nice to have, to reduce the query string length, but not mandatory)

Best regards,
Ignace

Reply via email to