Created
August 9, 2013 14:58
-
-
Save mnapoli/6194324 to your computer and use it in GitHub Desktop.
Tryout with Friend services
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 | |
// 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