From 1f1021bf9e1c82a60d7f6726bce5d71b5d6c18d3 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Sat, 11 Aug 2018 22:25:00 +0300 Subject: [PATCH 01/11] Add helper trait to provide type-hinting for zend-view --- src/View/HelperTrait.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/View/HelperTrait.php diff --git a/src/View/HelperTrait.php b/src/View/HelperTrait.php new file mode 100644 index 00000000..85644438 --- /dev/null +++ b/src/View/HelperTrait.php @@ -0,0 +1,30 @@ + Date: Wed, 5 Sep 2018 12:02:17 +0300 Subject: [PATCH 02/11] Add ending doc block annotation for ignoring coding standards --- src/View/HelperTrait.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/View/HelperTrait.php b/src/View/HelperTrait.php index 85644438..b23b8465 100644 --- a/src/View/HelperTrait.php +++ b/src/View/HelperTrait.php @@ -5,6 +5,7 @@ use IntlDateFormatter; // @codingStandardsIgnoreStart + /** * Trait HelperTrait * @@ -28,3 +29,4 @@ trait HelperTrait { } +// @codingStandardsIgnoreEnd From 7f3a1fc0134b8a92c8b72147f981885f7697c904 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 5 Sep 2018 12:04:57 +0300 Subject: [PATCH 03/11] Add doc block with copyright and license information --- src/View/HelperTrait.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/View/HelperTrait.php b/src/View/HelperTrait.php index b23b8465..0624ff0a 100644 --- a/src/View/HelperTrait.php +++ b/src/View/HelperTrait.php @@ -1,4 +1,9 @@ Date: Wed, 5 Sep 2018 12:08:40 +0300 Subject: [PATCH 04/11] Change comment in doc-block's description to properly address Zend Framework components --- src/View/HelperTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View/HelperTrait.php b/src/View/HelperTrait.php index 0624ff0a..92421516 100644 --- a/src/View/HelperTrait.php +++ b/src/View/HelperTrait.php @@ -20,7 +20,7 @@ * * The base class is PhpRenderer, followed by the helper trait from * the zend-i18n component. However, multiple helper traits from different - * Zend components can be chained afterwards. + * Zend Framework components can be chained afterwards. * * @example @var \Zend\View\Renderer\PhpRenderer|\Zend\I18n\View\HelperTrait $this * From 9c9c8f75de2ca8126e0319579081ac8da5b3b826 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 5 Sep 2018 12:35:42 +0300 Subject: [PATCH 05/11] Add data types for all @method parameters in the helper trait --- src/View/HelperTrait.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/View/HelperTrait.php b/src/View/HelperTrait.php index 92421516..59d6461f 100644 --- a/src/View/HelperTrait.php +++ b/src/View/HelperTrait.php @@ -24,12 +24,12 @@ * * @example @var \Zend\View\Renderer\PhpRenderer|\Zend\I18n\View\HelperTrait $this * - * @method string currencyFormat($number, $currencyCode = null, $showDecimals = null, $locale = null, $pattern = null) - * @method string dateFormat($date, $dateType = IntlDateFormatter::NONE, $timeType = IntlDateFormatter::NONE, $locale = null, $pattern = null) - * @method string numberFormat($number, $formatStyle = null, $formatType = null, $locale = null, $decimals = null, array $textAttributes = null) - * @method string plural($strings, $number) - * @method string translate($message, $textDomain = null, $locale = null) - * @method string translatePlural($singular, $plural, $number, $textDomain = null, $locale = null) + * @method string currencyFormat(float $number, string|null $currencyCode = null, bool|null $showDecimals = null, string|null $locale = null, string|null $pattern = null) + * @method string dateFormat(\DateTime|int|array $date, int $dateType = IntlDateFormatter::NONE, int $timeType = IntlDateFormatter::NONE, string|null $locale = null, string|null $pattern = null) + * @method string numberFormat(int|float $number, int|null $formatStyle = null, int|null $formatType = null, string|null $locale = null, int|null $decimals = null, array|null $textAttributes = null) + * @method string plural(array|string $strings, int $number) + * @method string translate(string $message, string|null $textDomain = null, string|null $locale = null) + * @method string translatePlural(string $singular, string $plural, int $number, string|null $textDomain = null, string|null $locale = null) */ trait HelperTrait { From 013008b9d854933971d663bac6256e65390f37b7 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 5 Sep 2018 12:36:57 +0300 Subject: [PATCH 06/11] Add a more descriptive title of the helper trait --- src/View/HelperTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View/HelperTrait.php b/src/View/HelperTrait.php index 59d6461f..b0b5179a 100644 --- a/src/View/HelperTrait.php +++ b/src/View/HelperTrait.php @@ -12,7 +12,7 @@ // @codingStandardsIgnoreStart /** - * Trait HelperTrait + * Helper trait for auto-completion of code in modern IDEs. * * The trait provides convenience methods for view helpers, * defined by the zend-i18n component. It is designed to be used From f9b5d9cd8cde91c30541b0adea6bd2bb428e2422 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Thu, 6 Sep 2018 01:47:22 +0300 Subject: [PATCH 07/11] Replace the year range with the current year in the copyright doc-block --- src/View/HelperTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View/HelperTrait.php b/src/View/HelperTrait.php index b0b5179a..424512fc 100644 --- a/src/View/HelperTrait.php +++ b/src/View/HelperTrait.php @@ -1,7 +1,7 @@ Date: Wed, 12 Sep 2018 16:59:11 +0300 Subject: [PATCH 08/11] Add documentation for HelperTrait for IDE auto-completion --- docs/book/view-helpers.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/book/view-helpers.md b/docs/book/view-helpers.md index 48d93612..bf405790 100644 --- a/docs/book/view-helpers.md +++ b/docs/book/view-helpers.md @@ -7,6 +7,29 @@ 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\Helper\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\I18n\View\Helper\HelperTrait|Zend\I18n\View\Helper\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 From 3e04da1c154b44efe05525041de7905b717c49e1 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 12 Sep 2018 17:03:25 +0300 Subject: [PATCH 09/11] Fix wrong type-hint --- docs/book/view-helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/book/view-helpers.md b/docs/book/view-helpers.md index bf405790..3c476f42 100644 --- a/docs/book/view-helpers.md +++ b/docs/book/view-helpers.md @@ -22,7 +22,7 @@ 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\I18n\View\Helper\HelperTrait|Zend\I18n\View\Helper\HelperTrait $this + * @var Zend\View\Renderer\PhpRenderer|Zend\I18n\View\Helper\HelperTrait $this */ ``` From 794901446d9bcd919dde0933fa47dff526fb4adc Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 12 Sep 2018 18:14:49 +0300 Subject: [PATCH 10/11] Move the docs section for IDE auto-completion inside a block quote and nest the headings one level further --- docs/book/view-helpers.md | 45 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/docs/book/view-helpers.md b/docs/book/view-helpers.md index 3c476f42..68bc994a 100644 --- a/docs/book/view-helpers.md +++ b/docs/book/view-helpers.md @@ -7,28 +7,29 @@ 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\Helper\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\Helper\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. +> ### IDE auto-completion in templates +> +> The `Zend\I18n\View\Helper\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\Helper\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 From fa2136b3473161ee5d1fc654a9183eee9000971b Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 12 Sep 2018 21:30:05 +0300 Subject: [PATCH 11/11] Fix wrong namespace in docs for HelperTrait and re-align code example --- docs/book/view-helpers.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/book/view-helpers.md b/docs/book/view-helpers.md index 68bc994a..0d92a597 100644 --- a/docs/book/view-helpers.md +++ b/docs/book/view-helpers.md @@ -9,9 +9,9 @@ for more information. > ### IDE auto-completion in templates > -> The `Zend\I18n\View\Helper\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. +> 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 > @@ -23,8 +23,8 @@ for more information. > bar) `|`: > ```php > /** -> * @var Zend\View\Renderer\PhpRenderer|Zend\I18n\View\Helper\HelperTrait $this -> */ +> * @var Zend\View\Renderer\PhpRenderer|Zend\I18n\View\HelperTrait $this +> */ > ``` > > You may chain as many `HelperTrait` traits as you like, depending on view