Variable type hinting in Netbeans (PHP) Variable type hinting in Netbeans (PHP) php php

Variable type hinting in Netbeans (PHP)


A single line is all you need:

/* @var $varName Type_Name */

See this article in the NetBeans PHP Blog: https://blogs.oracle.com/netbeansphp/entry/defining_a_variable_type_in

Note: At least, in version 8.2; The key seems to be:

  • The single asterisk (/* instead of /**).
  • Placing the type after the variable name.
  • Having nothing before and after the type-hinting (except white-space, but even that is not allowed when the comment is not in a single line).


I know this is an older question, but I was looking for a similar answer for Eclipse/Zend Studio and this solved it as well.

**Note though that it must be on a single line with the opening and closing explicitly in this style...

/* @var $varName Type_Name */

No other formats whether...

/** * @var $varName Type_Name */ 

or...

// @var $varName Type_Name

seemed to work at all. Hope that helps someone.


Are you looking to document those pesky magic variables? (I did; This question currently ranks top result for that in Google. I hope this helps someone!)

The @property tag allows you to document magic php variables - those implemented using __get() and __set(). The tag should be used in the documentation immediately preceding the class definition:

/** * Class Contact * @property string $firstName * @property string $lastName */class Contact extends Model {   ...

This notation triggers autocomplete, tested in Netbeans 8.1 and PhpStorm 2016.1.

enter image description here