I really prefer the Sara suggestion, instead of creating a new function
to do the same thing. parse_str($str): array.


Atenciosamente,
David Rodrigues


Em qua., 23 de jun. de 2021 às 20:20, Sara Golemon <poll...@php.net>
escreveu:

> On Wed, Jun 23, 2021 at 5:02 PM Kamil Tekiela <tekiela...@gmail.com>
> wrote:
>
> > I would like to propose a new simple RFC that aims to add a new function
> > called parse_query_string as an alternative to parse_str.
> >
> > https://wiki.php.net/rfc/parse_str_alternative
> >
> > The functionality stays the same, only the name and the way of returning
> > the array changes. While it is a rather insignificant change, I believe
> it
> > is one step closer to making PHP cleaner.
> >
> >
> There's a potential alternative option that doesn't require adding a new,
> parallel function.  We can use execute_data->return_value_used to figure
> out if parse_str() was called with the result assigned to a local var.
> This is overloady and probably a bad idea, but it's an option.
>
> if (ZEND_NUM_ARGS() == 2) {
>   // Put result into by-ref second arg
>   // parse_str($str, $refResult);
> } else if (EX(return_value_used)) {
>   // Put result into return_value
>   // $result = parse_str($str);
> } else {
>   // Put result into EG(local_symbol_table)
>   // parse_str($str);
>   php_error(E_DEPRECATED, ...);
> }
>
> Realistically, your approach is probably better simply because it doesn't
> depend on the assignment as a side-effect, and it'll be good to have a
> migration route, especially one which gives us a function with, frankly, a
> much better name.
>
> That said, and I'll sound like a broken record here, but this is another
> case of being something that can be sorted in userspace trivially:
>
> function parse_query_string(string $str): array {
>   parse_str($str, $ret);
>   return $ret;
> }
>
> Kinda +/- 0 on it at the moment.  I'm less hostile to it than
> str_contains()/str_left()/str_right()/etc...
>
> -Sara
>

Reply via email to