|
|
|
|
|
by deweller
5357 days ago
|
|
I think a good use case is to solve the problem of calling a closure and passing $this. In PHP 5.3, this is not allowed: class MyClass {
public function doSomething() {
$delegate = new SomeDelegateClass();
// the following line is not allowed
$delegate->doSomethingWithClosure(function($app) use ($this) {
// do something with $app
});
}
You can now solve this problem simply with the bindTo method. |
|
So here's how you could solve this "problem" before bindTo(), it's explicit and simple and it doesn't even need use: