aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/Translate.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2022-01-01 13:54:36 +0100
committerGravatar GitHub <noreply@github.com> 2022-01-01 13:54:36 +0100
commita791388ce4b7b5c03be109418336d41992d93b88 (patch)
treee4d0b697887203c1cbd2f19345f52c711354c299 /lib/Minz/Translate.php
parent3f6aa42b817145a3b00f4d615f87728b55c4413a (diff)
Avoid func_get_args (#4108)
Use variadic syntax instead https://php.net/manual/functions.arguments#functions.variable-arg-list And avoid dynamic functions names when possible to more easily identify calls and unused functions. Contributes to https://github.com/FreshRSS/FreshRSS/issues/4103
Diffstat (limited to 'lib/Minz/Translate.php')
-rw-r--r--lib/Minz/Translate.php17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php
index 90e678d58..0659b0de2 100644
--- a/lib/Minz/Translate.php
+++ b/lib/Minz/Translate.php
@@ -179,11 +179,11 @@ class Minz_Translate {
/**
* Translate a key into its corresponding value based on selected language.
* @param string $key the key to translate.
- * @param additional parameters for variable keys.
+ * @param string $args additional parameters for variable keys.
* @return string value corresponding to the key.
* If no value is found, return the key itself.
*/
- public static function t($key) {
+ public static function t($key, ...$args) {
$group = explode('.', $key);
if (count($group) < 2) {
@@ -232,9 +232,6 @@ class Minz_Translate {
}
// Get the facultative arguments to replace i18n variables.
- $args = func_get_args();
- unset($args[0]);
-
return vsprintf($translation_value, $args);
}
@@ -249,11 +246,9 @@ class Minz_Translate {
/**
* Alias for Minz_Translate::t()
+ * @param string $key
+ * @param array<string> $args
*/
-function _t($key) {
- $args = func_get_args();
- unset($args[0]);
- array_unshift($args, $key);
-
- return call_user_func_array('Minz_Translate::t', $args);
+function _t($key, ...$args) {
+ return Minz_Translate::t($key, ...$args);
}