How to get intellisense for PHP associative array index?

Possible duplicate:
PHPDoc for variable length argument arrays

Whenever I type $_SERVER[''] and press Ctrl + Space, it gives me a list of possible indexes. How can I create an array that I created?

+4
source share
3 answers

Code completion for $_SERVER gives hints about the typical values ​​that people have chosen from this associative array. It is hardcoded somewhere in the NetBeans source code. For an arbitrary array, NetBeans has no clue about the keys that are used in any array, and thus does not give any hints. You can even prove that it is impossible to reliably implement such a function, so I think you are out of luck here.

+3
source

If you use variables as objects, you can create a fake empty class with properties and phpDOC for each property , declare an object of this class, and netbeans will autocomplete properties (object keys).

  <?php namespace Models\Geo; /** * Results from GeoNames. * Dummy class for autocompletition only * See http://trac/wiki/Geo * * @property string $countryName * @property string $adminCode1 * ... * @property string $population * * @category BNT * @package Library */ class GeoNamesResult { } ?> 

Then in netbeans code

 <?php /* @var $obj \Models\Geo\GeoNamesResult */ $obj-> // will autocomplete with countryName, adminCode1 etc... ?> 

Of course, if the function returns $ obj and has phpDoc @return, there is no need to use the @var comment

+1
source

You cannot, but it is best to use phpDocumentor to document your code.

0
source

All Articles