Skip to content

Instantly share code, notes, and snippets.

@mnapoli
Created August 9, 2013 14:58
Show Gist options
  • Save mnapoli/6194324 to your computer and use it in GitHub Desktop.
Save mnapoli/6194324 to your computer and use it in GitHub Desktop.
Tryout with Friend services
<?php
// http://3v4l.org/e9RNO
class Foo {
private $bar = 'hello world';
}
class FriendOfFoo {
public function doSomething($foo) {
return function() use ($foo) {
echo $foo->bar;
};
}
}
$foo = new Foo();
$service = new FriendOfFoo();
$closure = $service->doSomething($foo)->bindTo(null, $foo);
$closure();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment