Skip to content

Instantly share code, notes, and snippets.

@dhrrgn
Created September 15, 2014 15:24
Show Gist options
  • Save dhrrgn/94daf599351aeda4fbcb to your computer and use it in GitHub Desktop.
Save dhrrgn/94daf599351aeda4fbcb to your computer and use it in GitHub Desktop.
<?php
class Foo {
private $closure;
public function __construct(Closure $closure)
{
$this->closure = $closure;
}
public function __invoke(array $args = [])
{
// This does not work: $this->closure(...$args);
// Have to get the closure first?
$closure = $this->closure;
return $closure(...$args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment