Last active
January 20, 2019 01:38
-
-
Save krmgns/e3fd79b91bfe5c047e914fdfa1d4ab47 to your computer and use it in GitHub Desktop.
PHP: copy_function()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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