diff options
| author | wn_ <invalid@email.com> | 2024-12-10 18:58:17 +0000 |
|---|---|---|
| committer | wn_ <invalid@email.com> | 2024-12-14 12:26:59 +0000 |
| commit | 1742fb65c53a2a6cd6a310d225add25ee20c14b6 (patch) | |
| tree | f7a7d60a227f9e469b5644b7a15fe21352080b4d /include/controls_compat.php | |
| parent | d5b1258d294fb8b0e43344a9925a9202925fcb02 (diff) | |
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).
Diffstat (limited to 'include/controls_compat.php')
| -rw-r--r-- | include/controls_compat.php | 30 |
1 files changed, 13 insertions, 17 deletions
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 "<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"; } |