diff --git a/composer.json b/composer.json index 5ba28af..68bbc78 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": ">=8.1", - "nette/forms": "3.1.15", + "nette/forms": "3.2.0", "nette/application": "^3.0" }, "require-dev": { diff --git a/src/BootstrapForm.php b/src/BootstrapForm.php index 8f7156e..21e5f43 100644 --- a/src/BootstrapForm.php +++ b/src/BootstrapForm.php @@ -57,7 +57,7 @@ public function __construct($container = null) $prototype = Html::el('form', [ 'action' => '', - 'method' => self::POST, + 'method' => self::Post, 'class' => [], ]); $this->elementPrototype = $prototype; @@ -98,10 +98,7 @@ public function getRenderer(): FormRenderer return $renderer; } - /** - * @return static - */ - public function setRenderer(?FormRenderer $renderer = null) + public function setRenderer(?FormRenderer $renderer = null): static { if (!$renderer instanceof BootstrapRenderer) { throw new InvalidArgumentException('Renderer must be a BootstrapRenderer class'); diff --git a/src/BootstrapRenderer.php b/src/BootstrapRenderer.php index 03ac447..ac894ad 100644 --- a/src/BootstrapRenderer.php +++ b/src/BootstrapRenderer.php @@ -375,7 +375,7 @@ public function renderBody(): string //region getting container - $container = $group->getOption(RendererOptions::CONTAINER, null); + $container = $group->getOption(RendererOptions::CONTAINER); if (is_string($container)) { $container = $this->configElem(Cnf::GROUP, Html::el($container)); } elseif ($container instanceof Html) { @@ -462,7 +462,7 @@ public function renderControls($parent): string // note that these are NOT form groups, these are groups specified to group foreach ($parent->getControls() as $control) { - if ($control->getOption(RendererOptions::_RENDERED, false)) { + if ($control->getOption(RendererOptions::_RENDERED)) { continue; } diff --git a/src/Grid/BootstrapRow.php b/src/Grid/BootstrapRow.php index 0e796c1..306b2a7 100644 --- a/src/Grid/BootstrapRow.php +++ b/src/Grid/BootstrapRow.php @@ -197,12 +197,11 @@ public function setParent(?IContainer $parent = null, ?string $name = null): sta /** * Gets previously set option * - * @param mixed|null $default * @return mixed|null */ - public function getOption(string $option, $default = null) + public function getOption(string $option) { - return $this->options[$option] ?? $default; + return $this->options[$option]; } /** diff --git a/src/Inputs/ButtonInput.php b/src/Inputs/ButtonInput.php index 83979df..e47801f 100644 --- a/src/Inputs/ButtonInput.php +++ b/src/Inputs/ButtonInput.php @@ -35,7 +35,7 @@ public function getControl($content = null): Html $btn = parent::getControl($content); $btn->setName('button'); $this->addBtnClass($btn); - $btn->setHtml($content ?? (string) $this->caption); //@phpstan-ignore-line + $btn->setHtml($content ?? (string) $this->caption); $btn->removeAttribute('value'); return $btn; diff --git a/src/Inputs/CheckboxInput.php b/src/Inputs/CheckboxInput.php index cf1e778..1e7b4ec 100644 --- a/src/Inputs/CheckboxInput.php +++ b/src/Inputs/CheckboxInput.php @@ -24,22 +24,15 @@ class CheckboxInput extends Checkbox implements IValidationInput /** * set to true so that checkboxes by defaults are alligned on right with input fields, you can also set - * - * @var bool */ - public static $defaultAllignWithInputControls = false; + public static bool $defaultAllignWithInputControls = false; /** * set to true to allign checkbox to right with all other input controls - * - * @var bool */ - public $allignWithInputControls; + public bool $allignWithInputControls; - /** - * @param string|object $label - */ - public function __construct($label = null) + public function __construct(string|\Stringable|null $label = null) { $this->allignWithInputControls = static::$defaultAllignWithInputControls; @@ -54,7 +47,7 @@ public function __construct($label = null) */ public static function makeCheckbox( string $name, - string $htmlId, + bool|null|string $htmlId, $caption = null, bool $checked = false, $value = false, diff --git a/src/Inputs/DateInput.php b/src/Inputs/DateInput.php index 0acfd06..c1e917f 100644 --- a/src/Inputs/DateInput.php +++ b/src/Inputs/DateInput.php @@ -70,7 +70,7 @@ public function cleanErrors(): void /** * @inheritdoc */ - public function getValue() + public function getValue(): mixed { $val = parent::getValue(); diff --git a/src/Inputs/SelectInput.php b/src/Inputs/SelectInput.php index 58f9963..06b7fb7 100644 --- a/src/Inputs/SelectInput.php +++ b/src/Inputs/SelectInput.php @@ -10,10 +10,6 @@ use Nette\Forms\Controls\SelectBox; use Nette\Utils\Html; -/** - * Class SelectInput. - * Single select. - */ class SelectInput extends SelectBox implements IValidationInput { diff --git a/src/Inputs/TextInput.php b/src/Inputs/TextInput.php index 7752189..6b5f952 100644 --- a/src/Inputs/TextInput.php +++ b/src/Inputs/TextInput.php @@ -97,10 +97,7 @@ public function setPlaceholder(string $placeholder) return $this; } - /** - * @param object|string $caption - */ - public function getLabel($caption = null): Html + public function getLabel(string|\Stringable|null $caption = null): Html { /** @var Html $label */ $label = parent::getLabel($caption); diff --git a/src/Traits/BootstrapContainerTrait.php b/src/Traits/BootstrapContainerTrait.php index 0a2605a..baa46aa 100644 --- a/src/Traits/BootstrapContainerTrait.php +++ b/src/Traits/BootstrapContainerTrait.php @@ -188,7 +188,7 @@ public function addEmail(string $name, $label = null): NetteTextInput { return $this->addText($name, $label) ->setNullable(BootstrapForm::$allwaysUseNullable) - ->addRule(Form::EMAIL); + ->addRule(Form::Email); } /** @@ -207,7 +207,7 @@ public function addInteger(string $name, $label = null): NetteTextInput { return $this->addText($name, $label) ->setNullable(BootstrapForm::$allwaysUseNullable) - ->addRule(Form::INTEGER); + ->addRule(Form::Integer); } /** diff --git a/src/Traits/InputPromptTrait.php b/src/Traits/InputPromptTrait.php index f10749c..e60091e 100644 --- a/src/Traits/InputPromptTrait.php +++ b/src/Traits/InputPromptTrait.php @@ -14,11 +14,8 @@ trait InputPromptTrait /** * Sets the first unselectable item on list. Its value is null. - * - * @param string|null $prompt - * @return static */ - public function setPrompt($prompt) + public function setPrompt(string|\Stringable|false $prompt): static { if (empty($prompt)) { return $this;