Skip to content

Instantly share code, notes, and snippets.

/named.php Secret

Created March 22, 2015 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c438a64b7147e122e34b to your computer and use it in GitHub Desktop.
Save anonymous/c438a64b7147e122e34b to your computer and use it in GitHub Desktop.
<?php
interface NamedCallback {
public function __invoke(string $foo, bool $bar): string;
}
function func(NamedCallback $cb) {
var_dump($cb("Hello", true));
}
func(new class implements NamedCallback {
public function __invoke(string $foo, bool $bar): string {
return $bar ? strrev($foo) : $foo;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment