Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117372 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50034 invoked from network); 18 Mar 2022 12:36:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Mar 2022 12:36:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2C1471804F8 for ; Fri, 18 Mar 2022 07:02:28 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com [209.85.221.176]) (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 ; Fri, 18 Mar 2022 07:02:27 -0700 (PDT) Received: by mail-vk1-f176.google.com with SMTP id r5so2043918vkf.8 for ; Fri, 18 Mar 2022 07:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1ETQi/y413WCNv6X1vT3ExHeO10gztxiUNGIC9LSQgE=; b=kvUUtAe3FS8qEqctvbYqm3clhxeOlyIU49b+CtubJqDdXHVlmpYVh1EMO9Bv8uO48/ jjW7CN5Ya5QumszwQ2zvC4heJuy5ToR5WXGedCdNZMnktFXy6nUUVl4p85OomUH6EdlD hMCdUQE8eSbyTWavU3HR50aznlkjk6fnFPJUOAXrqC+xaAPRLxXln6kgBvUiVb2V+ZI7 t/4Lu+74henwtrQ4rBQLAHHxhp6aM58EpTCpxa+OLEdq039+w3RmjClXpTypWyTBMj+b w/W9yjx4OIHU+W1HRGvlunujiiFlmmZn75E089CAjCpY834XkbGiCmRdo/rmfVf1Lb+4 /Ucw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1ETQi/y413WCNv6X1vT3ExHeO10gztxiUNGIC9LSQgE=; b=CAg0Sww18/6BujKbqRNv/hBrQ5ujEE5WMfojcnNgQC/Y24I5vGFin1aVqV3WZKaIkM pn8w9Me4Y/fgK6gqn4c7aCv44LcuQhGe8c8YxQAcioPARaNImEqljgACtl6r7PmOxtoa XtnlGyavJCtyZvdRTXjKPvxTrC0txuUDFUO1vhSdJrdax2zUeQciX67KOshyQLzDKj4v oug6oC6lAMOt08GZoXIN1QE+ZHL+JebhWy4Um9X6qhDDAdJHq35+JYP71WH0/LO3WoTT D8R4fMn2/ntVAa32gbv7avq01Q49TGpwKoW2m2OlI/zQrDp3wcx5NE4NCiRzIwTsX8Ah Zg/Q== X-Gm-Message-State: AOAM530zd3iTtbZzKtCDJMiildsVoDbJ58TjFP6tvox8gvmpwchYoANH VJ5l0P43tzGLHqFAKqgA/9YQVf1IXm+C5S7uNSI= X-Google-Smtp-Source: ABdhPJyaK5uA3kKHaewbOnEJsi8Xm8fVk1ugEOC9JfPTj3Y/JEJ/xUF3kVADO/gCtyCzUeKc/v9AGXAiPUGP/5o+4pQ= X-Received: by 2002:a1f:50c4:0:b0:336:e84d:2873 with SMTP id e187-20020a1f50c4000000b00336e84d2873mr3957499vkb.30.1647612145894; Fri, 18 Mar 2022 07:02:25 -0700 (PDT) MIME-Version: 1.0 References: <4AC60E84-B2AD-43F4-9B72-92604FC7BD41@gmail.com> In-Reply-To: Date: Fri, 18 Mar 2022 10:02:13 -0400 Message-ID: To: Theodore Brown Cc: Tobias Nyholm , Ilija Tovilo , PHP internals Content-Type: multipart/alternative; boundary="000000000000af08a205da7e985c" Subject: Re: [PHP-DEV] [RFC][Under discussion] Arbitrary string interpolation From: chasepeeler@gmail.com (Chase Peeler) --000000000000af08a205da7e985c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 18, 2022 at 12:49 AM Theodore Brown wrote: > On Thu, Mar 17, 2022 at 5:40 PM Tobias Nyholm > wrote: > > > On Thu, 17 Mar 2022, 23:27 Ilija Tovilo, wrote= : > > > >> Hi everyone > >> > >> I'd like to start discussion on a new RFC for arbitrary string > >> interpolation. > >> https://wiki.php.net/rfc/arbitrary_string_interpolation > >> > >> Let me know what you think. > > > > That is a cool idea. > > But I am not a big fan of having code in strings. > > Wouldn=E2=80=99t this open the door to all kinds of new attacks? > > Do you have an example of a new kind of attack this would allow? > The proposal doesn't enable interpolation of strings coming from > a database or user input - it only applies to string literals > directly in PHP code. > > Personally I'm really looking forward to having this functionality. > Just a couple days ago I wanted to call a function in an interpolated > string, and it was really annoying to have to wrap the function in a > closure in order to use it. > > If this RFC is accepted I'd be able to replace code like this: > > $name =3D "Theodore Brown"; > $strlen =3D fn(string $string): int =3D> strlen($string); > echo "{$name} has a length of {$strlen($name)}."; > > with > > $name =3D "Theodore Brown"; > echo "{$name} has a length of {$:strlen($name)}."; > > Out of curiosity, why not: $name =3D "Theodore Brown"; echo "{$name} has a length of ".strlen($name)."."; or even $name =3D "Theodore Brown"; $len =3D strlen($name); echo "{$name} has a length of {$len}."; > > Sincerely, > > Theodore > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --=20 Chase Peeler chasepeeler@gmail.com --000000000000af08a205da7e985c--