diff --git a/docs/book/view-helpers.md b/docs/book/view-helpers.md index 48d93612..0d92a597 100644 --- a/docs/book/view-helpers.md +++ b/docs/book/view-helpers.md @@ -7,6 +7,30 @@ displaying translated content. See the [zend-view helpers documentation](http://framework.zend.com/manual/current/en/modules/zend.view.helpers.html#zend-view-helpers) for more information. +> ### IDE auto-completion in templates +> +> The `Zend\I18n\View\HelperTrait` trait can be used to provide auto-completion +> for modern IDEs. It defines the aliases of the view helpers in a DocBlock as +> `@method` tags. +> +> #### Usage +> +> In order to allow auto-completion in templates, `$this` variable should be +> type-hinted via a DocBlock at the top of your template. It is recommended that +> you always add the `Zend\View\Renderer\PhpRenderer` as the first type, so that +> the IDE can auto-suggest the default view helpers from `zend-view`. Next, +> chain the `HelperTrait` from `zend-i18n` with a pipe symbol (a.k.a. vertical +> bar) `|`: +> ```php +> /** +> * @var Zend\View\Renderer\PhpRenderer|Zend\I18n\View\HelperTrait $this +> */ +> ``` +> +> You may chain as many `HelperTrait` traits as you like, depending on view +> helpers from which Zend Framework component you are using and would like to +> provide auto-completion for. + ## CurrencyFormat Helper The `CurrencyFormat` view helper can be used to simplify rendering of localized diff --git a/src/View/HelperTrait.php b/src/View/HelperTrait.php new file mode 100644 index 00000000..424512fc --- /dev/null +++ b/src/View/HelperTrait.php @@ -0,0 +1,37 @@ +