Skip to content

Instantly share code, notes, and snippets.

@k-gun

k-gun/copy_function.php

Last active Jan 20, 2019
Embed
What would you like to do?
PHP: copy_function()
<?php
function copy_function($name) {
$reflection = new ReflectionFunction($name);
return function(...$arguments) use($reflection) {
return call_user_func_array([$reflection, 'invoke'], $arguments);
};
}
$fn = copy_function('is_int');
var_dump($fn(123));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.