Phpstorm PHP Storm-代码助手不适用于返回类的类

Phpstorm PHP Storm-代码助手不适用于返回类的类,phpstorm,Phpstorm,我有这样一个代码: 伪码 class parent { /** @var aChild */ // <---- this is the fix! that tells PHP Storm about the class, from now on it understands the chain. private $achild; // in constructor $achild is defined through a '$this->$achild = new

我有这样一个代码: 伪码

class parent
{
   /** @var aChild */  // <---- this is the fix! that tells PHP Storm about the class, from now on it understands the chain.
   private $achild;
   // in constructor $achild is defined through a '$this->$achild = new aChild();'

   public method()
   {
      return $this->achild;
   }
}

class aChild extends parent
{
   public method_from_child($x)
   {
   }
}

 $parent->method()->method_from_child(123);
代码工作得很好,parent返回另一个类,它是parent的成员,我可以直接使用该子类的公共函数。 然而,我无法让PHPStorm理解这一部分。
代码助手只在$parent->method之前有效,但如果我添加另一个->它只会建议再添加一个$method。

该死,我问这个问题太快了。在私有成员声明之前添加解决了此问题。/**@var aChild*/我建议在其他方法中添加正确的PHPDoc注释,并使用适当的@return标记等-这样更具确定性/故障保护。