Use the spread operator instead of 'array_merge' in more places.

PHP 8.1 introduced support for merging string-key arrays (last array with a wins).
This commit is contained in:
wn_
2024-12-10 18:58:17 +00:00
parent d5b1258d29
commit 1742fb65c5
4 changed files with 31 additions and 36 deletions

View File

@@ -56,21 +56,21 @@
* @param array<string, mixed> $attributes
*/
function number_spinner_tag(string $name, string $value, array $attributes = [], string $id = ""): string {
return input_tag($name, $value, "text", array_merge(["dojoType" => "dijit.form.NumberSpinner"], $attributes), $id);
return input_tag($name, $value, 'text', ['dojoType' => 'dijit.form.NumberSpinner', ...$attributes], $id);
}
/**
* @param array<string, mixed> $attributes
*/
function submit_tag(string $value, array $attributes = []): string {
return button_tag($value, "submit", array_merge(["class" => "alt-primary"], $attributes));
return button_tag($value, 'submit', ['class' => 'alt-primary', ...$attributes]);
}
/**
* @param array<string, mixed> $attributes
*/
function cancel_dialog_tag(string $value, array $attributes = []): string {
return button_tag($value, "", array_merge(["onclick" => "App.dialogOf(this).hide()"], $attributes));
return button_tag($value, '', ['onclick' => 'App.dialogOf(this).hide()', ...$attributes]);
}
/**

View File

@@ -5,15 +5,13 @@
*/
function stylesheet_tag(string $filename, array $attributes = []): string {
$attributes_str = \Controls\attributes_to_string(
array_merge(
[
"href" => "$filename?" . filemtime($filename),
"rel" => "stylesheet",
"type" => "text/css",
"data-orig-href" => $filename
],
$attributes));
$attributes_str = \Controls\attributes_to_string([
'href' => "$filename?" . filemtime($filename),
'rel' => 'stylesheet',
'type' => 'text/css',
'data-orig-href' => $filename,
...$attributes,
]);
return "<link $attributes_str/>\n";
}
@@ -22,14 +20,12 @@ function stylesheet_tag(string $filename, array $attributes = []): string {
* @param array<string, mixed> $attributes
*/
function javascript_tag(string $filename, array $attributes = []): string {
$attributes_str = \Controls\attributes_to_string(
array_merge(
[
"src" => "$filename?" . filemtime($filename),
"type" => "text/javascript",
"charset" => "utf-8"
],
$attributes));
$attributes_str = \Controls\attributes_to_string([
'src' => "$filename?" . filemtime($filename),
'type' => 'text/javascript',
'charset' => 'utf-8',
...$attributes,
]);
return "<script $attributes_str></script>\n";
}