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

时间:2014-09-13 04:06:32

标签: 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 aChild();'

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

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

 $parent->method()->method_from_child(123);

代码工作正常,父类返回另一个类(父类的成员),我可以直接使用该子类的公共函数。
但是,我无法让PHPStorm理解这一部分 代码帮助程序仅在$ parent-&gt; method()之前有效,但如果我添加另一个 - &gt;它只建议一个$ method。

0 个答案:

没有答案