本文介绍了JetBrains WebIDE:PHP变量类型提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有办法提示WebIDE变量具有某种类型?我必须迭代一个对象数组,并且没有自动完成功能.这在ZendStudio中有帮助:

Is there a way to hint WebIDE that a variable has some type?I have to iterate an array of objects, and there's no auto-completion available.This helps in ZendStudio:

/* @var ClassName $object */

我知道JetBrains中有一个功能来声明对象数组:

I know there's a feature in JetBrains to declare an array of objects:

/**
 * @return ClassName[]
 */

但这仅适用于函数的返回类型.

But this works only with function's return type.

推荐答案

/* @var ClassName $object */是无效的PHPDOC注释,并且在当前版本的Web IDE中未解析.使用双星号使其起作用:

/* @var ClassName $object */ is a non-valid PHPDOC comment and is not parsed in the current version of Web IDE. Use double asterisks to make it work:

/** @var ClassName $object */

此外,您可以用/** @var ClassName[] $array */注释foreach($array as $var)中的$array,并且将自动推导出$var类型.

Also, you can annotate $array in foreach($array as $var) with /** @var ClassName[] $array */ and $var type will be deduced automatically.

这篇关于JetBrains WebIDE:PHP变量类型提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 06:21