phpdoc improvements, fixes #1036

This commit is contained in:
El RIDO 2024-03-10 17:07:10 +01:00
parent 53d2d3334d
commit 5f00587d71
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92
5 changed files with 6 additions and 12 deletions

View File

@ -55,7 +55,6 @@ class Database extends AbstractData
* @access public * @access public
* @param array $options * @param array $options
* @throws Exception * @throws Exception
* @return
*/ */
public function __construct(array $options) public function __construct(array $options)
{ {

View File

@ -66,7 +66,6 @@ class Filesystem extends AbstractData
* *
* @access public * @access public
* @param array $options * @param array $options
* @return
*/ */
public function __construct(array $options) public function __construct(array $options)
{ {

View File

@ -47,7 +47,6 @@ class GoogleCloudStorage extends AbstractData
* *
* @access public * @access public
* @param array $options * @param array $options
* @return
*/ */
public function __construct(array $options) public function __construct(array $options)
{ {

View File

@ -78,7 +78,6 @@ class S3Storage extends AbstractData
* *
* @access public * @access public
* @param array $options * @param array $options
* @return
*/ */
public function __construct(array $options) public function __construct(array $options)
{ {

View File

@ -85,7 +85,7 @@ class I18n
* @param mixed $args one or multiple parameters injected into placeholders * @param mixed $args one or multiple parameters injected into placeholders
* @return string * @return string
*/ */
public static function _($messageId) public static function _($messageId, ...$args)
{ {
return forward_static_call_array('PrivateBin\I18n::translate', func_get_args()); return forward_static_call_array('PrivateBin\I18n::translate', func_get_args());
} }
@ -99,7 +99,7 @@ class I18n
* @param mixed $args one or multiple parameters injected into placeholders * @param mixed $args one or multiple parameters injected into placeholders
* @return string * @return string
*/ */
public static function translate($messageId) public static function translate($messageId, ...$args)
{ {
if (empty($messageId)) { if (empty($messageId)) {
return $messageId; return $messageId;
@ -114,7 +114,7 @@ class I18n
if (!array_key_exists($messageId, self::$_translations)) { if (!array_key_exists($messageId, self::$_translations)) {
self::$_translations[$messageId] = $messages; self::$_translations[$messageId] = $messages;
} }
$args = func_get_args(); array_unshift($args, $messageId);
if (is_array(self::$_translations[$messageId])) { if (is_array(self::$_translations[$messageId])) {
$number = (int) $args[1]; $number = (int) $args[1];
$key = self::_getPluralForm($number); $key = self::_getPluralForm($number);
@ -130,13 +130,11 @@ class I18n
} }
// encode any non-integer arguments and the message ID, if it doesn't contain a link // encode any non-integer arguments and the message ID, if it doesn't contain a link
$argsCount = count($args); $argsCount = count($args);
if ($argsCount > 1) {
for ($i = 0; $i < $argsCount; ++$i) { for ($i = 0; $i < $argsCount; ++$i) {
if (($i > 0 && !is_int($args[$i])) || strpos($args[0], '<a') === false) { if ($i > 0 ? !is_int($args[$i]) : strpos($args[0], '<a') === false) {
$args[$i] = self::encode($args[$i]); $args[$i] = self::encode($args[$i]);
} }
} }
}
return call_user_func_array('sprintf', $args); return call_user_func_array('sprintf', $args);
} }