<?php
class MyClass2{
public $var = 123;
}
class MyClass{
public $var;
function __construct(){
$this->var = function(){
return new MyClass2();
};
}
}
function myFunc(){
return new MyClass();
}
$var = myFunc()->var;
echo $var()->var;
class MyClass2{
public $var = 123;
}
class MyClass{
public $var;
function __construct(){
$this->var = new MyClass2();
}
}
function myFunc(){
return new MyClass();
}
echo myFunc()->var->var;