Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/217' into develop
Browse files Browse the repository at this point in the history
Close #217
  • Loading branch information
weierophinney committed Dec 11, 2018
2 parents cf0f94e + d172fff commit f9802ed
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ All notable changes to this project will be documented in this file, in reverse

### Added

- Nothing.
- [#217](https://github.com/zendframework/zend-form/pull/217) adds `Zend\Form\View\HelperTrait`, which can be used to provide IDE
autocompletion for view helpers provided by zend-form. See
https://docs.zendframework.com/zend-form/view-helpers/#ide-auto-completion-in-templates
for more information.

### Changed

Expand Down
24 changes: 24 additions & 0 deletions docs/book/view-helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ behaviors for you.

See the section on \[view helpers\](zend.view.helpers) for more information.

> ### IDE auto-completion in templates
>
> The `Zend\Form\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-form` with a pipe symbol (a.k.a. vertical
> bar) `|`:
> ```php
> /**
> * @var Zend\View\Renderer\PhpRenderer|Zend\Form\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.
## Standard Helpers
## HTML5 Helpers
Expand Down
118 changes: 118 additions & 0 deletions src/View/HelperTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php
/**
* @see https://github.com/zendframework/zend-form for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-form/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Form\View;

use IntlDateFormatter;
use Zend\Form\ElementInterface;
use Zend\Form\FormInterface;
use Zend\Form\View\Helper\Captcha\Dumb;
use Zend\Form\View\Helper\Captcha\Figlet;
use Zend\Form\View\Helper\Captcha\Image;
use Zend\Form\View\Helper\Captcha\ReCaptcha;
use Zend\Form\View\Helper\Form;
use Zend\Form\View\Helper\FormButton;
use Zend\Form\View\Helper\FormCaptcha;
use Zend\Form\View\Helper\FormCheckbox;
use Zend\Form\View\Helper\FormCollection;
use Zend\Form\View\Helper\FormColor;
use Zend\Form\View\Helper\FormDate;
use Zend\Form\View\Helper\FormDateSelect;
use Zend\Form\View\Helper\FormDateTime;
use Zend\Form\View\Helper\FormDateTimeLocal;
use Zend\Form\View\Helper\FormDateTimeSelect;
use Zend\Form\View\Helper\FormElement;
use Zend\Form\View\Helper\FormElementErrors;
use Zend\Form\View\Helper\FormEmail;
use Zend\Form\View\Helper\FormFile;
use Zend\Form\View\Helper\FormHidden;
use Zend\Form\View\Helper\FormImage;
use Zend\Form\View\Helper\FormInput;
use Zend\Form\View\Helper\FormLabel;
use Zend\Form\View\Helper\FormMonth;
use Zend\Form\View\Helper\FormMonthSelect;
use Zend\Form\View\Helper\FormMultiCheckbox;
use Zend\Form\View\Helper\FormNumber;
use Zend\Form\View\Helper\FormPassword;
use Zend\Form\View\Helper\FormRadio;
use Zend\Form\View\Helper\FormRange;
use Zend\Form\View\Helper\FormReset;
use Zend\Form\View\Helper\FormRow;
use Zend\Form\View\Helper\FormSearch;
use Zend\Form\View\Helper\FormSelect;
use Zend\Form\View\Helper\FormSubmit;
use Zend\Form\View\Helper\FormTel;
use Zend\Form\View\Helper\FormText;
use Zend\Form\View\Helper\FormTextarea;
use Zend\Form\View\Helper\FormTime;
use Zend\Form\View\Helper\FormUrl;
use Zend\Form\View\Helper\FormWeek;

// @codingStandardsIgnoreStart

/**
* Helper trait for auto-completion of code in modern IDEs.
*
* The trait provides convenience methods for view helpers,
* defined by the zend-form component. It is designed to be used
* for type-hinting $this variable inside zend-view templates via doc blocks.
*
* The base class is PhpRenderer, followed by the helper trait from
* the zend-form component. However, multiple helper traits from different
* Zend Framework components can be chained afterwards.
*
* @example @var \Zend\View\Renderer\PhpRenderer|\Zend\Form\View\HelperTrait $this
*
* @method string|Form form(FormInterface|null $form = null)
* @method string|FormButton formButton(ElementInterface|null $element = null, string|null $buttonContent = null)
* @method string|FormCaptcha formCaptcha(ElementInterface|null $element = null)
* @method string|Dumb formCaptchaDumb(ElementInterface|null $element = null)
* @method string|Figlet formCaptchaFiglet(ElementInterface|null $element = null)
* @method string|Image formCaptchaImage(ElementInterface|null $element = null)
* @method string|ReCaptcha formCaptchaRecaptcha(ElementInterface|null $element = null)
* @method string|FormCheckbox formCheckbox(ElementInterface|null $element = null)
* @method string|FormCollection formCollection(ElementInterface|null $element = null, bool $wrap = true)
* @method string|FormColor formColor(ElementInterface|null $element = null)
* @method string|FormDate formDate(ElementInterface|null $element = null)
* @method string|FormDateTime formDateTime(ElementInterface|null $element = null)
* @method string|FormDateTimeLocal formDateTimeLocal(ElementInterface|null $element = null)
* @method string|FormDateTimeSelect formDateTimeSelect(ElementInterface|null $element = null, int $dateType = IntlDateFormatter::LONG, int|null|string $timeType = IntlDateFormatter::LONG, string|null $locale = null)
* @method string|FormDateSelect formDateSelect(ElementInterface $element = null, $dateType = IntlDateFormatter::LONG, $locale = null)
* @method string|FormElement formElement(ElementInterface|null $element = null)
* @method string|FormElementErrors formElementErrors(ElementInterface|null $element = null, array $attributes = [])
* @method string|FormEmail formEmail(ElementInterface|null $element = null)
* @method string|FormFile formFile(ElementInterface|null $element = null)
* @method string formFileApcProgress(ElementInterface|null $element = null)
* @method string formFileSessionProgress(ElementInterface|null $element = null)
* @method string formFileUploadProgress(ElementInterface|null $element = null)
* @method string|FormHidden formHidden(ElementInterface|null $element = null)
* @method string|FormImage formImage(ElementInterface|null $element = null)
* @method string|FormInput formInput(ElementInterface|null $element = null)
* @method string|FormLabel formLabel(ElementInterface|null $element = null, string|null $labelContent = null, string|null $position = null)
* @method string|FormMonth formMonth(ElementInterface|null $element = null)
* @method string|FormMonthSelect formMonthSelect(ElementInterface|null $element = null, int $dateType = IntlDateFormatter::LONG, string|null $locale = null)
* @method string|FormMultiCheckbox formMultiCheckbox(ElementInterface|null $element = null, string|null $labelPosition = null)
* @method string|FormNumber formNumber(ElementInterface|null $element = null)
* @method string|FormPassword formPassword(ElementInterface|null $element = null)
* @method string|FormRadio formRadio(ElementInterface|null $element = null, string|null $labelPosition = null)
* @method string|FormRange formRange(ElementInterface|null $element = null)
* @method string|FormReset formReset(ElementInterface|null $element = null)
* @method string|FormRow formRow(ElementInterface|null $element = null, string|null $labelPosition = null, bool|null $renderErrors = null, string|null $partial = null)
* @method string|FormSearch formSearch(ElementInterface|null $element = null)
* @method string|FormSelect formSelect(ElementInterface|null $element = null)
* @method string|FormSubmit formSubmit(ElementInterface|null $element = null)
* @method string|FormTel formTel(ElementInterface|null $element = null)
* @method string|FormText formText(ElementInterface|null $element = null)
* @method string|FormTextarea formTextarea(ElementInterface|null $element = null)
* @method string|FormTime formTime(ElementInterface|null $element = null)
* @method string|FormUrl formUrl(ElementInterface|null $element = null)
* @method string|FormWeek formWeek(ElementInterface|null $element = null)
*/
trait HelperTrait
{
}
// @codingStandardsIgnoreEnd

0 comments on commit f9802ed

Please sign in to comment.