Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69682 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49288 invoked from network); 18 Oct 2013 13:55:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Oct 2013 13:55:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.169 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.169 mail-wi0-f169.google.com Received: from [209.85.212.169] ([209.85.212.169:39766] helo=mail-wi0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/05-23638-7DD31625 for ; Fri, 18 Oct 2013 09:55:36 -0400 Received: by mail-wi0-f169.google.com with SMTP id cb5so2411591wib.0 for ; Fri, 18 Oct 2013 06:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Qz3ownpELbbqbvUC3LuoVji98M3b+2K6lsEJrk2565s=; b=QVP8M3dFJ4kgvoxB/gaTdoxN6J8fr4oTCXwQH9KqZdOFjSnYxeTNXvhOFyHirQ2cNn e/HsFOxMKH8nmMKpF85L2okbIOTdxrM6CGaAWYA7KyZjbzjWJztl+SZalFAW3KEgAq/f LM8nJD8zGzRH77LnHZNv1tXESZ1Ny402BqmOoNJ6gK7D9Cy7VJVXZ0TSAYlMgF6ZYLnF eb7vKhqeK65RMTNAItcMWEzaG6HVYF6YjjTv2+G4Ak2w2Xrvueh6fnSIGqKdRWmorqKX VWpb4y82v1BHcrZCGCHGudcxWqsAuWyh3I9Mi4wJk3qJz2Oc9htxdZCeOknFs/xzuYkk iPiQ== X-Received: by 10.180.208.2 with SMTP id ma2mr2590791wic.52.1382104532833; Fri, 18 Oct 2013 06:55:32 -0700 (PDT) Received: from [192.168.0.2] (cpc19-brig17-2-0-cust25.3-3.cable.virginmedia.com. [81.101.201.26]) by mx.google.com with ESMTPSA id e1sm27278471wij.6.2013.10.18.06.55.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 06:55:32 -0700 (PDT) Message-ID: <52613DCD.2010301@gmail.com> Date: Fri, 18 Oct 2013 14:55:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: PHP Internals References: <525C631E.1050008@gmail.com> <526136F8.6050300@rotorised.com> In-Reply-To: <526136F8.6050300@rotorised.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Proposal to deprecate create_function() From: rowan.collins@gmail.com (Rowan Collins) On 18/10/2013 14:26, Ryan McCue wrote: > I can say with confidence that if this gets in to PHP, we'll integrate > BC support as above (although probably some function name like > `_wp_anonymous_function_$i`), and the only real reason we still have > this is 5.2 support. > > I suspect by the time 5.next rolls around, we'll be at least considering > dropping 5.2, but that of course depends on usage. At the very least, > the plugin ecosystem is starting to look towards dropping 5.2 support, > which is where the big issue will be anyway, so that's nice. > > (FWIW, I always hated the create_function() calls in WordPress anyway.) That's interesting to hear - I have no knowledge of the Wordpress community and decision-making apparatus, so wasn't sure what the reaction would be. While digging around for references, I did find this ticket about removing a lot of the create_functions from core: http://core.trac.wordpress.org/ticket/14424 The usages I did find in the core code were what inspired my idea for a wrapper that took a list of variables to "close over" (like a use() clause without the extra syntax) and used var_export() to inject them into the function body, as that is the pattern used in a few places. The other interesting case I spotted was creating a function which always returned the same string (an SQL LIMIT clause), so that it could be registered as a filter callback. That could use an even simpler BC-wrapper, which wouldn't need any eval() at all in >=5.3 (as long as code was arranged such that older versions didn't try to compile it): function lambda($return_value) { return function() use($return_value) { return $return_value; }; } A fallback definition for <=5.2 would have a single var_export: function lambda($return_value) { return create_function('', 'return ' . var_export($return_value, true) . ';'); } -- Rowan Collins [IMSoP]