Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2022-04-27 20:21:00 +0300
committerAleksander Machniak <alec@alec.pl>2022-04-27 20:21:00 +0300
commitfa65a683893f07eb9145472d08e234794bda5624 (patch)
treef567f1a657478cb580204cf2155583d53efaf687
parent2e5a12b0ff57ed8236fac66d3748122ae32f33a5 (diff)
Use ... oprator instead of func_get_args() for variadic functions
-rw-r--r--plugins/markasjunk/drivers/email_learn.php4
-rw-r--r--program/actions/mail/bounce.php4
-rw-r--r--program/actions/mail/send.php4
-rw-r--r--program/include/rcmail_output.php12
-rw-r--r--program/include/rcmail_output_cli.php13
-rw-r--r--program/include/rcmail_output_html.php22
-rw-r--r--program/include/rcmail_output_json.php21
-rw-r--r--program/lib/Roundcube/db/mssql.php8
-rw-r--r--program/lib/Roundcube/db/mysql.php8
-rw-r--r--program/lib/Roundcube/rcube.php14
-rw-r--r--program/lib/Roundcube/rcube_db.php49
-rw-r--r--program/lib/Roundcube/rcube_plugin.php3
12 files changed, 71 insertions, 91 deletions
diff --git a/plugins/markasjunk/drivers/email_learn.php b/plugins/markasjunk/drivers/email_learn.php
index 8caccd79b..7d639ff06 100644
--- a/plugins/markasjunk/drivers/email_learn.php
+++ b/plugins/markasjunk/drivers/email_learn.php
@@ -76,8 +76,8 @@ class markasjunk_email_learn
'mailto' => $mailto,
'dsn_enabled' => false,
'charset' => 'UTF-8',
- 'error_handler' => function() use ($OUTPUT) {
- call_user_func_array([$OUTPUT, 'show_message'], func_get_args());
+ 'error_handler' => function(...$args) use ($OUTPUT) {
+ call_user_func_array([$OUTPUT, 'show_message'], $args);
$OUTPUT->send();
}
]);
diff --git a/program/actions/mail/bounce.php b/program/actions/mail/bounce.php
index aba42761b..6507e4367 100644
--- a/program/actions/mail/bounce.php
+++ b/program/actions/mail/bounce.php
@@ -64,8 +64,8 @@ class rcmail_action_mail_bounce extends rcmail_action
['mode' => rcmail_sendmail::MODE_FORWARD],
[
'sendmail' => true,
- 'error_handler' => function() use ($rcmail) {
- call_user_func_array([$rcmail->output, 'show_message'], func_get_args());
+ 'error_handler' => function(...$args) use ($rcmail) {
+ call_user_func_array([$rcmail->output, 'show_message'], $args);
$rcmail->output->send('iframe');
}
]
diff --git a/program/actions/mail/send.php b/program/actions/mail/send.php
index 1fffbdb1d..a28d7f9ba 100644
--- a/program/actions/mail/send.php
+++ b/program/actions/mail/send.php
@@ -56,8 +56,8 @@ class rcmail_action_mail_send extends rcmail_action
'sendmail' => true,
'saveonly' => $saveonly,
'savedraft' => $savedraft,
- 'error_handler' => function() use ($rcmail) {
- call_user_func_array([$rcmail->output, 'show_message'], func_get_args());
+ 'error_handler' => function(...$args) use ($rcmail) {
+ call_user_func_array([$rcmail->output, 'show_message'], $args);
$rcmail->output->send('iframe');
},
'keepformatting' => !empty($_POST['_keepformatting']),
diff --git a/program/include/rcmail_output.php b/program/include/rcmail_output.php
index 650935169..cd104976e 100644
--- a/program/include/rcmail_output.php
+++ b/program/include/rcmail_output.php
@@ -80,15 +80,17 @@ abstract class rcmail_output extends rcube_output
/**
* Call a client method
*
- * @param string Method to call
- * @param ... Additional arguments
+ * @param string $cmd Method to call
+ * @param mixed ...$args Method arguments
*/
- abstract function command();
+ abstract function command($cmd, ... $args);
/**
- * Add a localized label to the client environment
+ * Add a localized label(s) to the client environment
+ *
+ * @param mixed ...$args Labels (an array of strings, or many string arguments)
*/
- abstract function add_label();
+ abstract function add_label(...$args);
/**
* Register a template object handler
diff --git a/program/include/rcmail_output_cli.php b/program/include/rcmail_output_cli.php
index 0caa708a5..61eeccc17 100644
--- a/program/include/rcmail_output_cli.php
+++ b/program/include/rcmail_output_cli.php
@@ -27,28 +27,23 @@ class rcmail_output_cli extends rcmail_output
{
public $type = 'cli';
- /**
- * Object constructor
- */
- public function __construct()
- {
- parent::__construct();
- }
/**
* Call a client method
*
* @see rcube_output::command()
*/
- function command()
+ function command($cmd, ...$args)
{
// NOP
}
/**
* Add a localized label to the client environment
+ *
+ * @see rcube_output::command()
*/
- function add_label()
+ function add_label(...$args)
{
// NOP
}
diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index dcb95ade5..a721e7d91 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -491,28 +491,28 @@ EOF;
/**
* Call a client method
*
- * @param string Method to call
- * @param ... Additional arguments
+ * @param string $cmd Method to call
+ * @param mixed ...$args Method arguments
*/
- public function command()
+ public function command($cmd, ...$args)
{
- $cmd = func_get_args();
-
- if (strpos($cmd[0], 'plugin.') !== false) {
- $this->js_commands[] = ['triggerEvent', $cmd[0], $cmd[1]];
+ if (strpos($cmd, 'plugin.') !== false) {
+ $this->js_commands[] = ['triggerEvent', $cmd, $args[0]];
}
else {
- $this->js_commands[] = $cmd;
+ array_unshift($args, $cmd);
+
+ $this->js_commands[] = $args;
}
}
/**
* Add a localized label to the client environment
+ *
+ * @param mixed ...$args Labels (an array of strings, or many string arguments)
*/
- public function add_label()
+ public function add_label(...$args)
{
- $args = func_get_args();
-
if (count($args) == 1 && is_array($args[0])) {
$args = $args[0];
}
diff --git a/program/include/rcmail_output_json.php b/program/include/rcmail_output_json.php
index 8b5b396ae..c6cc316d2 100644
--- a/program/include/rcmail_output_json.php
+++ b/program/include/rcmail_output_json.php
@@ -94,27 +94,28 @@ class rcmail_output_json extends rcmail_output
/**
* Call a client method
*
- * @param string Method to call
- * @param ... Additional arguments
+ * @param string $cmd Method to call
+ * @param mixed ...$args Additional arguments
*/
- public function command()
+ public function command($cmd, ...$args)
{
- $cmd = func_get_args();
+ array_unshift($args, $cmd);
- if (strpos($cmd[0], 'plugin.') === 0) {
- $this->callbacks[] = $cmd;
+ if (strpos($args[0], 'plugin.') === 0) {
+ $this->callbacks[] = $args;
}
else {
- $this->commands[] = $cmd;
+ $this->commands[] = $args;
}
}
/**
- * Add a localized label to the client environment
+ * Add a localized label(s) to the client environment
+ *
+ * @param mixed ...$args Labels (an array of strings, or many string arguments)
*/
- public function add_label()
+ public function add_label(...$args)
{
- $args = func_get_args();
if (count($args) == 1 && is_array($args[0])) {
$args = $args[0];
}
diff --git a/program/lib/Roundcube/db/mssql.php b/program/lib/Roundcube/db/mssql.php
index aab5fe417..bd5c570d7 100644
--- a/program/lib/Roundcube/db/mssql.php
+++ b/program/lib/Roundcube/db/mssql.php
@@ -85,13 +85,11 @@ class rcube_db_mssql extends rcube_db
/**
* Abstract SQL statement for value concatenation
*
- * @return string SQL statement to be used in query
+ * @return string ...$args Values to concatenate
*/
- public function concat(/* col1, col2, ... */)
+ public function concat(...$args)
{
- $args = func_get_args();
-
- if (!empty($args) && is_array($args[0])) {
+ if (count($args) == 1 && is_array($args[0])) {
$args = $args[0];
}
diff --git a/program/lib/Roundcube/db/mysql.php b/program/lib/Roundcube/db/mysql.php
index 8a3922180..d5605a4b3 100644
--- a/program/lib/Roundcube/db/mysql.php
+++ b/program/lib/Roundcube/db/mysql.php
@@ -45,13 +45,11 @@ class rcube_db_mysql extends rcube_db
/**
* Abstract SQL statement for value concatenation
*
- * @return string SQL statement to be used in query
+ * @return string ...$args Values to concatenate
*/
- public function concat(/* col1, col2, ... */)
+ public function concat(...$args)
{
- $args = func_get_args();
-
- if (!empty($args) && is_array($args[0])) {
+ if (count($args) == 1 && is_array($args[0])) {
$args = $args[0];
}
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index 27e93ece5..bc3fd0038 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -1212,15 +1212,13 @@ class rcube
* Construct shell command, execute it and return output as string.
* Keywords {keyword} are replaced with arguments
*
- * @param string $cmd Format string with {keywords} to be replaced
- * @param mixed $values,... (zero, one or more arrays can be passed)
+ * @param string $cmd Format string with {keywords} to be replaced
+ * @param mixed ...$args (zero, one or more arrays can be passed)
*
* @return string Output of command. Shell errors not detectable
*/
- public static function exec(/* $cmd, $values1 = [], ... */)
+ public static function exec($cmd, ...$args)
{
- $args = func_get_args();
- $cmd = array_shift($args);
$values = $replacements = [];
// merge values into one array
@@ -1263,12 +1261,10 @@ class rcube
/**
* Print or write debug messages
*
- * @param mixed Debug message or data
+ * @param mixed ...$args Debug message or data
*/
- public static function console()
+ public static function console(...$args)
{
- $args = func_get_args();
-
if (class_exists('rcube', false)) {
$rcube = self::get_instance();
$plugin = $rcube->plugins->exec_hook('console', ['args' => $args]);
diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php
index 6d35e9222..3b75383a1 100644
--- a/program/lib/Roundcube/rcube_db.php
+++ b/program/lib/Roundcube/rcube_db.php
@@ -390,16 +390,13 @@ class rcube_db
/**
* Execute a SQL query
*
- * @param string SQL query to execute
- * @param mixed Values to be inserted in query
+ * @param string $query SQL query to execute
+ * @param mixed ...$params Query parameter values
*
* @return PDOStatement|false Query handle or False on error
*/
- public function query()
+ public function query($query, ...$params)
{
- $params = func_get_args();
- $query = array_shift($params);
-
// Support one argument of type array, instead of n arguments
if (count($params) == 1 && is_array($params[0])) {
$params = $params[0];
@@ -411,34 +408,29 @@ class rcube_db
/**
* Execute a SQL query with limits
*
- * @param string SQL query to execute
- * @param int Offset for LIMIT statement
- * @param int Number of rows for LIMIT statement
- * @param mixed Values to be inserted in query
+ * @param string $query SQL query to execute
+ * @param int $offset Offset for LIMIT statement
+ * @param int $limit Number of rows for LIMIT statement
+ * @param mixed ...$params Query parameter values
*
* @return PDOStatement|false Query handle or False on error
*/
- public function limitquery()
+ public function limitquery($query, $offset, $limit, ...$params)
{
- $params = func_get_args();
- $query = array_shift($params);
- $offset = array_shift($params);
- $numrows = array_shift($params);
-
- return $this->_query($query, $offset, $numrows, $params);
+ return $this->_query($query, $offset, $limit, $params);
}
/**
* Execute a SQL query with limits
*
- * @param string $query SQL query to execute
- * @param int $offset Offset for LIMIT statement
- * @param int $numrows Number of rows for LIMIT statement
- * @param array $params Values to be inserted in query
+ * @param string $query SQL query to execute
+ * @param int $offset Offset for LIMIT statement
+ * @param int $limit Number of rows for LIMIT statement
+ * @param array $params Values to be inserted in query
*
* @return PDOStatement|false Query handle or False on error
*/
- protected function _query($query, $offset, $numrows, $params)
+ protected function _query($query, $offset, $limit, $params)
{
$query = ltrim($query);
@@ -449,8 +441,8 @@ class rcube_db
return $this->last_result = false;
}
- if ($numrows || $offset) {
- $query = $this->set_limit($query, $numrows, $offset);
+ if ($limit || $offset) {
+ $query = $this->set_limit($query, $limit, $offset);
}
// replace self::DEFAULT_QUOTE with driver-specific quoting
@@ -1079,18 +1071,17 @@ class rcube_db
*/
public function ilike($column, $value)
{
- return $this->quote_identifier($column).' LIKE '.$this->quote($value);
+ return $this->quote_identifier($column) . ' LIKE ' . $this->quote($value);
}
/**
* Abstract SQL statement for value concatenation
*
- * @return string SQL statement to be used in query
+ * @return string ...$args Values to concatenate
*/
- public function concat(/* col1, col2, ... */)
+ public function concat(...$args)
{
- $args = func_get_args();
- if (!empty($args) && is_array($args[0])) {
+ if (count($args) == 1 && is_array($args[0])) {
$args = $args[0];
}
diff --git a/program/lib/Roundcube/rcube_plugin.php b/program/lib/Roundcube/rcube_plugin.php
index 08af422be..f528b5e79 100644
--- a/program/lib/Roundcube/rcube_plugin.php
+++ b/program/lib/Roundcube/rcube_plugin.php
@@ -241,12 +241,11 @@ abstract class rcube_plugin
/**
* Wrapper for add_label() adding the plugin ID as domain
*/
- public function add_label()
+ public function add_label(...$args)
{
$rcube = rcube::get_instance();
if (method_exists($rcube->output, 'add_label')) {
- $args = func_get_args();
if (count($args) == 1 && is_array($args[0])) {
$args = $args[0];
}