<?php
class MyClass
{
private $prop = "teste";
public function test()
{
$class = new class($this) {
public function __construct($obj)
{
$this->obj = $obj;
}
public function run()
{
echo $this->obj->prop, PHP_EOL;
}
};
$class->run();
}
}
$obj = new MyClass();
$obj->test();
PD9waHAKCgpjbGFzcyBNeUNsYXNzCnsKCXByaXZhdGUgJHByb3AgPSAidGVzdGUiOwogCiAgICBwdWJsaWMgZnVuY3Rpb24gdGVzdCgpCiAgICB7CiAgICAgICAgJGNsYXNzID0gbmV3IGNsYXNzKCR0aGlzKSB7CiAKICAgICAgICAgICAgcHVibGljIGZ1bmN0aW9uIF9fY29uc3RydWN0KCRvYmopCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICR0aGlzLT5vYmogPSAkb2JqOwogICAgICAgICAgICB9CiAKICAgICAgICAgICAgcHVibGljIGZ1bmN0aW9uIHJ1bigpIAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBlY2hvICR0aGlzLT5vYmotPnByb3AsIFBIUF9FT0w7CiAgICAgICAgICAgIH0KIAogICAgICAgIH07CiAKICAgICAgICAkY2xhc3MtPnJ1bigpOwogICAgfQp9CiAKJG9iaiA9IG5ldyBNeUNsYXNzKCk7CiRvYmotPnRlc3QoKTs=