How to make NetBeans auto complete better in PHP ?

NetBeans have good autocomplete, it helps productivity and reduce wasted time, but it can be better by using PHPDoc. NetBeans need to know what data types does the variable contains to be able to auto complete it to give it hints about what the data types of variables or function parameters.

Consider this example:

class class2 {
 
    /*
     * @var string
     */
    public $var = null;
 
}
 
class class1 {
 
    /**
     * @var class2 
     */
    static $some_class = null;
 
    /**
     * @var string 
     */
    static $some_var = null;
 
    /**
     * @param array $in_val
     * @return array
     */
    static function functionName($in_val) {
 
    }
}

After you add the PHPDoc values like above, if you try in your code doing something like this:

class1::$some_class->

it will give you a hint that it can be auto completed to:

class1::$some_class->var

and when you do:

class1::functionName(array())->

it will also hint to this:

class1::functionName(array())->var

Pretty powerful, isn’t it?

There is probably more details on PHPDoc than this. but for many, this little addition to autocomplete could make a big change.

Leave a Reply

Your email address will not be published. Required fields are marked *

(Your message will only be visible after moderation)