Autocompletion for ZF2 view helpers in PhpStorm

醉酒当歌 提交于 2019-12-04 08:47:36

NOTE I'm posting my method discussed in the comments as answer.

To typehint non-existing methods, the syntax is as following:

/**
 * @method \Zend\Mvc\Controller\Plugin\Url url(string $route = null, array $params = null)
 */
class MyClass
{
}

This allows us to use have a type-hint for method url on any variable recognized as MyClass:

/* @var $a \MyClass */
$a->// typehint!

You need such a "fake" class and then start your view scripts with:

/* @var $this \MyFakeClass */

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!