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
-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.