Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100640 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44379 invoked from network); 15 Sep 2017 17:37:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Sep 2017 17:37:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=ilija.tovilo@me.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ilija.tovilo@me.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain me.com designates 17.142.194.251 as permitted sender) X-PHP-List-Original-Sender: ilija.tovilo@me.com X-Host-Fingerprint: 17.142.194.251 pv33p00im-asmtp002.me.com Received: from [17.142.194.251] ([17.142.194.251:39612] helo=pv33p00im-asmtp002.me.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2D/C3-19300-BCF0CB95 for ; Fri, 15 Sep 2017 13:37:17 -0400 Received: from process-dkim-sign-daemon.pv33p00im-asmtp002.me.com by pv33p00im-asmtp002.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) id <0OWC00M000SLPX00@pv33p00im-asmtp002.me.com> for internals@lists.php.net; Fri, 15 Sep 2017 17:37:02 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=04042017; t=1505497022; bh=C8pt/mWwnM3ADliVz83cMntgtKqt22rg27wHB6sD3xM=; h=Date:From:To:Message-id:Subject:MIME-version:Content-type; b=JH46LdI23fDIXhXallNBVaVbAPWeK4GDoNVz6AE1LCxuKlBo0pyPS7Y8LsB5mcZst mJW1hradE4BWavg/Og5JnfuL2j2i7HBv/ZhOL1yEOC3VYvxhkdUGOIMaCdq4FMzXJ6 cygi66pUfA3vgsaGJuRkHzTz59RTmxsqcEj2osrpBGgX8NcE51PDd4w8kOtjkb2RwT FUkfdHrERnro518gjw2OTLwQdjHv3JD2zRn2wKDaJbfH9RfmouenPfEL/QA8/TqdHi 99wxvXepl2gq9VZE24Y0JbN7sbZyxLwgaN9OxY6sIfqpXhL3c12p5CwTorzP/lcejh TBZ/Du/ozQthw== Received: from icloud.com ([127.0.0.1]) by pv33p00im-asmtp002.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) with ESMTPSA id <0OWC009S20XLSY10@pv33p00im-asmtp002.me.com>; Fri, 15 Sep 2017 17:37:01 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-15_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=34 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709150255 Date: Fri, 15 Sep 2017 19:35:57 +0200 To: Marco Pivetta Cc: PHP internals Message-ID: <7d703ad8-5596-44e7-95dc-23c2cc058408@Spark> In-reply-to: References: <097578bf-ab74-44cf-a465-dc6fdd50930f@Spark> X-Readdle-Message-ID: 7d703ad8-5596-44e7-95dc-23c2cc058408@Spark MIME-version: 1.0 Content-type: multipart/alternative; boundary=59bc0fb5_327b23c6_73e9 Subject: Re: [PHP-DEV] [RFC] Deprecate the extract function in PHP 7.3 From: ilija.tovilo@me.com --59bc0fb5_327b23c6_73e9 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Marco I can see it=E2=80=99s usefulness in this case. But wouldn=E2=80=99t it be better to implement this by hand in these rare= cases (it=E2=80=99s 3 lines of code) instead of encouraging the pollutio= n of the symbol table by unknown input=3F It=E2=80=99s also clearer since= people who don=E2=80=99t know the =60extract=60 function probably don=E2= =80=99t expect it to mutate the local symbol table. Cheers On 15 Sep 2017, 19:26 +0200, Marco Pivetta , wrote:= > Heya, > > This is typically used in templating engines. > The one I worked on is > https://github.com/zendframework/zend-view/blob/5523511b6771cb6c060a77f= 6777426526a8db5ab/src/Renderer/PhpRenderer.php=23L491-L492 > > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > > On =46ri, Sep 15, 2017 at 7:20 PM, wrote: > > > Hi=21 > > > > The =60extract=60 function takes an associative array and puts it int= o the > > local symbol table. > > http://php.net/manual/en/function.extract.php > > > > =60=60=60 > > =24array =3D =5B > > =E2=80=98foo=E2=80=99 =3D> =E2=80=98foo=E2=80=99, > > =E2=80=98bar=E2=80=99 =3D> =E2=80=98bar=E2=80=99, > > =5D; > > > > extract(=24array); > > > > print =24foo; // =22foo=22 > > =60=60=60 > > > > As a second parameter the =60extract=60 function takes some options t= o make > > this function less dangerous, like =60EXTR=5FSKIP=60 that prevents an= existing > > local variable of being overwritten. There=E2=80=99s a few more optio= ns, go ahead > > and take a look at the documentation. =60EXTR=5FOVERWRITE=60 is the d= efault one > > though. You can also pass a prefix for the variable names as a third > > argument. > > > > I seriously doubt the usefulness of this function, especially looking= at > > the potential risks. The fact that overwriting the local variables is= the > > default behaviour doesn=E2=80=99t make it any better. I suggest depre= cating it in > > PHP 7.3 and removing it in 8. > > > > In a whole Symfony-Stack (3.4) with all of it=E2=80=99s dependencies = I could only > > find two usages of this function, both of which could be easily rewri= tten > > in vanilla PHP: > > https://github.com/symfony/symfony/blob/master/src/ > > Symfony/Component/Templating/PhpEngine.php=23L148 > > https://github.com/symfony/symfony/blob/master/src/ > > Symfony/Component/Templating/PhpEngine.php=23L158 > > > > Only downside: A polyfill is probably impossible since you cannot mut= ate > > the local symbol table of the callee (as far as I=E2=80=99m aware). > > > > Any thoughts=3F > > > > Regards > > > > > > --59bc0fb5_327b23c6_73e9--