Take a contrived example where I want to call a protected static method from another context through a callback function:
class Foo {
protected static function toBeCalled() { }
public static function bar() {
functionThatAcceptsACallback(function () {
self::toBeCalled();
});
}
}
Is this possible in PHP 5.3? I couldn’t find a way to make it work…
It’s not possible, but it will be in 5.4 along with support for
$thisin a closure.Reference
Edit
This works in 5.4alpha1.