Re: Proposal to deprecate create_function()
| From: | Crypto Compress | Date: | Fri, 18 Oct 2013 10:57:53 +0000 |
| Subject: | Re: Proposal to deprecate create_function() | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-69668@lists.php.net to get a copy of this message | ||
Am 18.10.2013 12:51, schrieb Alexey Zakhlestin:
On 18.10.2013, at 14:39, Crypto Compress <cryptocompress@googlemail.com> wrote:It is possible to write most of the array functions in plain php with a trivial foreach. Can't see the point.Am 18.10.2013 11:26, schrieb Nikita Popov:I think you misunderstood Nikita's proposal. "all these lines" can be put in a library and your code would just continue to work the way it is. Idea is that it is trivially implemented in userland and there is no much sense to keep it in core.You can even replicate the exact behavior (minus the hiding from get_defined_functions) with just four lines of code (though I have no idea what you could possibly need this for): function create_function($params, $code) {shure all things can be replaced with more and verbose code. What is the benefit of writing all this lines in contrast to one method call? https://github.com/phpcr/phpcr-utils/blob/master/src/PHPCR/Util/Console/Helper/PhpcrCliHelper.php#L111 -1 for removing wrappers/abbreviations/and such +1 for bug fixingstatic $i = 0; $name = "create_function_" . $i++; eval("function $name($params) { $code }"); return $name;} I tried to look on Github what people currently use create_function for, but with little success. Nearly all results I get are uses in the php testsuite (copied over to various projects). The only other use case I saw was in conjunction with the WordPress add_action() function. In this case the create_function call could always be replaced directly with an anonymous function (i.e. it didn't need any magic create_function capabilities).