3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $test; public function setTest($value) { $this->test = $value; return $this; } public function getPrivatePropertyOfAnotherOject(A $obj) { return $obj->test; } } $a = (new A())->setTest('x'); var_dump((new A())->getPrivatePropertyOfAnotherOject($a));

preferences:
35.55 ms | 402 KiB | 5 Q