Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115083 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93292 invoked from network); 23 Jun 2021 23:01:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jun 2021 23:01:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BC92A1804C3 for ; Wed, 23 Jun 2021 16:20:09 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 23 Jun 2021 16:20:09 -0700 (PDT) Received: by mail-lf1-f46.google.com with SMTP id a11so6886310lfg.11 for ; Wed, 23 Jun 2021 16:20:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zFvuwpACe2XMZlSz5ZDkp3HFvvUDMD9drdf0MeF20gM=; b=BkuOQvXPSg84hemy9iP00N83OKPntfbpR6qYstxJ3UZJio4STtAUhYDrGFHlHLE/pN UPImgvKBqyNMrAdWgTv9buBw9UXtKRkNdVkQkAtr80jasf9+m7uWVcS/QVAokwpAGXYP zADa6sV0UbtlOi+SM72Kw30inB5DqMkwd19o4T9sShWOz1NDFk5eUstQ/RYUKhNb5lxH wrsNte0RJQnKM7xOStOhnpnEQlUfFOWX4PzpZGnYXRiyRA4ypBooMBuqMc7QgOYuHvvJ 2Dy+q3smNoZw6Iw4RKJBCvTyDTusqCZ+/iE6fYcQCqtii1zWc1kF0J3bnWnDZTZwgKuS rVPw== X-Gm-Message-State: AOAM533yq8Y4JTjWqdbzdlAmjSU6xeLY63HAdhWG8k68ISctv2zB6GPO u60yGuu2/lOa5EbS9EDei6KAS5X1q2G1G2PZVOuiQg== X-Google-Smtp-Source: ABdhPJyHH6O9mhrP0nRfMSgYBKEDFLrCRMPXPtRr2NB5/WGP4M0CKzWE1LcZVlb/NGTrAGZfAXbzU+xDvXJb07UmbAk= X-Received: by 2002:a05:6512:3ca8:: with SMTP id h40mr1497821lfv.302.1624490406922; Wed, 23 Jun 2021 16:20:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 23 Jun 2021 18:19:55 -0500 Message-ID: To: Kamil Tekiela Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000a56b7a05c5772553" Subject: Re: [PHP-DEV] [RFC] Add parse_query_string as an alternative to parse_str From: pollita@php.net (Sara Golemon) --000000000000a56b7a05c5772553 Content-Type: text/plain; charset="UTF-8" On Wed, Jun 23, 2021 at 5:02 PM Kamil Tekiela 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 --000000000000a56b7a05c5772553--