From 1742fb65c53a2a6cd6a310d225add25ee20c14b6 Mon Sep 17 00:00:00 2001 From: wn_ Date: Tue, 10 Dec 2024 18:58:17 +0000 Subject: 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). --- include/controls.php | 6 +++--- include/controls_compat.php | 30 +++++++++++++----------------- 2 files changed, 16 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/include/controls.php b/include/controls.php index 5c6174e3d..8932dd048 100755 --- a/include/controls.php +++ b/include/controls.php @@ -56,21 +56,21 @@ * @param array $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 $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 $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]); } /** diff --git a/include/controls_compat.php b/include/controls_compat.php index 5a2a9f2ba..d22f7fc3c 100644 --- a/include/controls_compat.php +++ b/include/controls_compat.php @@ -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 "\n"; } @@ -22,14 +20,12 @@ function stylesheet_tag(string $filename, array $attributes = []): string { * @param array $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 "\n"; } -- cgit v1.2.3-54-g00ecf