From 5a1296f8441a25eeacef7df63496693b32503f7d Mon Sep 17 00:00:00 2001 From: Samuel De Backer Date: Tue, 26 Apr 2022 09:37:09 +0200 Subject: [PATCH] More type hinting --- src/Binding/BoundData.php | 5 +--- src/Elements/Button.php | 10 ++------ src/Elements/Checkbox.php | 15 +++--------- src/Elements/Date.php | 5 +--- src/Elements/DateTimeLocal.php | 5 +--- src/Elements/Element.php | 5 +--- src/Elements/Email.php | 5 +--- src/Elements/File.php | 5 +--- src/Elements/FormOpen.php | 15 +++--------- src/Elements/Hidden.php | 5 +--- src/Elements/Label.php | 19 ++++----------- src/Elements/Number.php | 5 +--- src/Elements/Password.php | 5 +--- src/Elements/RadioButton.php | 5 +--- src/Elements/Select.php | 12 +++------- src/Elements/Text.php | 5 +--- src/Elements/TextArea.php | 10 ++------ src/ErrorStore/IlluminateErrorStore.php | 5 +--- src/FormBuilder.php | 26 ++++++--------------- src/OldInput/IlluminateOldInputProvider.php | 5 +--- 20 files changed, 38 insertions(+), 134 deletions(-) diff --git a/src/Binding/BoundData.php b/src/Binding/BoundData.php index 02dd8cd..2d88a3e 100644 --- a/src/Binding/BoundData.php +++ b/src/Binding/BoundData.php @@ -4,10 +4,7 @@ class BoundData { - /** - * @var mixed - */ - protected $data; + protected mixed $data; public function __construct(mixed $data) { diff --git a/src/Elements/Button.php b/src/Elements/Button.php index b5004fa..073b000 100644 --- a/src/Elements/Button.php +++ b/src/Elements/Button.php @@ -4,17 +4,11 @@ class Button extends FormControl { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'button', ]; - /** - * @var string - */ - protected $value; + protected string $value; public function __construct(string $value, ?string $name = null) { diff --git a/src/Elements/Checkbox.php b/src/Elements/Checkbox.php index af8f1e0..e339d8f 100644 --- a/src/Elements/Checkbox.php +++ b/src/Elements/Checkbox.php @@ -4,22 +4,13 @@ class Checkbox extends Input { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'checkbox', ]; - /** - * @var ?bool - */ - protected $checked; + protected ?bool $checked; - /** - * @var mixed - */ - protected $oldValue; + protected mixed $oldValue = null; public function __construct(string $name, mixed $value = 1) { diff --git a/src/Elements/Date.php b/src/Elements/Date.php index 8f9152b..f9904f9 100644 --- a/src/Elements/Date.php +++ b/src/Elements/Date.php @@ -4,10 +4,7 @@ class Date extends Text { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'date', ]; diff --git a/src/Elements/DateTimeLocal.php b/src/Elements/DateTimeLocal.php index d6f8d80..b8a5bb2 100644 --- a/src/Elements/DateTimeLocal.php +++ b/src/Elements/DateTimeLocal.php @@ -4,10 +4,7 @@ class DateTimeLocal extends Text { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'datetime-local', ]; diff --git a/src/Elements/Element.php b/src/Elements/Element.php index 77296c3..80b9ce5 100644 --- a/src/Elements/Element.php +++ b/src/Elements/Element.php @@ -4,10 +4,7 @@ abstract class Element { - /** - * @var array - */ - protected $attributes = []; + protected array $attributes = []; protected function setAttribute(string $attribute, mixed $value = null): void { diff --git a/src/Elements/Email.php b/src/Elements/Email.php index b9b69fc..32be42c 100644 --- a/src/Elements/Email.php +++ b/src/Elements/Email.php @@ -4,10 +4,7 @@ class Email extends Text { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'email', ]; } diff --git a/src/Elements/File.php b/src/Elements/File.php index b02132c..055fe73 100644 --- a/src/Elements/File.php +++ b/src/Elements/File.php @@ -4,10 +4,7 @@ class File extends Input { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'file', ]; } diff --git a/src/Elements/FormOpen.php b/src/Elements/FormOpen.php index 97ac6f2..c69d3e9 100644 --- a/src/Elements/FormOpen.php +++ b/src/Elements/FormOpen.php @@ -4,23 +4,14 @@ class FormOpen extends Element { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'method' => 'POST', 'action' => '', ]; - /** - * @var ?Hidden - */ - protected $token; + protected ?Hidden $token; - /** - * @var ?Hidden - */ - protected $hiddenMethod; + protected ?Hidden $hiddenMethod; public function render(): string { diff --git a/src/Elements/Hidden.php b/src/Elements/Hidden.php index 88a4e05..d293226 100644 --- a/src/Elements/Hidden.php +++ b/src/Elements/Hidden.php @@ -4,10 +4,7 @@ class Hidden extends Input { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'hidden', ]; } diff --git a/src/Elements/Label.php b/src/Elements/Label.php index 5d7e875..511eccf 100644 --- a/src/Elements/Label.php +++ b/src/Elements/Label.php @@ -4,20 +4,11 @@ class Label extends Element { - /** - * @var ?Element - */ - protected $element; - - /** - * @var bool - */ - protected $labelBefore; - - /** - * @var string - */ - protected $label; + protected ?Element $element = null; + + protected ?bool $labelBefore = null; + + protected string $label; public function __construct(string $label) { diff --git a/src/Elements/Number.php b/src/Elements/Number.php index c5c842b..d1b49bf 100644 --- a/src/Elements/Number.php +++ b/src/Elements/Number.php @@ -4,10 +4,7 @@ class Number extends Input { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'number', ]; diff --git a/src/Elements/Password.php b/src/Elements/Password.php index d5bcb54..3d03b7e 100644 --- a/src/Elements/Password.php +++ b/src/Elements/Password.php @@ -4,10 +4,7 @@ class Password extends Text { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'password', ]; } diff --git a/src/Elements/RadioButton.php b/src/Elements/RadioButton.php index 8fc5dea..ea8b35b 100644 --- a/src/Elements/RadioButton.php +++ b/src/Elements/RadioButton.php @@ -4,10 +4,7 @@ class RadioButton extends Checkbox { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'radio', ]; diff --git a/src/Elements/Select.php b/src/Elements/Select.php index 722f72f..dbe5f38 100644 --- a/src/Elements/Select.php +++ b/src/Elements/Select.php @@ -4,15 +4,9 @@ class Select extends FormControl { - /** - * @var array - */ - protected $options; - - /** - * @var ?bool - */ - protected $selected; + protected array $options; + + protected mixed $selected = null; public function __construct(string $name, array $options = []) { diff --git a/src/Elements/Text.php b/src/Elements/Text.php index 8db50b1..3906bff 100644 --- a/src/Elements/Text.php +++ b/src/Elements/Text.php @@ -4,10 +4,7 @@ class Text extends Input { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'type' => 'text', ]; diff --git a/src/Elements/TextArea.php b/src/Elements/TextArea.php index c0397b8..069fdf4 100644 --- a/src/Elements/TextArea.php +++ b/src/Elements/TextArea.php @@ -4,19 +4,13 @@ class TextArea extends FormControl { - /** - * @var array - */ - protected $attributes = [ + protected array $attributes = [ 'name' => '', 'rows' => 10, 'cols' => 50, ]; - /** - * @var ?string - */ - protected $value; + protected ?string $value = null; public function render(): string { diff --git a/src/ErrorStore/IlluminateErrorStore.php b/src/ErrorStore/IlluminateErrorStore.php index a6ca8b3..958b25a 100644 --- a/src/ErrorStore/IlluminateErrorStore.php +++ b/src/ErrorStore/IlluminateErrorStore.php @@ -6,10 +6,7 @@ class IlluminateErrorStore implements ErrorStoreInterface { - /** - * @var Session - */ - private $session; + private Session $session; public function __construct(Session $session) { diff --git a/src/FormBuilder.php b/src/FormBuilder.php index 14eae9a..421628b 100644 --- a/src/FormBuilder.php +++ b/src/FormBuilder.php @@ -23,25 +23,13 @@ class FormBuilder { - /** - * @var ?OldInputInterface - */ - protected $oldInput; - - /** - * @var ?ErrorStoreInterface - */ - protected $errorStore; - - /** - * @var ?string - */ - protected $csrfToken; - - /** - * @var ?\TypiCMS\Form\Binding\BoundData - */ - protected $boundData; + protected ?OldInputInterface $oldInput; + + protected ?ErrorStoreInterface $errorStore; + + protected ?string $csrfToken; + + protected ?BoundData $boundData; public function setOldInputProvider(OldInputInterface $oldInputProvider): void { diff --git a/src/OldInput/IlluminateOldInputProvider.php b/src/OldInput/IlluminateOldInputProvider.php index 28ec032..3a139ca 100644 --- a/src/OldInput/IlluminateOldInputProvider.php +++ b/src/OldInput/IlluminateOldInputProvider.php @@ -6,10 +6,7 @@ class IlluminateOldInputProvider implements OldInputInterface { - /** - * @var Session - */ - private $session; + private Session $session; public function __construct(Session $session) {