Laravel和PhpStorm自动代码提示



我有一个返回集合的类:

public function getCustomers() : Collection;

当我循环结果时,PhpStorm IDE 不会知道集合中的内容。

在 .NET/JAVA 中,你可以写:

public <List<Customer>> getCustomers();

然后 IDE 将知道集合中的内容,并知道如何完成/提示。

有什么技巧可以把它介绍给PhpStorm吗?

使用文档块很容易:

/**
 * @return Customer[]|Collection
 */
public function getCustomers();

本质上,您在这里所做的是告诉phpStorm该函数还返回了客户对象和集合的数组。

您可以键入提示多个回车符,用管道符号分隔它们 |

最新更新