我正在使用eclipse IDE for php [4.9.0]我正在尝试获取自动完成类型提示以用于类内部的值,即我正在使用的注释
/* @var $helper_class base_helper_object */
看起来正确,但似乎无法正常工作,我找到了解决方法,但我认为应该有更好的方法来完成此操作。
// dirty work around
if(false) $this->helper_class = new base_helper_object();
class worker_b extends other_class
{
protected $helper_class = null;
/* @var $helper_class base_helper_object */
// ... other code here
public function do_stuff()
{
if($this->helper_class != null)
{
$this->helper_class->do_other_stuff();
// !! ---------------------------------- !!
// helper_class at this point does not have type hinting
// !! ---------------------------------- !!
// dirty work around
if(false) $this->helper_class = new base_helper_object();
$this->helper_class->do_other_stuff();
// helper_class now has type hinting
}
}
}