I'm trying to access the instance of the class where it contains an anonymous as we do in Java, eg:
JAVA
class MyClass
{
private String prop = "test";
public void test()
{
new Runnable() {
public void run()
{
// I can access MyClass.this from here
System.out.println(MyClass.this.prop);
}
}.run();
}
}
PHP 7
<?php
class MyClass
{
private $prop = "test";
public function test()
{
$class = new class{
public function run()
{
// ???? MyClass::$prop ????
}
};
}
}
How can I access the MyClass instance from within the anonymous?