如何通过构造中的返回值初始化类的基类?假设我有这个作为基类:
class Base
{
public function Foo()
{
}
private $_var;
}
我也有来自另一个类的这个静态方法,它返回基类:
class MyStaticClass
{
public static function Get()
{
return new Base();
}
}
现在我在这里从基类派生它:
class Derived extends Base
{
public function __construct()
{
// Here, how can I initialize Base class with
// object MyStaticClass returns? Something like
parent = MyStaticClass::Get(); // This doesn't obviously work..
}
}
有什么解决方案/解决方法吗?