Can I define a custom directory to autocomplete a function from?

Forgive me for the moderately confusing title.

I have a function that loads a file from a specific directory. Is it at all possible to docblock the function, such that PHPStorm will 'know' that the first argument is supposed to reference a file in that directory, and autocomplete / suggest filenames for me?

1

Hi there,

AFAIK -- no as there is no PHPDoc tags (or IDE supported ones) that would tell "inject file reference completion for this parameter".

Even if it would -- it would be relative to the project/resource roots (although you could mark such folder as "Resource root", it still would be "all resource roots" and not specific one).

At the same time, if you write custom plugin, then you surely can make such injection in the way you want it (many plugins do -- e.g. Laravel/Symfony one etc -- look how Laravel plugin offers completion for route() or view() functions).

P.S. Have a look at PHP Toolbox plugin as well, it offers various things based on JSON configs, maybe you can use it for your needs.

0

请先登录再写评论。