Skip to content

Instantly share code, notes, and snippets.

@mcuadros
Last active August 29, 2015 14:00
Show Gist options
  • Save mcuadros/11189569 to your computer and use it in GitHub Desktop.
Save mcuadros/11189569 to your computer and use it in GitHub Desktop.
<?hh
type Example = (function(): string);
function main() {
$callback = function() {
return 'foo';
};
echo acceptCallable($callback);
echo acceptCallable(['Foo', 'printBar']);
}
class Foo {
function printBar(): string {
return 'bar';
}
}
function acceptCallable(callable $callback): mixed {
return $callback();
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment