I have:
$myarr['DB'] = new DB(); $myarr['config'] = new config();
Can I somehow PHPStorm find out what exactly is inside these keys? So far I see only hints of the variables and properties of the class, but not the keys of the array.
You can predefine the keys of the array, then suggest PHPStorm (CTRL + space)
$my = array(); $my['qwe'] = ''; $my['asd'] = ''; $my['zxc'] = ''; $my['']// inside '' will be autosuggest
You can also use phpdoc (CTRL + Q):
/** * keys: * <pre> * some_array (array) * some_bool (boolean) * some_double (double) * some_nice_integer (integer) * </pre> * @return array */ public function toArray(){ // return some array }
This functionality is not yet implemented in PhpStorm. Vote for array support .
You can also try the silex plugin .
For an arbitrary array, PHPStorm has no idea about the keys that are used in any array, and therefore does not give hints. You can even prove that it is impossible to reliably implement such a function, so I think you are out of luck here.
Collected from:
Stop request response
https://plugins.jetbrains.com/plugin/9927-deep-assoc-completion
Image from github repo plugin. I use the plugin and can confirm that it works as described.
$obj = (object)[]; // Cast empty array to object add properties: $obj->x = 'some' $obj->y = 'hints'
Now, PHPStorm, when typing $obj-> ..... hints at x and y
$obj->