2013-02-02 50 views
2

我对Phpstorm的继承属性的代码完成有问题。下面是我的代码示例。Phpstorm智能感知/继承属性的代码完成

class ParentClass 
{ 
    public $repository; 
} 

/* 
* @property Entity\SubClassRepository $repository 
*/ 
class SubClass extends ParentClass 
{ 
    public function __construct() 
    { 
    $this->repository= $this->em->getRepository('Entity\Subclass'); 
    } 

    public function ExampleFunction() 
    { 
    $this->repository-> !Here i need the code completion! 
    } 
} 

的getRepository函数返回PARAM =实体\子类SubClassRepository或返回OtherClassRepository用于PARAM =实体\ OtherClass。顺便说一句,它没有确切的类型,它返回。从而;我需要说Phpstorm是父类的类型$ repository对象。

我知道Phpstorm使用Phpdoc表示法来完成代码。因此我试图使用@property表示法并将下面的行添加到SubClass中。

/* 
* @property Entity\SubClassRepository $repository 
*/ 

它不起作用。你有什么主意吗? 非常感谢。

+1

这不是PHPDoc的。 PHPDoc以'/ **'开头,而普通注释'/ *' - 看到区别? – LazyOne

+0

加..你在'public __construct()'中错过了'function' - 但我想它是快速编辑和复制粘贴错误/错字。 – LazyOne

+0

@LazyOne哦,是的,我错过了*,如你所说。现在它正在工作。非常感谢。 –

回答

1

问题是关于@LazyOne在他的评论中说的注释中缺少*字符的问题。 @property标签现在正在运行完美。

它应该阅读:

/** 
* @property Entity\SubClassRepository $repository 
*/ 
+0

请标记你的问题'回答' – thaJeztah