Skip to content

Commit

Permalink
More type hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed Apr 26, 2022
1 parent 4756d19 commit 5f291ad
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 98 deletions.
5 changes: 1 addition & 4 deletions src/BasicFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@

class BasicFormBuilder
{
/**
* @var FormBuilder
*/
protected $builder;
protected FormBuilder $builder;

public function __construct(FormBuilder $builder)
{
Expand Down
19 changes: 5 additions & 14 deletions src/BootForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,11 @@

class BootForm
{
/**
* @var BasicFormBuilder
*/
protected $builder;

/**
* @var BasicFormBuilder
*/
protected $basicFormBuilder;

/**
* @var HorizontalFormBuilder
*/
protected $horizontalFormBuilder;
protected BasicFormBuilder $builder;

protected BasicFormBuilder $basicFormBuilder;

protected HorizontalFormBuilder $horizontalFormBuilder;

public function __construct(BasicFormBuilder $basicFormBuilder, HorizontalFormBuilder $horizontalFormBuilder)
{
Expand Down
3 changes: 0 additions & 3 deletions src/BootFormsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

class BootFormsServiceProvider extends ServiceProvider implements DeferrableProvider
{
/**
* Register the service provider.
*/
public function register()
{
$this->registerErrorStore();
Expand Down
11 changes: 3 additions & 8 deletions src/Elements/CheckGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@

class CheckGroup extends FormGroup
{
protected $label;

/**
* BootForm implementation.
*
* @var \TypiCMS\Form\Elements\Element
*/
protected $control;
protected Label $label;

protected Element $control;

public function __construct(Label $label, Element $control)
{
Expand Down
26 changes: 7 additions & 19 deletions src/Elements/FormGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,13 @@

class FormGroup extends Element
{
/**
* @var Label
*/
protected $label;

/**
* @var \TypiCMS\Form\Elements\Element
*/
protected $control;

/**
* @var ?FormText
*/
protected $formText;

/**
* @var ?InvalidFeedback
*/
protected $invalidFeedback;
protected Label $label;

protected Element $control;

protected ?FormText $formText = null;

protected ?InvalidFeedback $invalidFeedback = null;

public function __construct(Label $label, Element $control)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Elements/FormText.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

class FormText extends Element
{
/**
* @var string
*/
private $message;
private string $message;

public function __construct(string $message)
{
Expand Down
14 changes: 5 additions & 9 deletions src/Elements/GroupWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

namespace TypiCMS\BootForms\Elements;

use TypiCMS\Form\Elements\Element;

class GroupWrapper
{
/**
* @var FormGroup
*/
protected $formGroup;

/**
* @var \TypiCMS\Form\Elements\Element
*/
protected $target;
protected FormGroup $formGroup;

protected Element $target;

public function __construct(FormGroup $formGroup)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Elements/HorizontalFormGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

class HorizontalFormGroup extends FormGroup
{
/**
* @var array
*/
protected $controlSizes;
protected array $controlSizes;

public function __construct(Label $label, Element $control, array $controlSizes)
{
Expand Down
16 changes: 5 additions & 11 deletions src/Elements/InputGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@

class InputGroup extends Text
{
/**
* @var array
*/
protected $beforeAddon = [];
protected array $beforeAddon = [];

/**
* @var array
*/
protected $afterAddon = [];
protected array $afterAddon = [];

public function beforeAddon(string $addon): self
{
Expand All @@ -37,7 +31,7 @@ public function type(string $type): self
return $this;
}

protected function renderAddons(array $addons, string $class): string
protected function renderAddons(array $addons): string
{
$html = '';

Expand All @@ -51,9 +45,9 @@ protected function renderAddons(array $addons, string $class): string
public function render(): string
{
$html = '<div class="input-group">';
$html .= $this->renderAddons($this->beforeAddon, 'prepend');
$html .= $this->renderAddons($this->beforeAddon);
$html .= parent::render();
$html .= $this->renderAddons($this->afterAddon, 'append');
$html .= $this->renderAddons($this->afterAddon);
$html .= '</div>';

return $html;
Expand Down
5 changes: 1 addition & 4 deletions src/Elements/InvalidFeedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

class InvalidFeedback extends Element
{
/**
* @var string
*/
private $message;
private string $message;

public function __construct(string $message)
{
Expand Down
12 changes: 3 additions & 9 deletions src/Elements/OffsetFormGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@

class OffsetFormGroup
{
/**
* @var mixed
*/
protected $control;

/**
* @var array
*/
protected $columnSizes;
protected mixed $control;

protected array $columnSizes;

public function __construct(mixed $control, array $columnSizes)
{
Expand Down
12 changes: 3 additions & 9 deletions src/HorizontalFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@

class HorizontalFormBuilder extends BasicFormBuilder
{
/**
* @var array
*/
protected $columnSizes;

/**
* @var FormBuilder
*/
protected $builder;
protected array $columnSizes;

protected FormBuilder $builder;

public function __construct(FormBuilder $builder, array $columnSizes = ['lg' => [2, 10]])
{
Expand Down

0 comments on commit 5f291ad

Please sign in to comment.