Is it possible to access classes/objects reffered as self
, static
and $this
in anonymous callbacks in PHP? Just like this:
class Foo {
const BAZ = 5;
public static function bar() {
echo self::BAZ; // it works OK
array_filter(array(1,3,5), function($number) /* use(self) */ {
return $number !== self::BAZ; // I cannot access self from here
});
}
}
Is there any way to make it behave as with usual variables, using use(self)
clause?