获取 PDT 代码完成以识别基类的运行时返回类型?
我有一个抽象基类:
abstract class BaseClass {
/**
* @return CLASSNAME
*/
public function fluent() {
// do stuff
return $this;
}
}
通常,我会将 BaseClass 放在 CLASSNAME 所在的位置,一切都会好起来的,PDT 会选择 phpdoc 返回类型并愉快地自动完成。
直到我对 BaseClass 进行子类化并添加其他方法,并且代码在派生类的实例上竞争。 PDT 将仅识别来自 BaseClass 的方法,而不识别来自派生类的方法。
我需要的是@return self 或@return this 之类的东西。
PDT有这样的功能吗?或者是否有其他技巧,而不必在每个派生类中声明这些方法?
I've got an abstract base class:
abstract class BaseClass {
/**
* @return CLASSNAME
*/
public function fluent() {
// do stuff
return $this;
}
}
Generally, i would put BaseClass where CLASSNAME is and all would be fine, PDT would pick up the phpdoc return type and happily autocomplete.
Until, that is, I subclass BaseClass and add additional methods, and code compete on an instance of the derived class. PDT will only recognise the methods from BaseClass and not those from the derived class.
What I need is something like @return self or @return this.
Does PDT have such functionality? Or is there an alternate trick without having to declare these methods in every derived class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK PDT 中没有这样的功能,但您至少可以使用类型提示:
然后您将拥有自动完成中派生的所有方法。我知道每次调用 Fluent() 时都写这个注释很烦人,但这仍然比一遍又一遍地重新定义每个派生类中的方法要好......
AFAIK there is no such feature in PDT, but you could use at least type hint:
Then you would have all methods from derived in autocompletion. I know its annoying to write this comment every time you call
fluent()
, but it is still better than re-defining the methods in each derived class over and over again...