Re: Proposal to deprecate create_function()

From: Date: Fri, 18 Oct 2013 11:06:01 +0000
Subject: Re: Proposal to deprecate create_function()
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-69669@lists.php.net to get a copy of this message
2013/10/18 Crypto Compress <cryptocompress@googlemail.com> > Am 18.10.2013 12:51, schrieb Alexey Zakhlestin: > > On 18.10.2013, at 14:39, Crypto Compress <cryptocompress@googlemail.com**> >> wrote: >> >> Am 18.10.2013 11:26, schrieb Nikita Popov: >>> >>>> 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) { >>>> static $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). >>>> >>> 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<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 fixing >>> >> >> 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. >> > > It is possible to write most of the array functions in plain php with a > trivial foreach. Can't see the point. That doesn't mean, that it was useful to include some array functions into the core. For example I still don't really get, why it was so important to get "array_column()" into the core, whereas it is _really_ trivial in PHP-userland [1]. In some cases it makes sense, for example for better performance, but imo it doesn't make sense only for the sake of itself. This said: Saying "but other xyz …" isn't an argument :) Regards, Sebastian [1] Don't want to start a discussion about that. Just needed an example. > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- github.com/KingCrunch

« previous php.internals (#69669) next »