Netbeans Autocomplete on Class Properties Using PHPDoc

This is post is now quite old and the the information it contains may be out of date or innacurate.

If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub

If you are using netbeans for PHP classes and you have some of your class properties are instances of other objects and you want to get autocomplete working for them, then you might struggle to figure out which PHPDoc syntax to use to get autocomplete working.

Here is the answer:

/**
* @property MyObject $myObject
* @property AnotherObject $anotherObject
*/
class MyClass{

     protected $myObject;
     protected $anotherObject;
     
     public function __construct($myObject, $anotherObject){
         $this->myObject=$myObject;
         $this->anotherObject=$anotherObject;
     }
     
     public function autocomplete(){
         $this->myObject->//autocomplete works here
     }
     
}

Tags: phpnetbeansobjectautocompletephpdocclass