Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100638 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41426 invoked from network); 15 Sep 2017 17:26:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Sep 2017 17:26:41 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.50 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.50 mail-wm0-f50.google.com Received: from [74.125.82.50] ([74.125.82.50:47382] helo=mail-wm0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/23-19300-A4D0CB95 for ; Fri, 15 Sep 2017 13:26:35 -0400 Received: by mail-wm0-f50.google.com with SMTP id 13so10072686wmq.2 for ; Fri, 15 Sep 2017 10:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=jTAG0masrl0H9jz5ycJM7PetKKXYeJPp2GBZWUf8T0I=; b=ZOMv0sdARDNsusqCw3VnEym639LmdsGOi/lwVfn5GdVstev2TzhZKMUgEdM1i8p+/K p/t1C9G38BccU7NbE9NIIphKfleUIm+6F4ZB6+Aa258xGhkQB+os1DrxVI3nNeGP7FAi pX3kEMFwcPFprR13Axq1XYhb7hYlvnNbBqU+LS/XGXI6eNitjW0SZ4Aa+J5OenipGGSD 0H+fgVaJdi5x+TwHL6BZHjKH9Pz1U3z1Hk7VVVtuaboi6T+Lb/pOu5m9MEMZVTOciWOs r/7gW9TAgttW2oc1Mw9tcAP7d8z8ADIvA15l2pZYkQzTZK/VYX5kczvaE6pYAyRq5uxy TACw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=jTAG0masrl0H9jz5ycJM7PetKKXYeJPp2GBZWUf8T0I=; b=Ab1lYzKUUpS/rEduCiv+F3I/1dzXZQUZU1Uf8cozzJ48EdepCChr9WYFKvN0AUNjaU k0EiZkmFlR2dj6/rzPufzWtoTcj/Nu3LyTYVD8m01/u623kzl/C11HUbIs8E4wuKQVvi en5lOeWpycW2t6WPz0w1JnDTCYUGoA8av8ZaSP5I1d49JYNeHLutv5WY4fVQM+bkdve6 xX9dRB7ZviuNlI9rLM6xw1sZvONPMnf6eICjxrZlo94LiqIHj6BkEIG3O4s/Tb3OJGsa T5tOVH/QLmW/p9sqcbqVpjzpdVqXHdKTscB+bX+ZpKRh7v10Hh5YikMKbjLs5CZ1nVyk DvnQ== X-Gm-Message-State: AHPjjUhZM7MelCQ5DXrHFzjTtAfd0K8bKpbQN2ZVGX7JMgEGFMT1BCbp xnkT/n36GwU2WHPXPPYE1vVvIoy2EsVJBm7wfuiKtufi X-Google-Smtp-Source: AOwi7QDtIqsoHtZzfxNOdcqF3H7ubJO9v1iiXGLHy/JrssGgKibCeQvCE+i6WpJT3+WLKC2mWiDSYNA+aRi726Y0iAk= X-Received: by 10.28.8.21 with SMTP id 21mr3205032wmi.23.1505496392351; Fri, 15 Sep 2017 10:26:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.164.6 with HTTP; Fri, 15 Sep 2017 10:26:11 -0700 (PDT) In-Reply-To: <097578bf-ab74-44cf-a465-dc6fdd50930f@Spark> References: <097578bf-ab74-44cf-a465-dc6fdd50930f@Spark> Date: Fri, 15 Sep 2017 19:26:11 +0200 Message-ID: To: ilija.tovilo@me.com Cc: PHP internals Content-Type: multipart/alternative; boundary="001a11442640ad551a05593db1bd" Subject: Re: [PHP-DEV] [RFC] Deprecate the extract function in PHP 7.3 From: ocramius@gmail.com (Marco Pivetta) --001a11442640ad551a05593db1bd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Heya, This is typically used in templating engines. The one I worked on is https://github.com/zendframework/zend-view/blob/5523511b6771cb6c060a77f6777= 426526a8db5ab/src/Renderer/PhpRenderer.php#L491-L492 Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Fri, Sep 15, 2017 at 7:20 PM, wrote: > Hi! > > The `extract` function takes an associative array and puts it into the > local symbol table. > http://php.net/manual/en/function.extract.php > > ``` > $array =3D [ > =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, > ]; > > extract($array); > > print $foo; // "foo" > ``` > > As a second parameter the `extract` function takes some options to make > this function less dangerous, like `EXTR_SKIP` that prevents an existing > local variable of being overwritten. There=E2=80=99s a few more options, = go ahead > and take a look at the documentation. `EXTR_OVERWRITE` is the default 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 deprecati= ng 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 co= uld only > find two usages of this function, both of which could be easily rewritten > in vanilla PHP: > https://github.com/symfony/symfony/blob/master/src/ > Symfony/Component/Templating/PhpEngine.php#L148 > https://github.com/symfony/symfony/blob/master/src/ > Symfony/Component/Templating/PhpEngine.php#L158 > > Only downside: A polyfill is probably impossible since you cannot mutate > the local symbol table of the callee (as far as I=E2=80=99m aware). > > Any thoughts? > > Regards > > > --001a11442640ad551a05593db1bd--