Does anyone know if PHPStorm has some builtin support for view helper autocompletion or a possibility to write a plugin for it. I don't want to use inline var definitions for this as this would be cumbersome to do if I use a lot of view helpers
$this->inlineScript()-> //I want some autocomplete here.
$this->translate('some translation')-> //Please give me autocompletion
If I use var definitions it will end up as something like this, but it will really clutter up my view:
/* @var $inlineScript \Zend\View\Helper\InlineScript */
$inlineScript = $this->inlineScript();
$inlineScript-> //Now I have autocompletion goodness
/* @var $translate \Zend\I18n\View\Helper\Translate */
$translate = $this->translate();
$translate('some translation')-> //Now I have autocompletion goodness
NOTE I'm posting my method discussed in the comments as answer.
To typehint non-existing methods, the syntax is as following:
This allows us to use have a type-hint for method
url
on any variable recognized asMyClass
:You need such a "fake" class and then start your view scripts with:
That will give you type-hints on
$this
within your view script. You could ideally open a pull request against https://github.com/zendframework/zf2 with something similar to https://github.com/zendframework/zf2/pull/3438