kolypto kolypto - 1 year ago 166
PHP Question

JetBrains WebIDE: PHP variable type hinting?

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 */

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.

Answer Source

/* @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 */

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download