Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100639 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42899 invoked from network); 15 Sep 2017 17:30:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Sep 2017 17:30:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.173 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 209.85.223.173 mail-io0-f173.google.com Received: from [209.85.223.173] ([209.85.223.173:56884] helo=mail-io0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BB/73-19300-84E0CB95 for ; Fri, 15 Sep 2017 13:30:48 -0400 Received: by mail-io0-f173.google.com with SMTP id m103so10070550iod.13 for ; Fri, 15 Sep 2017 10:30:48 -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=E6Km664owmZ5eIUZv6p6wIwrgzLoIj6GDeqpKsLgwHY=; b=kTXXd9c6nRSZR+IhaV9efrGcFgGpTAkw9fn/UTMKJywXhk6Qpf/YCUqaRaHf6WbIZB iyr0/1tZ/39gS2g040AUzf9E2MPKN0yR/eikV9XTggIu0tmGi27RtLGTAsXxetUaEUF9 kOpDpth6kC6dclwDejvE+03eiASTbzwfNPoy+YV875eZByYc3IUkMBkoScXxwjnDOszG fdemUlWudd3JMcqLEl4NYuZUOVKSpVwC+8aOgFcpdWRs19rv7c3nsvckzsu85tfmpjLj YENcXr8/XFNtikQ19n1ZmIOHsvy0AaN6jN3dQRWH/WTJxdedfkImv+ERP22IrxEsViDR 6xLw== 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=E6Km664owmZ5eIUZv6p6wIwrgzLoIj6GDeqpKsLgwHY=; b=uQTYqC1b52ol8XYQZK/Tv/23nezpTWfsJ2P9Mz8fK9Z0MSAyEj8BFh7MeFz24b/r2m FUiGl2A1JN3Q86Gx0WDI0raAnOBXxYzozfcdBY3xhMtaGoRob5wS8AARUUSm7NyJfoq3 o33jXQrdxlODx+cM/xi6JC5/SFITmpJkTUjEwEv8953rEmY6cXvv5A08IHla5Kk7H6ne kpneIrAXwOSHJo3RunFvCElCMpQ3qIKKzjQWYkXYJSYIw3ICiBO8/uVwPqv0l/SzmjFV 1HCWWTNeH2GkuoWePYsAOuyucTh6rtpBd5fdjg652bhJeSqk3XeAx7AvXWTr1hUMeqZZ 0swg== X-Gm-Message-State: AHPjjUh9zxlMSma7FKgMgxjXrdDhs23/PcYHje+uTmaUi7gkmODrDd24 zcEAqgingbV+ieWx4NGgTWaSazd7YkdBegJbkg== X-Google-Smtp-Source: AOwi7QAcHXDr40+HoBsS4jKEjH67W+RCtYXCpyHfX79W9tPWJH3QuXNcrD+vuW4FNBXBVnkZJ0z1rzxr9Zv4ErwoXhw= X-Received: by 10.202.172.12 with SMTP id v12mr28036833oie.105.1505496645433; Fri, 15 Sep 2017 10:30:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.61.117 with HTTP; Fri, 15 Sep 2017 10:30:44 -0700 (PDT) Received: by 10.157.61.117 with HTTP; Fri, 15 Sep 2017 10:30:44 -0700 (PDT) In-Reply-To: <097578bf-ab74-44cf-a465-dc6fdd50930f@Spark> References: <097578bf-ab74-44cf-a465-dc6fdd50930f@Spark> Date: Fri, 15 Sep 2017 11:30:44 -0600 Message-ID: To: ilija.tovilo@me.com Cc: PHP internals Content-Type: multipart/alternative; boundary="001a113ce3f4c300e605593dc07d" Subject: Re: [PHP-DEV] [RFC] Deprecate the extract function in PHP 7.3 From: derokorian@gmail.com (Ryan Pallas) --001a113ce3f4c300e605593dc07d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sep 15, 2017 11:22 AM, 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 deprecating= 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 coul= d 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? I see no gain by removing this function. I've also seen it used for templating quite often. Yes the functionality could be changed not to use extract and end up working the same to the consumer but why make people rewrite these things for no apparent gain (and likely a small performance hit)? Regards --001a113ce3f4c300e605593dc07d--