Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions src/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function withoutCsrf(bool $inject_token = false): static
*
* @return HtmlString|string
*/
public function label(string $name, string $value = null, array|null $options = [], bool|null $escape_html = true): HtmlString|string
public function label(string $name, string|null $value = null, array|null $options = [], bool|null $escape_html = true): HtmlString|string
{
$this->labels[] = $name;

Expand Down Expand Up @@ -311,7 +311,7 @@ protected function formatLabel(string $name, ?string $value): string
*
* @return string|HtmlString
*/
public function input(string $type, string|null $name, string $value = null, array $options = []): string|HtmlString
public function input(string $type, string|null $name, string|null $value = null, array $options = []): string|HtmlString
{
$this->type = $type;

Expand Down Expand Up @@ -347,7 +347,7 @@ public function input(string $type, string|null $name, string $value = null, arr
*
* @return string|HtmlString
*/
public function text(string $name, string $value = null, array $options = []): string|HtmlString
public function text(string $name, string|null $value = null, array $options = []): string|HtmlString
{
return $this->input('text', $name, $value, $options);
}
Expand All @@ -374,7 +374,7 @@ public function password(string $name, array $options = []): string|HtmlString
*
* @return string|HtmlString
*/
public function range(string $name, string $value = null, array $options = []): string|HtmlString
public function range(string $name, string|null $value = null, array $options = []): string|HtmlString
{
return $this->input('range', $name, $value, $options);
}
Expand All @@ -388,7 +388,7 @@ public function range(string $name, string $value = null, array $options = []):
*
* @return string|HtmlString
*/
public function hidden(string $name, string $value = null, array $options = []): string|HtmlString
public function hidden(string $name, string|null $value = null, array $options = []): string|HtmlString
{
return $this->input('hidden', $name, $value, $options);
}
Expand All @@ -402,7 +402,7 @@ public function hidden(string $name, string $value = null, array $options = []):
*
* @return string|HtmlString
*/
public function search(string $name, string $value = null, array $options = []): string|HtmlString
public function search(string $name, string|null $value = null, array $options = []): string|HtmlString
{
return $this->input('search', $name, $value, $options);
}
Expand All @@ -416,7 +416,7 @@ public function search(string $name, string $value = null, array $options = []):
*
* @return string|HtmlString
*/
public function email(string $name, string $value = null, array $options = []): string|HtmlString
public function email(string $name, string|null $value = null, array $options = []): string|HtmlString
{
return $this->input('email', $name, $value, $options);
}
Expand All @@ -430,7 +430,7 @@ public function email(string $name, string $value = null, array $options = []):
*
* @return string|HtmlString
*/
public function tel(string $name, string $value = null, array $options = []): string|HtmlString
public function tel(string $name, string|null $value = null, array $options = []): string|HtmlString
{
return $this->input('tel', $name, $value, $options);
}
Expand All @@ -444,7 +444,7 @@ public function tel(string $name, string $value = null, array $options = []): st
*
* @return string|HtmlString
*/
public function number(string $name, string $value = null, array $options = []): string|HtmlString
public function number(string $name, string|null $value = null, array $options = []): string|HtmlString
{
return $this->input('number', $name, $value, $options);
}
Expand All @@ -458,7 +458,7 @@ public function number(string $name, string $value = null, array $options = []):
*
* @return string|HtmlString
*/
public function date(string $name, string|DateTimeInterface $value = null, array $options = []): string|HtmlString
public function date(string $name, string|DateTimeInterface|null $value = null, array $options = []): string|HtmlString
{
$value ??= $this->getValueAttribute($name, $value);

Expand All @@ -478,7 +478,7 @@ public function date(string $name, string|DateTimeInterface $value = null, array
*
* @return HtmlString|string
*/
public function datetime(string $name, string|DateTimeInterface $value = null, array $options = []): HtmlString|string
public function datetime(string $name, string|DateTimeInterface|null $value = null, array $options = []): HtmlString|string
{
if ($value instanceof DateTimeInterface) {
$value = $value->format(DateTimeInterface::RFC3339);
Expand All @@ -497,7 +497,7 @@ public function datetime(string $name, string|DateTimeInterface $value = null, a
* @return HtmlString|string
* @noinspection PhpUnused
*/
public function datetimeLocal(string $name, string|DateTimeInterface $value = null, array $options = []): HtmlString|string
public function datetimeLocal(string $name, string|DateTimeInterface|null $value = null, array $options = []): HtmlString|string
{
if ($value instanceof DateTimeInterface) {
$value = $value->format('Y-m-d\TH:i');
Expand All @@ -515,7 +515,7 @@ public function datetimeLocal(string $name, string|DateTimeInterface $value = nu
*
* @return HtmlString|string
*/
public function time(string $name, string|DateTimeInterface $value = null, array $options = []): HtmlString|string
public function time(string $name, string|DateTimeInterface|null $value = null, array $options = []): HtmlString|string
{
if ($value instanceof DateTimeInterface) {
$value = $value->format('H:i');
Expand All @@ -533,7 +533,7 @@ public function time(string $name, string|DateTimeInterface $value = null, array
*
* @return HtmlString|string
*/
public function url(string $name, string $value = null, array $options = []): HtmlString|string
public function url(string $name, string|null $value = null, array $options = []): HtmlString|string
{
return $this->input('url', $name, $value, $options);
}
Expand All @@ -547,7 +547,7 @@ public function url(string $name, string $value = null, array $options = []): Ht
*
* @return HtmlString|string
*/
public function week(string $name, string|DateTimeInterface $value = null, array $options = []): HtmlString|string
public function week(string $name, string|DateTimeInterface|null $value = null, array $options = []): HtmlString|string
{
if ($value instanceof DateTimeInterface) {
$value = $value->format('Y-\WW');
Expand Down Expand Up @@ -578,7 +578,7 @@ public function file(string $name, array $options = []): HtmlString|string
*
* @return HtmlString|string
*/
public function textarea(string $name, string $value = null, array $options = []): HtmlString|string
public function textarea(string $name, string|null $value = null, array $options = []): HtmlString|string
{
$this->type = 'textarea';

Expand Down Expand Up @@ -659,7 +659,7 @@ protected function setQuickTextAreaSize(array $options): array
public function select(
string $name,
array|Collection $list = [],
bool|string|array|Collection $selected = null,
bool|string|array|Collection|null $selected = null,
array $selectAttributes = [],
array $optionsAttributes = [],
array $optgroupsAttributes = []
Expand Down Expand Up @@ -717,7 +717,7 @@ public function select(
*
* @return HtmlString|string
*/
public function selectRange(string $name, string $begin, string $end, string $selected = null, array $options = []): HtmlString|string
public function selectRange(string $name, string $begin, string $end, string|null $selected = null, array $options = []): HtmlString|string
{
$range = array_combine($range = range($begin, $end), $range);

Expand All @@ -735,7 +735,7 @@ public function selectRange(string $name, string $begin, string $end, string $se
*
* @return mixed
*/
public function selectYear(string $name, string $begin, string $end, string $selected = null, array $options = null): mixed
public function selectYear(string $name, string $begin, string $end, string|null $selected = null, array|null $options = null): mixed
{
return call_user_func_array([$this, 'selectRange'], func_get_args());
}
Expand All @@ -750,7 +750,7 @@ public function selectYear(string $name, string $begin, string $end, string $sel
*
* @return HtmlString|string
*/
public function selectMonth(string $name, string $selected = null, array $options = [], string $format = 'F'): HtmlString|string
public function selectMonth(string $name, string|null $selected = null, array $options = [], string $format = 'F'): HtmlString|string
{
$months = [];

Expand Down Expand Up @@ -898,7 +898,7 @@ public function checkbox(string $name, mixed $value = 1, bool|null $checked = nu
*
* @return HtmlString|string
*/
public function radio(string $name, mixed $value = null, bool $checked = null, array $options = []): HtmlString|string
public function radio(string $name, mixed $value = null, bool|null $checked = null, array $options = []): HtmlString|string
{
if (is_null($value)) {
$value = $name;
Expand Down Expand Up @@ -1050,7 +1050,7 @@ public function reset(string $value, array $attributes = []): HtmlString|string
*
* @return HtmlString|string
*/
public function image(string $url, string $name = null, array $attributes = []): HtmlString|string
public function image(string $url, string|null $name = null, array $attributes = []): HtmlString|string
{
$attributes['src'] = $this->url->asset($url);

Expand All @@ -1066,7 +1066,7 @@ public function image(string $url, string $name = null, array $attributes = []):
*
* @return HtmlString|string
*/
public function month(string $name, string|DateTimeInterface $value = null, array $options = []): HtmlString|string
public function month(string $name, string|DateTimeInterface|null $value = null, array $options = []): HtmlString|string
{
if ($value instanceof DateTimeInterface) {
$value = $value->format('Y-m');
Expand All @@ -1084,7 +1084,7 @@ public function month(string $name, string|DateTimeInterface $value = null, arra
*
* @return HtmlString|string
*/
public function color(string $name, string $value = null, array $options = []): HtmlString|string
public function color(string $name, string|null $value = null, array $options = []): HtmlString|string
{
return $this->input('color', $name, $value, $options);
}
Expand All @@ -1097,7 +1097,7 @@ public function color(string $name, string $value = null, array $options = []):
*
* @return HtmlString|string
*/
public function submit(string $value = null, array $options = []): HtmlString|string
public function submit(string|null $value = null, array $options = []): HtmlString|string
{
return $this->input('submit', null, $value, $options);
}
Expand All @@ -1110,7 +1110,7 @@ public function submit(string $value = null, array $options = []): HtmlString|st
*
* @return HtmlString|string
*/
public function button(string $value = null, array $options = []): HtmlString|string
public function button(string|null $value = null, array $options = []): HtmlString|string
{
if (! array_key_exists('type', $options)) {
$options['type'] = 'button';
Expand Down
24 changes: 12 additions & 12 deletions src/HtmlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function decode(string $value): string
*
* @return HtmlString|string
*/
public function script(string $url, array $attributes = [], bool $secure = null): HtmlString|string
public function script(string $url, array $attributes = [], bool|null $secure = null): HtmlString|string
{
$attributes['src'] = $this->url->asset($url, $secure);

Expand All @@ -91,7 +91,7 @@ public function script(string $url, array $attributes = [], bool $secure = null)
*
* @return HtmlString|string
*/
public function style(string $url, array $attributes = [], bool $secure = null): HtmlString|string
public function style(string $url, array $attributes = [], bool|null $secure = null): HtmlString|string
{
$defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];

Expand All @@ -112,7 +112,7 @@ public function style(string $url, array $attributes = [], bool $secure = null):
*
* @return HtmlString|string
*/
public function image(string $url, string $alt = null, array $attributes = [], bool $secure = null): HtmlString|string
public function image(string $url, string|null $alt = null, array $attributes = [], bool|null $secure = null): HtmlString|string
{
$attributes['alt'] = $alt;

Expand All @@ -129,7 +129,7 @@ public function image(string $url, string $alt = null, array $attributes = [], b
*
* @return HtmlString|string
*/
public function favicon(string $url, array $attributes = [], bool $secure = null): HtmlString|string
public function favicon(string $url, array $attributes = [], bool|null $secure = null): HtmlString|string
{
$defaults = ['rel' => 'shortcut icon', 'type' => 'image/x-icon'];

Expand All @@ -151,7 +151,7 @@ public function favicon(string $url, array $attributes = [], bool $secure = null
*
* @return HtmlString|string
*/
public function link(string $url, string $title = null, array $attributes = [], bool $secure = null, bool $escape = true): HtmlString|string
public function link(string $url, string|null $title = null, array $attributes = [], bool|null $secure = null, bool $escape = true): HtmlString|string
{
$url = $this->url->to($url, [], $secure);

Expand All @@ -176,7 +176,7 @@ public function link(string $url, string $title = null, array $attributes = [],
*
* @return HtmlString|string
*/
public function secureLink(string $url, string $title = null, array $attributes = [], bool $escape = true): HtmlString|string
public function secureLink(string $url, string|null $title = null, array $attributes = [], bool $escape = true): HtmlString|string
{
return $this->link($url, $title, $attributes, true, $escape);
}
Expand All @@ -192,7 +192,7 @@ public function secureLink(string $url, string $title = null, array $attributes
*
* @return HtmlString|string
*/
public function linkAsset(string $url, string $title = null, array $attributes = [], bool $secure = null, bool $escape = true): HtmlString|string
public function linkAsset(string $url, string|null $title = null, array $attributes = [], bool|null $secure = null, bool $escape = true): HtmlString|string
{
$url = $this->url->asset($url, $secure);

Expand All @@ -209,7 +209,7 @@ public function linkAsset(string $url, string $title = null, array $attributes =
*
* @return HtmlString|string
*/
public function linkSecureAsset(string $url, string $title = null, array $attributes = [], bool $escape = true): HtmlString|string
public function linkSecureAsset(string $url, string|null $title = null, array $attributes = [], bool $escape = true): HtmlString|string
{
return $this->linkAsset($url, $title, $attributes, true, $escape);
}
Expand All @@ -226,7 +226,7 @@ public function linkSecureAsset(string $url, string $title = null, array $attrib
*
* @return HtmlString|string
*/
public function linkRoute(string $name, string $title = null, mixed $parameters = [], array $attributes = [], bool $secure = null, bool $escape = true): HtmlString|string
public function linkRoute(string $name, string|null $title = null, mixed $parameters = [], array $attributes = [], bool|null $secure = null, bool $escape = true): HtmlString|string
{
return $this->link($this->url->route($name, $parameters), $title, $attributes, $secure, $escape);
}
Expand All @@ -243,7 +243,7 @@ public function linkRoute(string $name, string $title = null, mixed $parameters
*
* @return HtmlString|string
*/
public function linkAction(string $action, string $title = null, array $parameters = [], array $attributes = [], bool $secure = null, bool $escape = true): HtmlString|string
public function linkAction(string $action, string|null $title = null, array $parameters = [], array $attributes = [], bool|null $secure = null, bool $escape = true): HtmlString|string
{
return $this->link($this->url->action($action, $parameters), $title, $attributes, $secure, $escape);
}
Expand All @@ -258,7 +258,7 @@ public function linkAction(string $action, string $title = null, array $paramete
*
* @return HtmlString|string
*/
public function mailto(string $email, string $title = null, array $attributes = [], bool $escape = true): HtmlString|string
public function mailto(string $email, string|null $title = null, array $attributes = [], bool $escape = true): HtmlString|string
{
$email = $this->email($email);

Expand Down Expand Up @@ -424,7 +424,7 @@ protected function nestedListing(mixed $key, string $type, mixed $value): string
* @param string|null $input_type
* @return string
*/
public function attributes(array|null $attributes, string $input_type = null): string
public function attributes(array|null $attributes, string|null $input_type = null): string
{
$defaultAttributes = config('html-forms.default_attributes', []);
$all_default_attributes = $defaultAttributes['all'] ?? [];
Expand Down
6 changes: 3 additions & 3 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function link_to(string $url, string|null $title = null, array $attributes = [],
*
* @return string
*/
function link_to_asset(string $url, string $title = null, array $attributes = [], bool $secure = null): string
function link_to_asset(string $url, string|null $title = null, array $attributes = [], bool|null $secure = null): string
{
return app('html')->linkAsset($url, $title, $attributes, $secure);
}
Expand All @@ -48,7 +48,7 @@ function link_to_asset(string $url, string $title = null, array $attributes = []
*
* @return string
*/
function link_to_route(string $name, string $title = null, mixed $parameters = [], array $attributes = []): HtmlString|string
function link_to_route(string $name, string|null $title = null, mixed $parameters = [], array $attributes = []): HtmlString|string
{
return app('html')->linkRoute($name, $title, $parameters, $attributes);
}
Expand All @@ -65,7 +65,7 @@ function link_to_route(string $name, string $title = null, mixed $parameters = [
*
* @return string
*/
function link_to_action(string $action, string $title = null, array $parameters = [], array $attributes = []): HtmlString|string
function link_to_action(string $action, string|null $title = null, array $parameters = [], array $attributes = []): HtmlString|string
{
return app('html')->linkAction($action, $title, $parameters, $attributes);
}
Expand Down