有没有一种方法,使PhpStorm的自动完成"深究下去"? [英] Is there a way to make PhpStorm's autocomplete "go deeper"?

查看:129
本文介绍了有没有一种方法,使PhpStorm的自动完成"深究下去"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PhpStorm,如果我创建了一个对象,那么我所有的汽车的目标努力完成罚款:

In PhpStorm, if I create an object, then I have all auto complete on that object working fine:

$object = new MyClass();
$object->getNa...

将自动完成,以

$object->getName();

到目前为止好,但如果我通过第一方法返回一个对象,然后自动完成将无法在正常工作。

So far so good, but if I get returned an object through the first method, then the auto complete will not work on that.

$car->getDriver()->getNam...

将显示一个空列表。
该getDriver方法都有其PHPDoc的@return标签设置为驱动程序,虽然和一些其他IDE,因此这个工程以获得正确的自动完成。

Will show an empty list. The getDriver method has its PHPDoc @return tag set to 'Driver' though and in some other IDEs, this therefore works to get the correct auto complete.

知道如果有,我错过了某处的设置,或者如果PhpStorm不提供这种先进的自动完成没有?

Wondering if there's a setting that I missed somewhere or if PhpStorm doesn't offer this kind of advanced auto complete yet?

推荐答案

功能 getDriver()需要适当类型的提示的返回值(函数的文档块):

The function getDriver() needs appropriate type-hints for the return value (function's docblock):

  * @return classOrInterfaceName

这是正常足有一个IDE走得更深。我是pretty确保Phpstorm支持,但我不是一个Phpstorm用户。

This is normally enough to have a IDE "go deeper". I'm pretty sure Phpstorm supports that, but I'm not a Phpstorm user.

以关怀与接口文件/类是项目内或引用它。

Take care the file with the interface/class is within the project or referenced to it.

作为一个工作,你可以左右的返回值赋给一个变量和类型暗示变量。可能不是舒服,但能有所帮助。

As a work around you can assign the return value to a variable and type-hint that variable. Might not be that comfortable but can help.

这篇关于有没有一种方法,使PhpStorm的自动完成"深究下去"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆