Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115086 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99378 invoked from network); 23 Jun 2021 23:43:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jun 2021 23:43:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2B1841804CC for ; Wed, 23 Jun 2021 17:02:14 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, MISSING_HEADERS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 17:02:10 -0700 (PDT) Received: by mail-qk1-f178.google.com with SMTP id q190so9864794qkd.2 for ; Wed, 23 Jun 2021 17:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:cc; bh=J7M55mpwLKKP6hJf0Dn5S9pnc5bIMLV5o2uP9+tJLik=; b=ckRkRBBnvEg09jZptngruYySUOD/sZnrFANTVro2LyFo1piQxU9YVmD02HNUYdAsY0 nJdRNQxNRwmtxry04Mv6waMnyEanJ+jt+USx37jf3FgdpyxBR6vBGp12mRr1fSZ2FkPM 8W6vNrieF1NtjyXAR7O8UvQHYH1LM4rLNI/3+5AaobYGPuWPDXXkYw+tAD4uVW0Di5IP 1ZCzUZgpPO5jPeJfXBtB1N6zdF/jQqL+NjUSJYtv/iNqO/mWFdHN2xDnRSKR6dy+Ql6G uTpBE1yxe5jQCyrcu6LjiP52uaSBUAjuMWV+4+B3Dg6ZrkuymRlF9ya36tNKxunzGZVT pATA== 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:cc; bh=J7M55mpwLKKP6hJf0Dn5S9pnc5bIMLV5o2uP9+tJLik=; b=nfsQzH5ZsWexaLM2f4SLfD5lMs+XKf3BlAHRHJ2MP5j4GUR2beu8JiG0SHjBmyNf4m mYgUiI6eTNdg2Jrb0gyECdGpGXDEvlS8YP4fhBpmKnw83dFjR4iArN9/RB0eLkw5E2r1 3Fvrb1w5vka+1xC+X6tBY5Smfc+uWf83Js7zJCOPcUjv5WWD69IuXwkMWK0Mkn4WxL48 4Sa0YEIeYSer89qDR0dN1PemNIFgczfhFnS609e+Oc+WUTJty/+vvadIvf7NJtWMiOSD BEkFfnAM+9nDNJPTsMb5tBBzt0c1pjSxFQzDv3MxLeFYDiz2cIJa3jAJ6RawEzRZky8x IYIQ== X-Gm-Message-State: AOAM5336sWlnFDTbdorCy2P3Q3HHVVvawRMDTrmKHmbtcem75Miaa/IM jP4lyC2y8U5px7GUneaqdk6+wlkJUnDAoF8Eb7kcGioqUFQ= X-Google-Smtp-Source: ABdhPJwvs3zCpDK5flNLKVS4XMNHlKZFpgCpGhhGNmwUg3Dh//kR2bjy71LNe7+tQ/oecX/YaMVNHLWVF/Y7CpW7XqM= X-Received: by 2002:a25:b808:: with SMTP id v8mr1019571ybj.130.1624492928521; Wed, 23 Jun 2021 17:02:08 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 23 Jun 2021 21:01:56 -0300 Message-ID: Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000f1d7b405c577bb9c" Subject: Re: [PHP-DEV] [RFC] Add parse_query_string as an alternative to parse_str From: david.proweb@gmail.com (David Rodrigues) --000000000000f1d7b405c577bb9c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 =C3=A0s 20:20, Sara Golemon escreveu: > 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 functio= n > > 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 returnin= g > > 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() =3D=3D 2) { > // Put result into by-ref second arg > // parse_str($str, $refResult); > } else if (EX(return_value_used)) { > // Put result into return_value > // $result =3D 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 > --000000000000f1d7b405c577bb9c--