Php – this in the context of a callable?
class foo { function bar(callable $callable) { $callable(); } function printStr() { echo "hi"; } } $foo = new foo(); $foo->bar(function () { $this->printStr(); // Using $this when not in object context }); Yes, you need to pass an anonymous…