Skip to content

Commit

Permalink
phpdoc generics for Control
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 9, 2021
1 parent 4ed5243 commit cc84040
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Forms/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@

/**
* Defines method that must be implemented to allow a component to act like a form control.
* @template T
*/
interface Control
{
/**
* Sets control's value.
* @param T|null $value
* @param mixed $value
* @return static
*/
function setValue($value);

/**
* Returns control's value.
* @return T|null
* @return mixed
*/
function getValue();
Expand Down
3 changes: 3 additions & 0 deletions src/Forms/Controls/BaseControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
* @property-read array $errors
* @property-read array $options
* @property-read string $error
*
* @template T
* @implements Control<T>
*/
abstract class BaseControl extends Nette\ComponentModel\Component implements Control
{
Expand Down
1 change: 1 addition & 0 deletions src/Forms/Controls/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

/**
* Push button control with no default behavior.
* @extends BaseControl<string>
*/
class Button extends BaseControl
{
Expand Down
1 change: 1 addition & 0 deletions src/Forms/Controls/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

/**
* Check box control. Allows the user to select a true or false condition.
* @extends BaseControl<bool>
*/
class Checkbox extends BaseControl
{
Expand Down
2 changes: 2 additions & 0 deletions src/Forms/Controls/ChoiceControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*
* @property array $items
* @property-read mixed $selectedItem
*
* @extends BaseControl<array-key>
*/
abstract class ChoiceControl extends BaseControl
{
Expand Down
1 change: 1 addition & 0 deletions src/Forms/Controls/CsrfProtection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

/**
* CSRF protection field.
* @extends BaseControl<null>
*/
class CsrfProtection extends HiddenField
{
Expand Down
1 change: 1 addition & 0 deletions src/Forms/Controls/HiddenField.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

/**
* Hidden form control used to store a non-displayed value.
* @extends BaseControl<string>
*/
class HiddenField extends BaseControl
{
Expand Down
2 changes: 2 additions & 0 deletions src/Forms/Controls/MultiChoiceControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*
* @property array $items
* @property-read array $selectedItems
*
* @extends BaseControl<array-key[]>
*/
abstract class MultiChoiceControl extends BaseControl
{
Expand Down
1 change: 1 addition & 0 deletions src/Forms/Controls/TextBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

/**
* Implements the basic functionality common to text input controls.
* @extends BaseControl<string>
*/
abstract class TextBase extends BaseControl
{
Expand Down
1 change: 1 addition & 0 deletions src/Forms/Controls/UploadControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/**
* Text box and browse button that allow users to select a file to upload to the server.
* @extends BaseControl<FileUpload|FileUpload[]>
*/
class UploadControl extends BaseControl
{
Expand Down

0 comments on commit cc84040

Please sign in to comment.