From f4ed1024dc43a23bed28ea9b31e4a35d682db7fb Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 2 Dec 2020 20:15:00 +0100 Subject: [PATCH] PHP8 fixes, CS fixes, short array syntax, tests --- program/actions/contacts/edit.php | 2 +- program/actions/contacts/export.php | 2 +- program/actions/contacts/group_addmembers.php | 2 +- program/actions/contacts/index.php | 2 +- program/actions/contacts/photo.php | 2 +- program/actions/mail/show.php | 6 +- program/include/rcmail_install.php | 2 +- program/include/rcmail_output_html.php | 6 +- program/lib/Roundcube/db/pgsql.php | 4 +- program/lib/Roundcube/html.php | 4 +- program/lib/Roundcube/rcube.php | 4 +- program/lib/Roundcube/rcube_charset.php | 2 +- program/lib/Roundcube/rcube_contacts.php | 2 +- program/lib/Roundcube/rcube_csv2vcard.php | 2 +- program/lib/Roundcube/rcube_db.php | 2 +- program/lib/Roundcube/rcube_imap.php | 4 +- program/lib/Roundcube/rcube_imap_generic.php | 2 +- program/lib/Roundcube/rcube_ldap.php | 12 +- program/lib/Roundcube/rcube_ldap_generic.php | 2 +- program/lib/Roundcube/rcube_message.php | 4 +- program/lib/Roundcube/rcube_mime_decode.php | 2 +- program/lib/Roundcube/rcube_output.php | 57 ++-- program/lib/Roundcube/rcube_plugin_api.php | 38 ++- program/lib/Roundcube/rcube_storage.php | 2 +- .../lib/Roundcube/rcube_string_replacer.php | 32 +- program/lib/Roundcube/rcube_text2html.php | 8 +- program/lib/Roundcube/rcube_tnef_decoder.php | 16 +- program/lib/Roundcube/rcube_user.php | 280 ++++++++------- program/lib/Roundcube/rcube_utils.php | 73 ++-- program/lib/Roundcube/rcube_vcard.php | 101 +++--- program/lib/Roundcube/rcube_washtml.php | 95 +++--- tests/Actions/Settings/PrefsSave.php | 3 + tests/Browser/bootstrap.php | 2 +- tests/Framework/CacheDB.php | 2 +- tests/Framework/Output.php | 56 +++ tests/Framework/StringReplacer.php | 51 ++- tests/Framework/Text2Html.php | 135 ++++---- tests/Framework/TnefDecoder.php | 25 +- tests/Framework/User.php | 193 ++++++++++- tests/Framework/Utils.php | 318 +++++++++--------- tests/Framework/VCard.php | 3 + tests/Framework/Washtml.php | 52 +-- tests/Rcmail/Rcmail.php | 14 +- tests/Rcmail/Sendmail.php | 70 ++-- tests/src/sample.rtf | 18 + 45 files changed, 1023 insertions(+), 691 deletions(-) create mode 100644 tests/Framework/Output.php create mode 100644 tests/src/sample.rtf diff --git a/program/actions/contacts/edit.php b/program/actions/contacts/edit.php index a5647b6b8..5f9c47ec1 100644 --- a/program/actions/contacts/edit.php +++ b/program/actions/contacts/edit.php @@ -246,7 +246,7 @@ class rcmail_action_contacts_edit extends rcmail_action_contacts_index $rcmail->output->add_gui_object('editform', $edit_form); } - return array($form_start, $form_end); + return [$form_start, $form_end]; } /** diff --git a/program/actions/contacts/export.php b/program/actions/contacts/export.php index 028cbf551..ecf992e16 100644 --- a/program/actions/contacts/export.php +++ b/program/actions/contacts/export.php @@ -158,7 +158,7 @@ class rcmail_action_contacts_export extends rcmail_action_contacts_index // avoid unwanted casting of DateTime objects to an array // (same as in rcube_contacts::convert_save_data()) if (is_object($values) && is_a($values, 'DateTime')) { - $values = array($values); + $values = [$values]; } foreach ((array) $values as $value) { diff --git a/program/actions/contacts/group_addmembers.php b/program/actions/contacts/group_addmembers.php index 0eaffa538..06cb0ba12 100644 --- a/program/actions/contacts/group_addmembers.php +++ b/program/actions/contacts/group_addmembers.php @@ -57,7 +57,7 @@ class rcmail_action_contacts_group_addmembers extends rcmail_action_contacts_ind ($maxnum = $rcmail->config->get('max_group_members')) && ($contacts->count()->count + $num2add > $maxnum) ) { - $rcmail->output->show_message('maxgroupmembersreached', 'warning', array('max' => $maxnum)); + $rcmail->output->show_message('maxgroupmembersreached', 'warning', ['max' => $maxnum]); $rcmail->output->send(); } diff --git a/program/actions/contacts/index.php b/program/actions/contacts/index.php index e1c99cb52..2a360d80b 100644 --- a/program/actions/contacts/index.php +++ b/program/actions/contacts/index.php @@ -535,7 +535,7 @@ class rcmail_action_contacts_index extends rcmail_action $js_id = rcube::JQ($id); // set class name(s) - $classes = array('contactsearch'); + $classes = ['contactsearch']; if (!empty($source['class_name'])) { $classes[] = $source['class_name']; } diff --git a/program/actions/contacts/photo.php b/program/actions/contacts/photo.php index 1adf36dcc..1412a210d 100644 --- a/program/actions/contacts/photo.php +++ b/program/actions/contacts/photo.php @@ -56,7 +56,7 @@ class rcmail_action_contacts_photo extends rcmail_action_contacts_index if ($email = rcube_utils::get_input_value('_email', rcube_utils::INPUT_GPC)) { foreach ($rcmail->get_address_sources() as $s) { $abook = $rcmail->get_address_book($s['id']); - $result = $abook->search(array('email'), $email, 1, true, true, 'photo'); + $result = $abook->search(['email'], $email, 1, true, true, 'photo'); while ($result && ($record = $result->iterate())) { if ($record['photo']) { break 2; diff --git a/program/actions/mail/show.php b/program/actions/mail/show.php index badd7f4f6..26aa778f5 100644 --- a/program/actions/mail/show.php +++ b/program/actions/mail/show.php @@ -345,7 +345,7 @@ class rcmail_action_mail_show extends rcmail_action_mail_index $photo_img = $placeholder; } - return html::img(array('src' => $photo_img, 'alt' => $rcmail->gettext('contactphoto')) + $attrib); + return html::img(['src' => $photo_img, 'alt' => $rcmail->gettext('contactphoto')] + $attrib); } /** @@ -457,7 +457,7 @@ class rcmail_action_mail_show extends rcmail_action_mail_index $attrib['addicon'], $headers['charset'], $header_title); $ishtml = true; } - else if (in_array($hkey, array('from', 'to', 'cc', 'bcc'))) { + else if (in_array($hkey, ['from', 'to', 'cc', 'bcc'])) { $header_value = self::address_string($value, $attrib['max'], true, $attrib['addicon'], $headers['charset'], $header_title); $ishtml = true; @@ -665,7 +665,7 @@ class rcmail_action_mail_show extends rcmail_action_mail_index // Set attributes of the part container $container_class = $part->ctype_secondary == 'html' ? 'message-htmlpart' : 'message-part'; $container_id = $container_class . (++$part_no); - $container_attrib = array('class' => $container_class, 'id' => $container_id); + $container_attrib = ['class' => $container_class, 'id' => $container_id]; $body_args = [ 'safe' => $safe_mode, diff --git a/program/include/rcmail_install.php b/program/include/rcmail_install.php index aa43c7182..185f063d3 100644 --- a/program/include/rcmail_install.php +++ b/program/include/rcmail_install.php @@ -839,7 +839,7 @@ class rcmail_install } if ($isnum) { - return '[' . implode(', ', array_map(array('rcmail_install', '_dump_var'), $var)) . ']'; + return '[' . implode(', ', array_map(['rcmail_install', '_dump_var'], $var)) . ']'; } } diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index 42f604ade..fb9e4bd74 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -98,7 +98,7 @@ class rcmail_output_html extends rcmail_output if ($this->devel_mode && !empty($_GET['skin']) && preg_match('/^[a-z0-9-_]+$/i', $_GET['skin'])) { if ($this->check_skin($_GET['skin'])) { $this->set_skin($_GET['skin']); - $this->app->user->save_prefs(array('skin' => $_GET['skin'])); + $this->app->user->save_prefs(['skin' => $_GET['skin']]); } } @@ -1877,7 +1877,7 @@ EOF; } if (!isset($this->script_files[$position]) || !is_array($this->script_files[$position])) { - $this->script_files[$position] = array(); + $this->script_files[$position] = []; } if (!in_array($file, $this->script_files[$position])) { @@ -2332,7 +2332,7 @@ EOF; // add oauth login button if ($this->config->get('oauth_auth_uri') && $this->config->get('oauth_provider')) { - $link_attr = array('href' => $this->app->url(['action' => 'oauth']), 'id' => 'rcmloginoauth', 'class' => 'button oauth ' . $this->config->get('oauth_provider')); + $link_attr = ['href' => $this->app->url(['action' => 'oauth']), 'id' => 'rcmloginoauth', 'class' => 'button oauth ' . $this->config->get('oauth_provider')]; $out .= html::p('oauthlogin', html::a($link_attr, $this->app->gettext(['name' => 'oauthlogin', 'vars' => ['provider' => $this->config->get('oauth_provider_name', 'OAuth')]]))); } diff --git a/program/lib/Roundcube/db/pgsql.php b/program/lib/Roundcube/db/pgsql.php index 7a9c0a99a..8c66991c3 100644 --- a/program/lib/Roundcube/db/pgsql.php +++ b/program/lib/Roundcube/db/pgsql.php @@ -212,8 +212,8 @@ class rcube_db_pgsql extends rcube_db } $table = $this->table_name($table, true); - $columns = array_map(array($this, 'quote_identifier'), $columns); - $target = implode(', ', array_map(array($this, 'quote_identifier'), array_keys($keys))); + $columns = array_map([$this, 'quote_identifier'], $columns); + $target = implode(', ', array_map([$this, 'quote_identifier'], array_keys($keys))); $cols = $target . ', ' . implode(', ', $columns); $vals = implode(', ', array_map(function($i) { return $this->quote($i); }, $keys)); $vals .= ', ' . rtrim(str_repeat('?, ', count($columns)), ', '); diff --git a/program/lib/Roundcube/html.php b/program/lib/Roundcube/html.php index 546c4f731..aa85dae29 100644 --- a/program/lib/Roundcube/html.php +++ b/program/lib/Roundcube/html.php @@ -658,13 +658,13 @@ class html_textarea extends html * Builder for HTML drop-down menus * Syntax:
  * // create instance. arguments are used to set attributes of select-tag
- * $select = new html_select(array('name' => 'fieldname'));
+ * $select = new html_select(['name' => 'fieldname']);
  *
  * // add one option
  * $select->add('Switzerland', 'CH');
  *
  * // add multiple options
- * $select->add(array('Switzerland','Germany'), array('CH','DE'));
+ * $select->add(['Switzerland','Germany'], ['CH','DE']);
  *
  * // generate pulldown with selection 'Switzerland'  and return html-code
  * // as second argument the same attributes available to instantiate can be used
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index 817824ae6..6ba90802f 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -1194,7 +1194,7 @@ class rcube
      *
      * @return string Output of command. Shell errors not detectable
      */
-    public static function exec(/* $cmd, $values1 = array(), ... */)
+    public static function exec(/* $cmd, $values1 = [], ... */)
     {
         $args   = func_get_args();
         $cmd    = array_shift($args);
@@ -1658,7 +1658,7 @@ class rcube
 
         // Try to find FQDN, some spamfilters doesn't like 'localhost' (#1486924)
         if (!preg_match('/\.[a-z0-9-]+$/i', $domain_part)) {
-            foreach (array($_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME']) as $host) {
+            foreach ([$_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME']] as $host) {
                 $host = preg_replace('/:[0-9]+$/', '', $host);
                 if ($host && preg_match('/\.[a-z]+$/i', $host)) {
                     $domain_part = $host;
diff --git a/program/lib/Roundcube/rcube_charset.php b/program/lib/Roundcube/rcube_charset.php
index 311ba20ce..bdb05bbc4 100644
--- a/program/lib/Roundcube/rcube_charset.php
+++ b/program/lib/Roundcube/rcube_charset.php
@@ -292,7 +292,7 @@ class rcube_charset
 
         // throw an exception if mbstring reports an illegal character in input
         // using mb_check_encoding() is much slower
-        set_error_handler(array('rcube_charset', 'error_handler'), E_WARNING);
+        set_error_handler(['rcube_charset', 'error_handler'], E_WARNING);
         try {
             $out = mb_convert_encoding($str, $to, $from);
         }
diff --git a/program/lib/Roundcube/rcube_contacts.php b/program/lib/Roundcube/rcube_contacts.php
index 47a45587e..2cb7d8935 100644
--- a/program/lib/Roundcube/rcube_contacts.php
+++ b/program/lib/Roundcube/rcube_contacts.php
@@ -347,7 +347,7 @@ class rcube_contacts extends rcube_addressbook
         }
         else {
             // require each word in to be present in one of the fields
-            $words = ($mode & rcube_addressbook::SEARCH_STRICT) ? array($value) : rcube_utils::tokenize_string($value, 1);
+            $words = ($mode & rcube_addressbook::SEARCH_STRICT) ? [$value] : rcube_utils::tokenize_string($value, 1);
             foreach ($words as $word) {
                 $groups = [];
                 foreach ((array) $fields as $idx => $col) {
diff --git a/program/lib/Roundcube/rcube_csv2vcard.php b/program/lib/Roundcube/rcube_csv2vcard.php
index 9baf0ed64..d8c5c25d2 100644
--- a/program/lib/Roundcube/rcube_csv2vcard.php
+++ b/program/lib/Roundcube/rcube_csv2vcard.php
@@ -647,7 +647,7 @@ class rcube_csv2vcard
         }
 
         // Empty dates, e.g. "0/0/00", "0000-00-00 00:00:00"
-        foreach (array('birthday', 'anniversary') as $key) {
+        foreach (['birthday', 'anniversary'] as $key) {
             if (!empty($contact[$key])) {
                 $date = preg_replace('/[0[:^word:]]/', '', $contact[$key]);
                 if (empty($date)) {
diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php
index 644f35543..d95843403 100644
--- a/program/lib/Roundcube/rcube_db.php
+++ b/program/lib/Roundcube/rcube_db.php
@@ -1326,7 +1326,7 @@ class rcube_db
                     $opts = explode('&', $dsn);
                 }
                 else { // database?param1=value1
-                    $opts = array($dsn);
+                    $opts = [$dsn];
                 }
                 foreach ($opts as $opt) {
                     list($key, $value) = explode('=', $opt);
diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index 4265ebc7b..8ed2e6d84 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -2186,7 +2186,7 @@ class rcube_imap extends rcube_storage
 
         // get message/rfc822's child-parts
         if (is_array($part[8]) && $di != 8) {
-            $struct->parts = array();
+            $struct->parts = [];
             for ($i=0, $count=0; $iget_capability('QRESYNC') || $this->get_capability('CONDSTORE'))
         ) {
-            if ($add_data = $this->conn->status($folder, array('HIGHESTMODSEQ'))) {
+            if ($add_data = $this->conn->status($folder, ['HIGHESTMODSEQ'])) {
                 $data = array_merge($data, $add_data);
             }
         }
diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php
index 18ee54a3d..6eca2b96e 100644
--- a/program/lib/Roundcube/rcube_imap_generic.php
+++ b/program/lib/Roundcube/rcube_imap_generic.php
@@ -2158,7 +2158,7 @@ class rcube_imap_generic
 
                 if ($mode == 1 && $index_field == 'DATE') {
                     if (preg_match('/BODY\[HEADER\.FIELDS \("*DATE"*\)\] (.*)/', $line, $matches)) {
-                        $value = preg_replace(array('/^"*[a-z]+:/i'), '', $matches[1]);
+                        $value = preg_replace(['/^"*[a-z]+:/i'], '', $matches[1]);
                         $value = trim($value);
                         $result[$id] = rcube_utils::strtotime($value);
                     }
diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php
index dc4b2f096..d1edda85d 100644
--- a/program/lib/Roundcube/rcube_ldap.php
+++ b/program/lib/Roundcube/rcube_ldap.php
@@ -179,12 +179,12 @@ class rcube_ldap extends rcube_addressbook
 
         // support for composite address
         if (!empty($this->coltypes['street']) && !empty($this->coltypes['locality'])) {
-            $this->coltypes['address'] = array(
+            $this->coltypes['address'] = [
                'limit'    => max(1, $this->coltypes['locality']['limit'] + $this->coltypes['address']['limit']),
                'subtypes' => array_merge((array)$this->coltypes['address']['subtypes'], (array)$this->coltypes['locality']['subtypes']),
                'childs'   => [],
                'attributes' => [],
-               ) + (array)$this->coltypes['address'];
+               ] + (array)$this->coltypes['address'];
 
             foreach (['street','locality','zipcode','region','country'] as $childcol) {
                 if ($this->coltypes[$childcol]) {
@@ -676,7 +676,7 @@ class rcube_ldap extends rcube_addressbook
             $attrs = [];
 
             foreach ((array) $entry['objectclass'] as $objectclass) {
-                if (($member_attr = $this->get_group_member_attr(array($objectclass), ''))
+                if (($member_attr = $this->get_group_member_attr([$objectclass], ''))
                     && ($member_attr = strtolower($member_attr)) && !in_array($member_attr, $attrs)
                 ) {
                     $members       = $this->_list_group_members($dn, $entry, $member_attr, $count);
@@ -1036,7 +1036,7 @@ class rcube_ldap extends rcube_addressbook
 
             $name_attr  = $this->prop['groups']['name_attr'];
             $email_attr = $this->prop['groups']['email_attr'] ?: 'mail';
-            $attrs      = array_unique(array('dn', 'objectClass', $name_attr, $email_attr));
+            $attrs      = array_unique(['dn', 'objectClass', $name_attr, $email_attr]);
 
             $res = $this->ldap->search($this->groups_base_dn, $filter, $this->prop['groups']['scope'], $attrs, $prop, $count);
 
@@ -1349,7 +1349,7 @@ class rcube_ldap extends rcube_addressbook
                         if (!in_array($fld, $this->prop['required_fields'])) {
                             // ...It is not, safe to clear.
                             // #1488420: Workaround "ldap_mod_del(): Modify: Inappropriate matching in..."
-                            // jpegPhoto attribute require an array() here. It looks to me that it works for other attribs too
+                            // jpegPhoto attribute require an array here. It looks to me that it works for other attribs too
                             $deletedata[$fld] = [];
                             //$deletedata[$fld] = $old_data[$fld];
                         }
@@ -1691,7 +1691,7 @@ class rcube_ldap extends rcube_addressbook
                foreach ($colprop['serialized'] as $subtype => $delim) {
                   $key = $col.':'.$subtype;
                   foreach ((array)$save_cols[$key] as $i => $val) {
-                     $values = array($val['street'], $val['locality'], $val['zipcode'], $val['country']);
+                     $values = [$val['street'], $val['locality'], $val['zipcode'], $val['country']];
                      $save_cols[$key][$i] = count(array_filter($values)) ? implode($delim, $values) : null;
                  }
                }
diff --git a/program/lib/Roundcube/rcube_ldap_generic.php b/program/lib/Roundcube/rcube_ldap_generic.php
index 1e779c95b..f696566f5 100644
--- a/program/lib/Roundcube/rcube_ldap_generic.php
+++ b/program/lib/Roundcube/rcube_ldap_generic.php
@@ -294,7 +294,7 @@ class rcube_ldap_generic extends Net_LDAP3
             if ($entry[$attr]['count'] == 1) {
                 switch ($attr) {
                     case 'objectclass':
-                        $rec[$attr] = array(strtolower($entry[$attr][0]));
+                        $rec[$attr] = [strtolower($entry[$attr][0])];
                         break;
                     default:
                         $rec[$attr] = $entry[$attr][0];
diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php
index 20a09d46c..92992c0a2 100644
--- a/program/lib/Roundcube/rcube_message.php
+++ b/program/lib/Roundcube/rcube_message.php
@@ -875,7 +875,7 @@ class rcube_message
                     }
 
                     if ($mail_part->headers['content-id']) {
-                        $mail_part->content_id = preg_replace(array('/^$/'), '', $mail_part->headers['content-id']);
+                        $mail_part->content_id = preg_replace(['/^$/'], '', $mail_part->headers['content-id']);
                     }
 
                     if ($mail_part->headers['content-location']) {
@@ -924,7 +924,7 @@ class rcube_message
             // if this is a related part try to resolve references
             // Note: mixed is not supposed to contain inline images, but we've found such examples (#5905)
             if (preg_match('/^multipart\/(related|relative|mixed)/', $mimetype) && count($this->inline_parts)) {
-                $a_replaces = array();
+                $a_replaces = [];
                 $img_regexp = '/^image\/(gif|jpe?g|png|tiff|bmp|svg)/';
 
                 foreach ($this->inline_parts as $inline_object) {
diff --git a/program/lib/Roundcube/rcube_mime_decode.php b/program/lib/Roundcube/rcube_mime_decode.php
index 9f7f11f23..c9695d791 100644
--- a/program/lib/Roundcube/rcube_mime_decode.php
+++ b/program/lib/Roundcube/rcube_mime_decode.php
@@ -107,7 +107,7 @@ class rcube_mime_decode
             $header_name = strtolower($value['name']);
 
             if (isset($return->headers[$header_name]) && !is_array($return->headers[$header_name])) {
-                $return->headers[$header_name]   = array($return->headers[$header_name]);
+                $return->headers[$header_name]   = [$return->headers[$header_name]];
                 $return->headers[$header_name][] = $value['value'];
             }
             else if (isset($return->headers[$header_name])) {
diff --git a/program/lib/Roundcube/rcube_output.php b/program/lib/Roundcube/rcube_output.php
index 0440b890f..aea09dddd 100644
--- a/program/lib/Roundcube/rcube_output.php
+++ b/program/lib/Roundcube/rcube_output.php
@@ -31,8 +31,8 @@ abstract class rcube_output
     protected $app;
     protected $config;
     protected $charset = RCUBE_CHARSET;
-    protected $env = array();
-    protected $skins = array();
+    protected $env     = [];
+    protected $skins   = [];
 
 
     /**
@@ -82,8 +82,8 @@ abstract class rcube_output
     /**
      * Set environment variable
      *
-     * @param string $name   Property name
-     * @param mixed  $value  Property value
+     * @param string $name  Property name
+     * @param mixed  $value Property value
      */
     public function set_env($name, $value)
     {
@@ -93,7 +93,7 @@ abstract class rcube_output
     /**
      * Environment variable getter.
      *
-     * @param string $name  Property name
+     * @param string $name Property name
      *
      * @return mixed Property value
      */
@@ -107,7 +107,7 @@ abstract class rcube_output
      */
     public function reset()
     {
-        $this->env = array();
+        $this->env = [];
     }
 
     /**
@@ -116,7 +116,7 @@ abstract class rcube_output
      * @param string  $message  Message to display
      * @param string  $type     Message type [notice|confirm|error]
      * @param array   $vars     Key-value pairs to be replaced in localized text
-     * @param boolean $override Override last set message
+     * @param bool    $override Override last set message
      * @param int     $timeout  Message displaying time in seconds
      */
     abstract function show_message($message, $type = 'notice', $vars = null, $override = true, $timeout = 0);
@@ -124,10 +124,10 @@ abstract class rcube_output
     /**
      * Redirect to a certain url.
      *
-     * @param mixed $p     Either a string with the action or url parameters as key-value pairs
-     * @param int   $delay Delay in seconds
+     * @param array|string $p     Either a string with the action or url parameters as key-value pairs
+     * @param int          $delay Delay in seconds
      */
-    abstract function redirect($p = array(), $delay = 1);
+    abstract function redirect($p = [], $delay = 1);
 
     /**
      * Send output to the client.
@@ -184,7 +184,7 @@ abstract class rcube_output
             return;
         }
 
-        $headers = array();
+        $headers = [];
 
         // Unlock IE compatibility mode
         if ($this->browser->ie) {
@@ -204,7 +204,7 @@ abstract class rcube_output
             $headers['X-Frame-Options'] = $xframe;
         }
 
-        $plugin = $this->app->plugins->exec_hook('common_headers', array('headers' => $headers, 'privacy' => $privacy));
+        $plugin = $this->app->plugins->exec_hook('common_headers', ['headers' => $headers, 'privacy' => $privacy]);
 
         foreach ($plugin['headers'] as $header => $value) {
             header("$header: $value");
@@ -223,7 +223,7 @@ abstract class rcube_output
      *                         type_charset - Content character set
      *                         time_limit   - Script execution limit (default: 3600)
      */
-    public function download_headers($filename, $params = array())
+    public function download_headers($filename, $params = [])
     {
         if (empty($params['disposition'])) {
             $params['disposition'] = 'attachment';
@@ -246,7 +246,10 @@ abstract class rcube_output
             $disposition .= sprintf("; filename=\"%s\"", $filename);
         }
         else {
-            $disposition .= sprintf("; filename*=%s''%s", $params['charset'] ?: $this->charset, rawurlencode($filename));
+            $disposition .= sprintf("; filename*=%s''%s",
+                !empty($params['charset']) ? $params['charset'] : $this->charset,
+                rawurlencode($filename)
+            );
         }
 
         header($disposition);
@@ -281,27 +284,29 @@ abstract class rcube_output
     /**
      * Create an edit field for inclusion on a form
      *
-     * @param string $col    Field name
+     * @param string $name   Field name
      * @param string $value  Field value
      * @param array  $attrib HTML element attributes for the field
      * @param string $type   HTML element type (default 'text')
      *
      * @return string HTML field definition
      */
-    public static function get_edit_field($col, $value, $attrib, $type = 'text')
+    public static function get_edit_field($name, $value, $attrib = [], $type = 'text')
     {
-        static $colcounts = array();
+        static $colcounts = [];
 
-        $fname           = '_' . $col;
+        $fname           = '_' . $name;
         $attrib['name']  = $fname . (!empty($attrib['array']) ? '[]' : '');
-        $attrib['class'] = trim((!empty($attrib['class']) ? $attrib['class'] : '') . ' ff_' . $col);
+        $attrib['class'] = trim((!empty($attrib['class']) ? $attrib['class'] : '') . ' ff_' . $name);
 
         if ($type == 'checkbox') {
             $attrib['value'] = '1';
             $input = new html_checkbox($attrib);
         }
         else if ($type == 'textarea') {
-            $attrib['cols'] = $attrib['size'];
+            if (!empty($attrib['size'])) {
+                $attrib['cols'] = $attrib['size'];
+            }
             $input = new html_textarea($attrib);
         }
         else if ($type == 'select') {
@@ -309,7 +314,9 @@ abstract class rcube_output
             if (empty($attrib['skip-empty'])) {
                 $input->add('---', '');
             }
-            $input->add(array_values($attrib['options']), array_keys($attrib['options']));
+            if (!empty($attrib['options'])) {
+                $input->add(array_values($attrib['options']), array_keys($attrib['options']));
+            }
         }
         else if ($type == 'password' || (isset($attrib['type']) && $attrib['type'] == 'password')) {
             $input = new html_passwordfield($attrib);
@@ -324,7 +331,7 @@ abstract class rcube_output
         // use value from post
         if (isset($_POST[$fname])) {
             $postvalue = rcube_utils::get_input_value($fname, rcube_utils::INPUT_POST, true);
-            $value = !empty($attrib['array']) ? $postvalue[intval($colcounts[$col]++)] : $postvalue;
+            $value = !empty($attrib['array']) ? $postvalue[intval($colcounts[$name]++)] : $postvalue;
         }
 
         return $input->show($value);
@@ -333,9 +340,9 @@ abstract class rcube_output
     /**
      * Convert a variable into a javascript object notation
      *
-     * @param mixed   $input  Input value
-     * @param boolean $pretty Enable JSON formatting
-     * @param boolean $inline Enable inline mode (generates output safe for use inside HTML)
+     * @param mixed $input  Input value
+     * @param bool  $pretty Enable JSON formatting
+     * @param bool  $inline Enable inline mode (generates output safe for use inside HTML)
      *
      * @return string Serialized JSON string
      */
diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php
index c5ce0a67d..d7de956be 100644
--- a/program/lib/Roundcube/rcube_plugin_api.php
+++ b/program/lib/Roundcube/rcube_plugin_api.php
@@ -438,8 +438,8 @@ class rcube_plugin_api
     /**
      * Allows a plugin object to register a callback for a certain hook
      *
-     * @param string $hook Hook name
-     * @param mixed  $callback String with global function name or array($obj, 'methodname')
+     * @param string   $hook     Hook name
+     * @param callback $callback A callback function
      */
     public function register_hook($hook, $callback)
     {
@@ -468,8 +468,8 @@ class rcube_plugin_api
     /**
      * Allow a plugin object to unregister a callback.
      *
-     * @param string $hook Hook name
-     * @param mixed  $callback String with global function name or array($obj, 'methodname')
+     * @param string   $hook     Hook name
+     * @param callback $callback A callback function
      */
     public function unregister_hook($hook, $callback)
     {
@@ -526,18 +526,20 @@ class rcube_plugin_api
     /**
      * Let a plugin register a handler for a specific request
      *
-     * @param string $action   Action name (_task=mail&_action=plugin.foo)
-     * @param string $owner    Plugin name that registers this action
-     * @param mixed  $callback Callback: string with global function name or array($obj, 'methodname')
-     * @param string $task     Task name registered by this plugin
+     * @param string   $action   Action name (_task=mail&_action=plugin.foo)
+     * @param string   $owner    Plugin name that registers this action
+     * @param callback $callback A callback function
+     * @param string   $task     Task name registered by this plugin
      */
     public function register_action($action, $owner, $callback, $task = null)
     {
         // check action name
-        if ($task)
+        if ($task) {
             $action = $task.'.'.$action;
-        else if (strpos($action, 'plugin.') !== 0)
+        }
+        else if (strpos($action, 'plugin.') !== 0) {
             $action = 'plugin.'.$action;
+        }
 
         // can register action only if it's not taken or registered by myself
         if (!isset($this->actionmap[$action]) || $this->actionmap[$action] == $owner) {
@@ -545,10 +547,12 @@ class rcube_plugin_api
             $this->actionmap[$action] = $owner;
         }
         else {
-            rcube::raise_error(array('code' => 523, 'type' => 'php',
-                'file' => __FILE__, 'line' => __LINE__,
-                'message' => "Cannot register action $action;"
-                    ." already taken by another plugin"), true, false);
+            rcube::raise_error([
+                    'code' => 523, 'file' => __FILE__, 'line' => __LINE__,
+                    'message' => "Cannot register action $action; already taken by another plugin"
+                ],
+                true, false
+            );
         }
     }
 
@@ -576,9 +580,9 @@ class rcube_plugin_api
     /**
      * Register a handler function for template objects
      *
-     * @param string $name     Object name
-     * @param string $owner    Plugin name that registers this action
-     * @param mixed  $callback Callback: string with global function name or array($obj, 'methodname')
+     * @param string   $name     Object name
+     * @param string   $owner    Plugin name that registers this action
+     * @param callback $callback A callback function
      */
     public function register_handler($name, $owner, $callback)
     {
diff --git a/program/lib/Roundcube/rcube_storage.php b/program/lib/Roundcube/rcube_storage.php
index 8d1ac64d1..c1818f1a2 100644
--- a/program/lib/Roundcube/rcube_storage.php
+++ b/program/lib/Roundcube/rcube_storage.php
@@ -613,7 +613,7 @@ abstract class rcube_storage
             }
         }
 
-        return array($uids, $all);
+        return [$uids, $all];
     }
 
 
diff --git a/program/lib/Roundcube/rcube_string_replacer.php b/program/lib/Roundcube/rcube_string_replacer.php
index f42479e34..1f6f40ec0 100644
--- a/program/lib/Roundcube/rcube_string_replacer.php
+++ b/program/lib/Roundcube/rcube_string_replacer.php
@@ -31,10 +31,10 @@ class rcube_string_replacer
     public $linkref_index;
     public $linkref_pattern;
 
-    protected $values   = array();
-    protected $options  = array();
-    protected $linkrefs = array();
-    protected $urls     = array();
+    protected $values   = [];
+    protected $options  = [];
+    protected $linkrefs = [];
+    protected $urls     = [];
     protected $noword   = '[^\w@.#-]';
 
 
@@ -43,7 +43,7 @@ class rcube_string_replacer
      *
      * @param array $options Configuration options
      */
-    function __construct($options = array())
+    function __construct($options = [])
     {
         // Simplified domain expression for UTF8 characters handling
         // Support unicode/punycode in top-level domain part
@@ -201,11 +201,11 @@ class rcube_string_replacer
     public function replace($str)
     {
         // search for patterns like links and e-mail addresses
-        $str = preg_replace_callback($this->link_pattern, array($this, 'link_callback'), $str);
-        $str = preg_replace_callback($this->mailto_pattern, array($this, 'mailto_callback'), $str);
+        $str = preg_replace_callback($this->link_pattern, [$this, 'link_callback'], $str);
+        $str = preg_replace_callback($this->mailto_pattern, [$this, 'mailto_callback'], $str);
         // resolve link references
-        $str = preg_replace_callback($this->linkref_index, array($this, 'linkref_addindex'), $str);
-        $str = preg_replace_callback($this->linkref_pattern, array($this, 'linkref_callback'), $str);
+        $str = preg_replace_callback($this->linkref_index, [$this, 'linkref_addindex'], $str);
+        $str = preg_replace_callback($this->linkref_pattern, [$this, 'linkref_callback'], $str);
 
         return $str;
     }
@@ -219,7 +219,7 @@ class rcube_string_replacer
      */
     public function resolve($str)
     {
-        return preg_replace_callback(self::$pattern, array($this, 'replace_callback'), $str);
+        return preg_replace_callback(self::$pattern, [$this, 'replace_callback'], $str);
     }
 
     /**
@@ -245,13 +245,15 @@ class rcube_string_replacer
             $in = false;
             for ($i=0, $len=strlen($url); $i<$len; $i++) {
                 if ($url[$i] == '[') {
-                    if ($in)
+                    if ($in) {
                         break;
+                    }
                     $in = true;
                 }
                 else if ($url[$i] == ']') {
-                    if (!$in)
+                    if (!$in) {
                         break;
+                    }
                     $in = false;
                 }
             }
@@ -267,13 +269,15 @@ class rcube_string_replacer
             $in = false;
             for ($i=0, $len=strlen($url); $i<$len; $i++) {
                 if ($url[$i] == '(') {
-                    if ($in)
+                    if ($in) {
                         break;
+                    }
                     $in = true;
                 }
                 else if ($url[$i] == ')') {
-                    if (!$in)
+                    if (!$in) {
                         break;
+                    }
                     $in = false;
                 }
             }
diff --git a/program/lib/Roundcube/rcube_text2html.php b/program/lib/Roundcube/rcube_text2html.php
index 1e8121f62..f35153859 100644
--- a/program/lib/Roundcube/rcube_text2html.php
+++ b/program/lib/Roundcube/rcube_text2html.php
@@ -32,7 +32,7 @@ class rcube_text2html
     protected $text;
 
     /** @var array Configuration */
-    protected $config = array(
+    protected $config = [
         // non-breaking space
         'space' => "\xC2\xA0",
         // enables format=flowed parser
@@ -53,7 +53,7 @@ class rcube_text2html
         // prefix and suffix of unwrappable line
         'nobr_start' => '',
         'nobr_end'   => '',
-    );
+    ];
 
     /** @var bool Internal state */
     protected $_converted = false;
@@ -70,7 +70,7 @@ class rcube_text2html
      * @param bool   $from_file Indicates $source is a file to pull content from
      * @param array  $config    Class configuration
      */
-    function __construct($source = '', $from_file = false, $config = array())
+    function __construct($source = '', $from_file = false, $config = [])
     {
         if (!empty($source)) {
             $this->set_text($source, $from_file);
@@ -141,7 +141,7 @@ class rcube_text2html
     protected function _converter($text)
     {
         // make links and email-addresses clickable
-        $attribs  = array('link_attribs' => array('rel' => 'noreferrer', 'target' => '_blank'));
+        $attribs  = ['link_attribs' => ['rel' => 'noreferrer', 'target' => '_blank']];
         $replacer = new $this->config['replacer']($attribs);
 
         if ($this->config['flowed']) {
diff --git a/program/lib/Roundcube/rcube_tnef_decoder.php b/program/lib/Roundcube/rcube_tnef_decoder.php
index accc87240..47ee1db6a 100644
--- a/program/lib/Roundcube/rcube_tnef_decoder.php
+++ b/program/lib/Roundcube/rcube_tnef_decoder.php
@@ -135,8 +135,8 @@ class rcube_tnef_decoder
      */
     public function decompress($data)
     {
-        $attachments = array();
-        $message     = array();
+        $attachments = [];
+        $message     = [];
 
         if ($this->_geti($data, 32) == self::SIGNATURE) {
             $this->_geti($data, 16);
@@ -160,10 +160,10 @@ class rcube_tnef_decoder
             }
         }
 
-        return array(
+        return [
             'message'     => $message,
             'attachments' => array_reverse($attachments),
-        );
+        ];
     }
 
     /**
@@ -425,12 +425,12 @@ class rcube_tnef_decoder
         case self::ARENDDATA:
             // Add a new default data block to hold details of this
             // attachment. Reverse order is easier to handle later!
-            array_unshift($attachment, array(
+            array_unshift($attachment, [
                     'type'    => 'application',
                     'subtype' => 'octet-stream',
                     'name'    => 'unknown',
                     'stream'  => ''
-            ));
+            ]);
 
             break;
 
@@ -547,7 +547,7 @@ class rcube_tnef_decoder
     public static function rtf2text($text)
     {
         $document = '';
-        $stack    = array();
+        $stack    = [];
         $j        = -1;
 
         // Read the data character-by- character…
@@ -746,7 +746,7 @@ class rcube_tnef_decoder
      */
     protected static function _rtfIsPlain($s)
     {
-        $notPlain = array('*', 'fonttbl', 'colortbl', 'datastore', 'themedata', 'stylesheet');
+        $notPlain = ['*', 'fonttbl', 'colortbl', 'datastore', 'themedata', 'stylesheet'];
 
         for ($i = 0; $i < count($notPlain); $i++) {
             if (!empty($s[$notPlain[$i]])) {
diff --git a/program/lib/Roundcube/rcube_user.php b/program/lib/Roundcube/rcube_user.php
index c51bd2a4f..eb431d1c0 100644
--- a/program/lib/Roundcube/rcube_user.php
+++ b/program/lib/Roundcube/rcube_user.php
@@ -47,7 +47,7 @@ class rcube_user
     private $rc;
 
     /** @var array Internal identities cache */
-    private $identities = array();
+    private $identities = [];
 
     /** @var array Internal emails cache */
     private $emails;
@@ -71,12 +71,14 @@ class rcube_user
         if ($id && !$sql_arr) {
             $sql_result = $this->db->query(
                 "SELECT * FROM " . $this->db->table_name('users', true)
-                . " WHERE `user_id` = ?", $id);
+                . " WHERE `user_id` = ?", $id
+            );
+
             $sql_arr = $this->db->fetch_assoc($sql_result);
         }
 
         if (!empty($sql_arr)) {
-            $this->ID       = $sql_arr['user_id'];
+            $this->ID       = (int) $sql_arr['user_id'];
             $this->data     = $sql_arr;
             $this->language = $sql_arr['language'];
         }
@@ -91,13 +93,13 @@ class rcube_user
      */
     function get_username($part = null)
     {
-        if ($this->data['username']) {
+        if (!empty($this->data['username'])) {
             // return real name
             if (!$part) {
                 return $this->data['username'];
             }
 
-            list($local, $domain) = explode('@', $this->data['username']);
+            list($local, $domain) = rcube_utils::explode('@', $this->data['username']);
 
             // at least we should always have the local part
             if ($part == 'local') {
@@ -131,10 +133,11 @@ class rcube_user
             return $this->prefs;
         }
 
-        $this->prefs = array();
+        $this->prefs = [];
 
-        if (!empty($this->language))
+        if (!empty($this->language)) {
             $this->prefs['language'] = $this->language;
+        }
 
         if ($this->ID) {
             // Preferences from session (write-master is unavailable)
@@ -152,7 +155,7 @@ class rcube_user
             }
 
             if ($this->data['preferences']) {
-                $this->prefs += (array)unserialize($this->data['preferences']);
+                $this->prefs += (array) unserialize($this->data['preferences']);
             }
         }
 
@@ -165,7 +168,7 @@ class rcube_user
      * @param array $a_user_prefs User prefs to save
      * @param bool  $no_session   Simplified language/preferences handling
      *
-     * @return boolean True on success, False on failure
+     * @return bool True on success, False on failure
      */
     function save_prefs($a_user_prefs, $no_session = false)
     {
@@ -181,11 +184,11 @@ class rcube_user
             return true;
         }
 
-        $plugin = $this->rc->plugins->exec_hook('preferences_update', array(
+        $plugin = $this->rc->plugins->exec_hook('preferences_update', [
                 'userid' => $this->ID,
                 'prefs'  => $a_user_prefs,
                 'old'    => (array)$this->get_prefs()
-        ));
+        ]);
 
         if (!empty($plugin['abort'])) {
             return false;
@@ -218,7 +221,8 @@ class rcube_user
             " WHERE `user_id` = ?",
             $save_prefs,
             $this->language,
-            $this->ID);
+            $this->ID
+        );
 
         // Update success
         if ($this->db->affected_rows() !== false) {
@@ -251,7 +255,7 @@ class rcube_user
     }
 
     /**
-     * Generate a unique hash to identify this user whith
+     * Generate a unique hash to identify this user with
      */
     function get_hash()
     {
@@ -260,7 +264,7 @@ class rcube_user
         // generate a random hash and store it in user prefs
         if (empty($prefs['client_hash'])) {
             $prefs['client_hash'] = rcube_utils::random_bytes(16);
-            $this->save_prefs(array('client_hash' => $prefs['client_hash']));
+            $this->save_prefs(['client_hash' => $prefs['client_hash']]);
         }
 
         return $prefs['client_hash'];
@@ -271,19 +275,20 @@ class rcube_user
      *
      * @param bool $default Return only default identity
      *
-     * @return array List of emails (identity_id, name, email)
+     * @return array List of emails (identity_id, name, email) or single email-data
      */
     function list_emails($default = false)
     {
         if ($this->emails === null) {
-            $this->emails = array();
+            $this->emails = [];
 
             $sql_result = $this->db->query(
                 "SELECT `identity_id`, `name`, `email`"
                 ." FROM " . $this->db->table_name('identities', true)
                 ." WHERE `user_id` = ? AND `del` <> 1"
                 ." ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC",
-                $this->ID);
+                $this->ID
+            );
 
             while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
                 $this->emails[] = $sql_arr;
@@ -302,7 +307,8 @@ class rcube_user
      */
     function get_identity($id = null)
     {
-        $id = (int)$id;
+        $id = (int) $id;
+
         // cache identities for better performance
         if (!array_key_exists($id, $this->identities)) {
             $result = $this->list_identities($id ? "AND `identity_id` = $id" : '');
@@ -322,14 +328,14 @@ class rcube_user
      */
     function list_identities($sql_add = '', $formatted = false)
     {
-        $result = array();
+        $result = [];
 
         $sql_result = $this->db->query(
-            "SELECT * FROM ".$this->db->table_name('identities', true).
-            " WHERE `del` <> 1 AND `user_id` = ?".
-            ($sql_add ? " ".$sql_add : "").
-            " ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC",
-            $this->ID);
+            "SELECT * FROM ".$this->db->table_name('identities', true)
+            . " WHERE `del` <> 1 AND `user_id` = ?" . ($sql_add ? " $sql_add" : "")
+            . " ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC",
+            $this->ID
+        );
 
         while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
             if ($formatted) {
@@ -353,7 +359,7 @@ class rcube_user
      * @param int   $iid  Identity ID
      * @param array $data Hash array with col->value pairs to save
      *
-     * @return boolean True if saved successfully, false if nothing changed
+     * @return bool True if saved successfully, false if nothing changed
      */
     function update_identity($iid, $data)
     {
@@ -361,9 +367,9 @@ class rcube_user
             return false;
         }
 
-        $query_cols = $query_params = array();
+        $query_cols = $query_params = [];
 
-        foreach ((array)$data as $col => $value) {
+        foreach ((array) $data as $col => $value) {
             $query_cols[]   = $this->db->quote_identifier($col) . ' = ?';
             $query_params[] = $value;
         }
@@ -371,16 +377,15 @@ class rcube_user
         $query_params[] = $this->ID;
 
         $sql = "UPDATE ".$this->db->table_name('identities', true).
-            " SET `changed` = ".$this->db->now().", ".implode(', ', $query_cols).
-            " WHERE `identity_id` = ?".
-                " AND `user_id` = ?".
-                " AND `del` <> 1";
+            " SET `changed` = ".$this->db->now() . ", " . implode(', ', $query_cols)
+            . " WHERE `identity_id` = ?"
+                . " AND `user_id` = ?"
+                . " AND `del` <> 1";
 
-        call_user_func_array(array($this->db, 'query'),
-            array_merge(array($sql), $query_params));
+        $this->db->query($sql, $query_params);
 
         // clear the cache
-        $this->identities = array();
+        $this->identities = [];
         $this->emails     = null;
 
         return $this->db->affected_rows() > 0;
@@ -391,7 +396,7 @@ class rcube_user
      *
      * @param array $data Hash array with col->value pairs to save
      *
-     * @return int The inserted identity ID or false on error
+     * @return int|false The inserted identity ID or false on error
      */
     function insert_identity($data)
     {
@@ -401,10 +406,10 @@ class rcube_user
 
         unset($data['user_id']);
 
-        $insert_cols   = array();
-        $insert_values = array();
+        $insert_cols   = [];
+        $insert_values = [];
 
-        foreach ((array)$data as $col => $value) {
+        foreach ((array) $data as $col => $value) {
             $insert_cols[]   = $this->db->quote_identifier($col);
             $insert_values[] = $value;
         }
@@ -412,14 +417,14 @@ class rcube_user
         $insert_cols[]   = $this->db->quote_identifier('user_id');
         $insert_values[] = $this->ID;
 
-        $sql = "INSERT INTO ".$this->db->table_name('identities', true).
-            " (`changed`, ".implode(', ', $insert_cols).")".
-            " VALUES (".$this->db->now().", ".implode(', ', array_pad(array(), count($insert_values), '?')).")";
+        $sql = "INSERT INTO " . $this->db->table_name('identities', true)
+            . " (`changed`, " . implode(', ', $insert_cols) . ")"
+            . " VALUES (" . $this->db->now() . ", " . implode(', ', array_pad([], count($insert_values), '?')) . ")";
 
         $insert = $this->db->query($sql, $insert_values);
 
         // clear the cache
-        $this->identities = array();
+        $this->identities = [];
         $this->emails     = null;
 
         return $this->db->affected_rows($insert) ? $this->db->insert_id('identities') : false;
@@ -430,7 +435,7 @@ class rcube_user
      *
      * @param int $iid Identity ID
      *
-     * @return boolean True if deleted successfully, false if nothing changed
+     * @return bool True if deleted successfully, false if nothing changed
      */
     function delete_identity($iid)
     {
@@ -439,9 +444,10 @@ class rcube_user
         }
 
         $sql_result = $this->db->query(
-            "SELECT count(*) AS ident_count FROM ".$this->db->table_name('identities', true).
-            " WHERE `user_id` = ? AND `del` <> 1",
-            $this->ID);
+            "SELECT count(*) AS ident_count FROM " . $this->db->table_name('identities', true)
+            . " WHERE `user_id` = ? AND `del` <> 1",
+            $this->ID
+        );
 
         $sql_arr = $this->db->fetch_assoc($sql_result);
 
@@ -451,15 +457,15 @@ class rcube_user
         }
 
         $this->db->query(
-            "UPDATE ".$this->db->table_name('identities', true).
-            " SET `del` = 1, `changed` = ".$this->db->now().
-            " WHERE `user_id` = ?".
-                " AND `identity_id` = ?",
+            "UPDATE " . $this->db->table_name('identities', true)
+            . " SET `del` = 1, `changed` = " . $this->db->now()
+            . " WHERE `user_id` = ? AND `identity_id` = ?",
             $this->ID,
-            $iid);
+            $iid
+        );
 
         // clear the cache
-        $this->identities = array();
+        $this->identities = [];
         $this->emails     = null;
 
         return $this->db->affected_rows() > 0;
@@ -474,13 +480,22 @@ class rcube_user
     {
         if ($this->ID && $iid) {
             $this->db->query(
-                "UPDATE ".$this->db->table_name('identities', true).
-                " SET `standard` = '0'".
-                " WHERE `user_id` = ? AND `identity_id` <> ?",
+                "UPDATE " . $this->db->table_name('identities', true)
+                . " SET `standard` = '0'"
+                . " WHERE `user_id` = ? AND `identity_id` <> ?",
                 $this->ID,
-                $iid);
+                $iid
+            );
 
-            unset($this->identities[0]);
+            $this->db->query(
+                "UPDATE " . $this->db->table_name('identities', true)
+                . " SET `standard` = '1'"
+                . " WHERE `user_id` = ? AND `identity_id` = ?",
+                $this->ID,
+                $iid
+            );
+
+            $this->identities = [];
         }
     }
 
@@ -491,10 +506,11 @@ class rcube_user
     {
         if ($this->ID) {
             $this->db->query(
-                "UPDATE ".$this->db->table_name('users', true).
-                " SET `last_login` = ".$this->db->now().
-                " WHERE `user_id` = ?",
-                $this->ID);
+                "UPDATE " . $this->db->table_name('users', true)
+                . " SET `last_login` = " . $this->db->now()
+                . " WHERE `user_id` = ?",
+                $this->ID
+            );
         }
     }
 
@@ -525,7 +541,8 @@ class rcube_user
                     . " SET `failed_login` = ?"
                     . ", `failed_login_counter` = " . ($counter ?: "`failed_login_counter` + 1")
                 . " WHERE `user_id` = ?",
-                $failed_login, $this->ID);
+                $failed_login, $this->ID
+            );
         }
     }
 
@@ -581,9 +598,11 @@ class rcube_user
         // username not found, try aliases from identities
         if (empty($sql_arr) && $config->get('user_aliases') && strpos($user, '@')) {
             $sql_result = $dbh->limitquery("SELECT u.*"
-                ." FROM " . $dbh->table_name('users', true) . " u"
-                ." JOIN " . $dbh->table_name('identities', true) . " i ON (i.`user_id` = u.`user_id`)"
-                ." WHERE `email` = ? AND `del` <> 1", 0, 1, $user);
+                . " FROM " . $dbh->table_name('users', true) . " u"
+                . " JOIN " . $dbh->table_name('identities', true) . " i ON (i.`user_id` = u.`user_id`)"
+                . " WHERE `email` = ? AND `del` <> 1",
+                0, 1, $user
+            );
 
             $sql_arr = $dbh->fetch_assoc($sql_result);
         }
@@ -614,15 +633,15 @@ class rcube_user
             $user_email = is_array($email_list[0]) ? $email_list[0]['email'] : $email_list[0];
         }
 
-        $data = $rcube->plugins->exec_hook('user_create', array(
-            'host'       => $host,
-            'user'       => $user,
-            'user_name'  => $user_name,
-            'user_email' => $user_email,
-            'email_list' => $email_list,
-            'language'   =>  $_SESSION['language'],
-            'preferences'   => array(),
-        ));
+        $data = $rcube->plugins->exec_hook('user_create', [
+                'host'        => $host,
+                'user'        => $user,
+                'user_name'   => $user_name,
+                'user_email'  => $user_email,
+                'email_list'  => $email_list,
+                'language'    => isset($_SESSION['language']) ? $_SESSION['language'] : null,
+                'preferences' => [],
+        ]);
 
         // plugin aborted this operation
         if ($data['abort']) {
@@ -630,23 +649,24 @@ class rcube_user
         }
 
         $insert = $dbh->query(
-            "INSERT INTO ".$dbh->table_name('users', true).
-            " (`created`, `last_login`, `username`, `mail_host`, `language`, `preferences`)".
-            " VALUES (".$dbh->now().", ".$dbh->now().", ?, ?, ?, ?)",
+            "INSERT INTO " . $dbh->table_name('users', true)
+            . " (`created`, `last_login`, `username`, `mail_host`, `language`, `preferences`)"
+            . " VALUES (" . $dbh->now() . ", " . $dbh->now() . ", ?, ?, ?, ?)",
             $data['user'],
             $data['host'],
             $data['language'],
-            serialize($data['preferences']));
-        
+            serialize($data['preferences'])
+        );
+
         if ($dbh->affected_rows($insert) && ($user_id = $dbh->insert_id('users'))) {
             // create rcube_user instance to make plugin hooks work
-            $user_instance = new rcube_user($user_id, array(
-                'user_id'   => $user_id,
-                'username'  => $data['user'],
-                'mail_host' => $data['host'],
-                'language'  => $data['language'],
-                'preferences'  => serialize($data['preferences'])
-            ));
+            $user_instance = new rcube_user($user_id, [
+                    'user_id'     => $user_id,
+                    'username'    => $data['user'],
+                    'mail_host'   => $data['host'],
+                    'language'    => $data['language'],
+                    'preferences' => serialize($data['preferences']),
+            ]);
             $rcube->user = $user_instance;
             $mail_domain = $rcube->config->mail_domain($data['host']);
             $user_name   = $data['user_name'];
@@ -661,7 +681,7 @@ class rcube_user
             }
             // identities_level check
             else if (count($email_list) > 1 && $rcube->config->get('identities_level', 0) > 1) {
-                $email_list = array($email_list[0]);
+                $email_list = [$email_list[0]];
             }
 
             if (empty($user_name)) {
@@ -671,7 +691,7 @@ class rcube_user
             // create new identities records
             $standard = 1;
             foreach ($email_list as $row) {
-                $record = array();
+                $record = [];
 
                 if (is_array($row)) {
                     if (empty($row['email'])) {
@@ -691,21 +711,22 @@ class rcube_user
                 $record['standard'] = $standard;
 
                 $plugin = $rcube->plugins->exec_hook('identity_create',
-                    array('login' => true, 'record' => $record));
+                    ['login' => true, 'record' => $record]);
 
                 if (!$plugin['abort'] && $plugin['record']['email']) {
                     $rcube->user->insert_identity($plugin['record']);
                 }
+
                 $standard = 0;
             }
         }
         else {
-            rcube::raise_error(array(
-                'code' => 500,
-                'type' => 'php',
-                'line' => __LINE__,
-                'file' => __FILE__,
-                'message' => "Failed to create new user"), true, false);
+            rcube::raise_error([
+                    'code' => 500, 'line' => __LINE__, 'file' => __FILE__,
+                    'message' => "Failed to create new user"
+                ],
+                true, false
+            );
         }
 
         return !empty($user_instance) ? $user_instance : null;
@@ -720,9 +741,8 @@ class rcube_user
      */
     static function email2user($email)
     {
-        $rcube = rcube::get_instance();
-        $plugin = $rcube->plugins->exec_hook('email2user',
-            array('email' => $email, 'user' => null));
+        $rcube  = rcube::get_instance();
+        $plugin = $rcube->plugins->exec_hook('email2user', ['email' => $email, 'user' => null]);
 
         return $plugin['user'];
     }
@@ -730,18 +750,21 @@ class rcube_user
     /**
      * Resolve e-mail address from virtuser plugins
      *
-     * @param string  $user     User name
-     * @param boolean $first    If true returns first found entry
-     * @param boolean $extended If true returns email as array (email and name for identity)
+     * @param string $user     User name
+     * @param bool   $first    If true returns first found entry
+     * @param bool   $extended If true returns email as array (email and name for identity)
      *
      * @return mixed Resolved e-mail address string or array of strings
      */
-    static function user2email($user, $first=true, $extended=false)
+    static function user2email($user, $first = true, $extended = false)
     {
-        $rcube = rcube::get_instance();
-        $plugin = $rcube->plugins->exec_hook('user2email',
-            array('email' => null, 'user' => $user,
-                'first' => $first, 'extended' => $extended));
+        $rcube  = rcube::get_instance();
+        $plugin = $rcube->plugins->exec_hook('user2email', [
+                'email'    => null,
+                'user'     => $user,
+                'first'    => $first,
+                'extended' => $extended
+        ]);
 
         return empty($plugin['email']) ? null : $plugin['email'];
     }
@@ -755,20 +778,21 @@ class rcube_user
      */
     function list_searches($type)
     {
-        $plugin = $this->rc->plugins->exec_hook('saved_search_list', array('type' => $type));
+        $plugin = $this->rc->plugins->exec_hook('saved_search_list', ['type' => $type]);
 
         if ($plugin['abort']) {
             return (array) $plugin['result'];
         }
 
-        $result = array();
+        $result = [];
 
         $sql_result = $this->db->query(
             "SELECT `search_id` AS id, `name`"
-            ." FROM ".$this->db->table_name('searches', true)
-            ." WHERE `user_id` = ? AND `type` = ?"
-            ." ORDER BY `name`",
-            (int) $this->ID, (int) $type);
+            . " FROM " . $this->db->table_name('searches', true)
+            . " WHERE `user_id` = ? AND `type` = ?"
+            . " ORDER BY `name`",
+            (int) $this->ID, (int) $type
+        );
 
         while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
             $sql_arr['data'] = unserialize($sql_arr['data']);
@@ -787,27 +811,29 @@ class rcube_user
      */
     function get_search($id)
     {
-        $plugin = $this->rc->plugins->exec_hook('saved_search_get', array('id' => $id));
+        $plugin = $this->rc->plugins->exec_hook('saved_search_get', ['id' => $id]);
 
         if ($plugin['abort']) {
-            return $plugin['result'];
+            return (array) $plugin['result'];
         }
 
         $sql_result = $this->db->query(
             "SELECT `name`, `data`, `type`"
             . " FROM ".$this->db->table_name('searches', true)
-            . " WHERE `user_id` = ?"
-                ." AND `search_id` = ?",
-            (int) $this->ID, (int) $id);
+            . " WHERE `user_id` = ? AND `search_id` = ?",
+            (int) $this->ID, (int) $id
+        );
 
         while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
-            return array(
+            return [
                 'id'   => $id,
                 'name' => $sql_arr['name'],
                 'type' => $sql_arr['type'],
                 'data' => unserialize($sql_arr['data']),
-            );
+            ];
         }
+
+        return [];
     }
 
     /**
@@ -815,7 +841,7 @@ class rcube_user
      *
      * @param int $sid Search ID
      *
-     * @return boolean True if deleted successfully, false if nothing changed
+     * @return bool True if deleted successfully, false if nothing changed
      */
     function delete_search($sid)
     {
@@ -824,10 +850,10 @@ class rcube_user
         }
 
         $this->db->query(
-            "DELETE FROM ".$this->db->table_name('searches', true)
-            ." WHERE `user_id` = ?"
-                ." AND `search_id` = ?",
-            (int) $this->ID, $sid);
+            "DELETE FROM " . $this->db->table_name('searches', true)
+            ." WHERE `user_id` = ? AND `search_id` = ?",
+            (int) $this->ID, $sid
+        );
 
         return $this->db->affected_rows() > 0;
     }
@@ -854,9 +880,9 @@ class rcube_user
         $insert_cols[]   = $this->db->quote_identifier('data');
         $insert_values[] = serialize($data['data']);
 
-        $sql = "INSERT INTO ".$this->db->table_name('searches', true)
-            ." (".implode(', ', $insert_cols).")"
-            ." VALUES (".implode(', ', array_pad(array(), count($insert_values), '?')).")";
+        $sql = "INSERT INTO " . $this->db->table_name('searches', true)
+            . " (" . implode(', ', $insert_cols) . ")"
+            . " VALUES (" . implode(', ', array_pad([], count($insert_values), '?')) . ")";
 
         $insert = $this->db->query($sql, $insert_values);
 
diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index e3d3f8b50..3c12b05df 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -161,7 +161,7 @@ class rcube_utils
 
             // Check DNS record(s)
             // Note: We can't use ANY (#6581)
-            foreach (array('A', 'MX', 'CNAME', 'AAAA') as $type) {
+            foreach (['A', 'MX', 'CNAME', 'AAAA'] as $type) {
                 if (checkdnsrr($domain_part, $type)) {
                     return true;
                 }
@@ -233,7 +233,7 @@ class rcube_utils
 
         // if the replace tables for XML and JS are not yet defined
         if ($js_rep_table === false) {
-            $js_rep_table = $xml_rep_table = array();
+            $js_rep_table = $xml_rep_table = [];
             $xml_rep_table['&'] = '&';
 
             // can be increased to support more charsets
@@ -252,7 +252,7 @@ class rcube_utils
 
         // encode for javascript use
         if ($enctype == 'js') {
-            return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), strtr($str, $js_rep_table));
+            return preg_replace(["/\r?\n/", "/\r/", '/<\\//'], ['\n', '\n', '<\\/'], strtr($str, $js_rep_table));
         }
 
         // encode for plaintext
@@ -360,7 +360,7 @@ class rcube_utils
      */
     public static function request2param($mode = null, $ignore = 'task|action', $allow_html = false)
     {
-        $out = array();
+        $out = [];
         $src = $mode == self::INPUT_GET ? $_GET : ($mode == self::INPUT_POST ? $_POST : $_REQUEST);
 
         foreach (array_keys($src) as $key) {
@@ -452,7 +452,7 @@ class rcube_utils
                     }
                     // allow strict url() values only
                     else if (stripos($stripped, 'url(') && !preg_match($strict_url_regexp, $line)) {
-                        $a_styles = array('/* evil! */');
+                        $a_styles = ['/* evil! */'];
                         break;
                     }
                 }
@@ -483,7 +483,7 @@ class rcube_utils
                 }
 
                 if ($prefix) {
-                    $replace = str_replace(array('.', '#'), array(".$prefix", "#$prefix"), $replace);
+                    $replace = str_replace(['.', '#'], [".$prefix", "#$prefix"], $replace);
                 }
 
                 if ($container_id) {
@@ -524,14 +524,9 @@ class rcube_utils
         $mimetype = strtolower($mimetype);
         $filename = strtolower($filename);
 
-        if (strpos($mimetype, '/')) {
-            list($primary, $secondary) = explode('/', $mimetype);
-        }
-        else {
-            $primary = $mimetype;
-        }
+        list($primary, $secondary) = rcube_utils::explode('/', $mimetype);
 
-        $classes = array($primary ?: 'unknown');
+        $classes = [$primary ?: 'unknown'];
 
         if (!empty($secondary)) {
             $classes[] = $secondary;
@@ -571,7 +566,7 @@ class rcube_utils
     /**
      * Check if we can process not exceeding memory_limit
      *
-     * @param integer $need Required amount of memory
+     * @param int $need Required amount of memory
      *
      * @return bool True if memory won't be exceeded, False otherwise
      */
@@ -599,12 +594,12 @@ class rcube_utils
 
         if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])
             && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'
-            && in_array($_SERVER['REMOTE_ADDR'], rcube::get_instance()->config->get('proxy_whitelist', array()))
+            && in_array($_SERVER['REMOTE_ADDR'], (array) rcube::get_instance()->config->get('proxy_whitelist', []))
         ) {
             return true;
         }
 
-        if ($port && $_SERVER['SERVER_PORT'] == $port) {
+        if ($port && isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == $port) {
             return true;
         }
 
@@ -653,7 +648,7 @@ class rcube_utils
             $s = $s[2];
         }
 
-        return str_replace(array('%n', '%t', '%d', '%h', '%z', '%s'), array($n, $t, $d, $h, $z, $s), $name);
+        return str_replace(['%n', '%t', '%d', '%h', '%z', '%s'], [$n, $t, $d, $h, $z, $s], $name);
     }
 
     /**
@@ -691,8 +686,12 @@ class rcube_utils
                 }
             }
 
-            $rcube->raise_error(array('file' => __FILE__, 'line' => __LINE__,
-                'message' => "Specified host is not trusted. Using 'localhost'."), true, false);
+            $rcube->raise_error([
+                    'file' => __FILE__, 'line' => __LINE__,
+                    'message' => "Specified host is not trusted. Using 'localhost'."
+                ]
+                , true, false
+            );
         }
 
         return 'localhost';
@@ -733,7 +732,7 @@ class rcube_utils
     {
         // Check if any of the headers are set first to improve performance
         if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']) || !empty($_SERVER['HTTP_X_REAL_IP'])) {
-            $proxy_whitelist = rcube::get_instance()->config->get('proxy_whitelist', array());
+            $proxy_whitelist = (array) rcube::get_instance()->config->get('proxy_whitelist', []);
             if (in_array($_SERVER['REMOTE_ADDR'], $proxy_whitelist)) {
                 if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                     foreach (array_reverse(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])) as $forwarded_ip) {
@@ -792,7 +791,7 @@ class rcube_utils
      */
     public static function explode_quoted_string($delimiter, $string)
     {
-        $result = array();
+        $result = [];
         $strlen = strlen($string);
 
         for ($q=$p=$i=0; $i < $strlen; $i++) {
@@ -908,18 +907,20 @@ class rcube_utils
 
         // Clean malformed data
         $date = preg_replace(
-            array(
+            [
                 '/\(.*\)/',                                 // remove RFC comments
                 '/GMT\s*([+-][0-9]+)/',                     // support non-standard "GMTXXXX" literal
                 '/[^a-z0-9\x20\x09:\/\.+-]/i',              // remove any invalid characters
                 '/\s*(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*/i',   // remove weekday names
-            ),
-            array(
+            ],
+            [
                 '',
                 '\\1',
                 '',
                 '',
-            ), $date);
+            ],
+            $date
+        );
 
         $date = trim($date);
 
@@ -1053,8 +1054,8 @@ class rcube_utils
      */
     public static function tokenize_string($str, $minlen = 2)
     {
-        $expr = array('/[\s;,"\'\/+-]+/ui', '/(\d)[-.\s]+(\d)/u');
-        $repl = array(' ', '\\1\\2');
+        $expr = ['/[\s;,"\'\/+-]+/ui', '/(\d)[-.\s]+(\d)/u'];
+        $repl = [' ', '\\1\\2'];
 
         if ($minlen > 1) {
             $minlen--;
@@ -1096,7 +1097,7 @@ class rcube_utils
             preg_match_all('/./',  'aaaaaaaceeeeiiiinoooooouuuuyy', $values);
 
             $mapping = array_combine($keys[0], $values[0]);
-            $mapping = array_merge($mapping, array('ß' => 'ss', 'ae' => 'a', 'oe' => 'o', 'ue' => 'u'));
+            $mapping = array_merge($mapping, ['ß' => 'ss', 'ae' => 'a', 'oe' => 'o', 'ue' => 'u']);
         }
         else if (rcube_charset::convert(rcube_charset::convert($str, 'UTF-8', 'ISO-8859-2'), 'ISO-8859-2', 'UTF-8') == $str) {
             // ISO-8859-2
@@ -1104,7 +1105,7 @@ class rcube_utils
             preg_match_all('/./',  'aaaaccceeeeiilllnnooorrsssttuuuuzzzy', $values);
 
             $mapping = array_combine($keys[0], $values[0]);
-            $mapping = array_merge($mapping, array('ß' => 'ss', 'ae' => 'a', 'oe' => 'o', 'ue' => 'u'));
+            $mapping = array_merge($mapping, ['ß' => 'ss', 'ae' => 'a', 'oe' => 'o', 'ue' => 'u']);
         }
 
         foreach ($arr as $i => $part) {
@@ -1156,10 +1157,10 @@ class rcube_utils
      *
      * @return array Argument values hash
      */
-    public static function get_opt($aliases = array())
+    public static function get_opt($aliases = [])
     {
-        $args = array();
-        $bool = array();
+        $args = [];
+        $bool = [];
 
         // find boolean (no value) options
         foreach ($aliases as $key => $alias) {
@@ -1190,7 +1191,7 @@ class rcube_utils
                     $value = $_SERVER['argv'][++$i];
                 }
 
-                $args[$key] = is_string($value) ? preg_replace(array('/^["\']/', '/["\']$/'), '', $value) : $value;
+                $args[$key] = is_string($value) ? preg_replace(['/^["\']/', '/["\']$/'], '', $value) : $value;
             }
             else {
                 $args[] = $arg;
@@ -1254,7 +1255,7 @@ class rcube_utils
     {
         $str = strtolower($str);
 
-        return !in_array($str, array('false', '0', 'no', 'off', 'nein', ''), true);
+        return !in_array($str, ['false', '0', 'no', 'off', 'nein', ''], true);
     }
 
     /**
@@ -1444,7 +1445,7 @@ class rcube_utils
      *
      * @return bool True on error, False otherwise
      */
-    public static function preg_error($error = array(), $terminate = false)
+    public static function preg_error($error = [], $terminate = false)
     {
         if (($preg_error = preg_last_error()) != PREG_NO_ERROR) {
             $errstr = "PCRE Error: $preg_error.";
@@ -1456,7 +1457,7 @@ class rcube_utils
                 $errstr .= " Consider raising pcre.recursion_limit!";
             }
 
-            $error = array_merge(array('code' => 620, 'line' => __LINE__, 'file' => __FILE__), $error);
+            $error = array_merge(['code' => 620, 'line' => __LINE__, 'file' => __FILE__], $error);
 
             if (!empty($error['message'])) {
                 $error['message'] .= ' ' . $errstr;
diff --git a/program/lib/Roundcube/rcube_vcard.php b/program/lib/Roundcube/rcube_vcard.php
index 2bf3db3f1..f4f8a6c14 100644
--- a/program/lib/Roundcube/rcube_vcard.php
+++ b/program/lib/Roundcube/rcube_vcard.php
@@ -28,11 +28,11 @@
 class rcube_vcard
 {
     private static $values_decoded = false;
-    private $raw = array(
-        'FN' => array(),
-        'N'  => array(array('','','','','')),
-    );
-    private static $fieldmap = array(
+    private $raw = [
+        'FN' => [],
+        'N'  => [['','','','','']],
+    ];
+    private static $fieldmap = [
         'phone'    => 'TEL',
         'birthday' => 'BDAY',
         'website'  => 'URL',
@@ -49,23 +49,23 @@ class rcube_vcard
         'spouse'      => 'X-SPOUSE',
         'edit'        => 'X-AB-EDIT',
         'groups'      => 'CATEGORIES',
-    );
-    private $typemap = array(
+    ];
+    private $typemap = [
         'IPHONE'   => 'mobile',
         'CELL'     => 'mobile',
         'WORK,FAX' => 'workfax',
-    );
-    private $phonetypemap = array(
+    ];
+    private $phonetypemap = [
         'HOME1'       => 'HOME',
         'BUSINESS1'   => 'WORK',
         'BUSINESS2'   => 'WORK2',
         'BUSINESSFAX' => 'WORK,FAX',
         'MOBILE'      => 'CELL',
-    );
-    private $addresstypemap = array(
+    ];
+    private $addresstypemap = [
         'BUSINESS' => 'WORK',
-    );
-    private $immap = array(
+    ];
+    private $immap = [
         'X-JABBER' => 'jabber',
         'X-ICQ'    => 'icq',
         'X-MSN'    => 'msn',
@@ -73,7 +73,7 @@ class rcube_vcard
         'X-YAHOO'  => 'yahoo',
         'X-SKYPE'  => 'skype',
         'X-SKYPE-USERNAME' => 'skype',
-    );
+    ];
 
     public $business = false;
     public $displayname;
@@ -82,7 +82,7 @@ class rcube_vcard
     public $middlename;
     public $nickname;
     public $organization;
-    public $email = array();
+    public $email = [];
 
     public static $eol = "\r\n";
 
@@ -96,7 +96,7 @@ class rcube_vcard
      *                         for charset detection is required
      * @param array  $fieldmap Fields mapping definition
      */
-    public function __construct($vcard = null, $charset = RCUBE_CHARSET, $detect = false, $fieldmap = array())
+    public function __construct($vcard = null, $charset = RCUBE_CHARSET, $detect = false, $fieldmap = [])
     {
         if (!empty($fieldmap)) {
             $this->extend_fieldmap($fieldmap);
@@ -170,11 +170,11 @@ class rcube_vcard
      */
     public function get_assoc()
     {
-        $out     = array('name' => $this->displayname);
+        $out     = ['name' => $this->displayname];
         $typemap = $this->typemap;
 
         // copy name fields to output array
-        foreach (array('firstname','surname','middlename','nickname','organization') as $col) {
+        foreach (['firstname', 'surname', 'middlename', 'nickname', 'organization'] as $col) {
             if (strlen($this->$col)) {
                 $out[$col] = $this->$col;
             }
@@ -203,7 +203,7 @@ class rcube_vcard
                     if (!empty($raw['type'])) {
                         $raw['type'] = array_map('strtolower', $raw['type']);
 
-                        $combined = implode(',', array_diff($raw['type'], array('internet', 'pref')));
+                        $combined = implode(',', array_diff($raw['type'], ['internet', 'pref']));
                         $combined = strtoupper($combined);
 
                         if (!empty($typemap[$combined])) {
@@ -226,7 +226,7 @@ class rcube_vcard
                     if (!$subtype) {
                         foreach ($raw as $k => $v) {
                             if (!is_numeric($k) && $v === true && ($k = strtolower($k))
-                                && !in_array($k, array('pref','internet','voice','base64'))
+                                && !in_array($k, ['pref', 'internet', 'voice', 'base64'])
                             ) {
                                 $k_uc    = strtoupper($k);
                                 $subtype = $typemap[$k_uc] ?: $k;
@@ -298,10 +298,10 @@ class rcube_vcard
      *
      * @param array List of field names to be reset
      */
-    public function reset($fields = null)
+    public function reset($fields = [])
     {
-        if (!$fields) {
-            $fields = array('FN', 'N', 'ORG', 'NICKNAME', 'EMAIL', 'ADR', 'BDAY');
+        if (empty($fields)) {
+            $fields = ['FN', 'N', 'ORG', 'NICKNAME', 'EMAIL', 'ADR', 'BDAY'];
             $fields = array_merge(array_values(self::$fieldmap), array_keys($this->immap), $fields);
         }
 
@@ -310,14 +310,14 @@ class rcube_vcard
         }
 
         if (empty($this->raw['N'])) {
-            $this->raw['N'] = array(array('','','','',''));
+            $this->raw['N'] = [['','','','','']];
         }
 
         if (empty($this->raw['FN'])) {
-            $this->raw['FN'] = array();
+            $this->raw['FN'] = [];
         }
 
-        $this->email = array();
+        $this->email = [];
     }
 
     /**
@@ -369,15 +369,15 @@ class rcube_vcard
         case 'photo':
             if (strpos($value, 'http:') === 0) {
                 // TODO: fetch file from URL and save it locally?
-                $this->raw['PHOTO'][0] = array(0 => $value, 'url' => true);
+                $this->raw['PHOTO'][0] = [0 => $value, 'url' => true];
             }
             else {
-                $this->raw['PHOTO'][0] = array(0 => $value, 'base64' => (bool) preg_match('![^a-z0-9/=+-]!i', $value));
+                $this->raw['PHOTO'][0] = [0 => $value, 'base64' => (bool) preg_match('![^a-z0-9/=+-]!i', $value)];
             }
             break;
 
         case 'email':
-            $this->raw['EMAIL'][] = array(0 => $value, 'type' => array_filter(array('INTERNET', $type_uc)));
+            $this->raw['EMAIL'][] = [0 => $value, 'type' => array_filter(['INTERNET', $type_uc])];
             $this->email[] = $value;
             break;
 
@@ -386,7 +386,7 @@ class rcube_vcard
             $typemap = array_flip($this->immap);
             if (!empty($typemap[strtolower($type)])) {
                 $field = $typemap[strtolower($type)];
-                $this->raw[$field][] = array(0 => $value);
+                $this->raw[$field][] = [$value];
             }
             break;
 
@@ -394,7 +394,7 @@ class rcube_vcard
         case 'anniversary':
             if (($val = rcube_utils::anytodatetime($value)) && !empty(self::$fieldmap[$field])) {
                 $fn = self::$fieldmap[$field];
-                $this->raw[$fn][] = array(0 => $val->format('Y-m-d'), 'value' => array('date'));
+                $this->raw[$fn][] = [0 => $val->format('Y-m-d'), 'value' => ['date']];
             }
             break;
 
@@ -533,7 +533,7 @@ class rcube_vcard
      */
     public static function import($data)
     {
-        $out = array();
+        $out = [];
 
         // check if charsets are specified (usually vcard version < 3.0 but this is not reliable)
         if (preg_match('/charset=/i', substr($data, 0, 2048))) {
@@ -542,7 +542,7 @@ class rcube_vcard
         // detect charset and convert to utf-8
         else if (($charset = self::detect_encoding($data)) && $charset != RCUBE_CHARSET) {
             $data = rcube_charset::convert($data, $charset);
-            $data = preg_replace(array('/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'), '', $data); // also remove BOM
+            $data = preg_replace(['/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'], '', $data); // also remove BOM
             $charset = RCUBE_CHARSET;
         }
 
@@ -588,25 +588,28 @@ class rcube_vcard
         // convert Apple X-ABRELATEDNAMES into X-* fields for better compatibility
         $vcard = preg_replace_callback(
             '/item(\d+)\.(X-ABRELATEDNAMES)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w() -]*)(?:>!\$_)?./s',
-            array('rcube_vcard', 'x_abrelatednames_callback'),
+            ['rcube_vcard', 'x_abrelatednames_callback'],
             $vcard);
 
         // Cleanup
-        $vcard = preg_replace(array(
+        $vcard = preg_replace(
+            [
                 // convert special types (like Skype) to normal type='skype' classes with this simple regex ;)
                 '/item(\d+)\.(TEL|EMAIL|URL)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w() -]*)(?:>!\$_)?./si',
                 '/^item\d*\.X-AB.*$/mi',  // remove cruft like item1.X-AB*
                 '/^item\d*\./mi',         // remove item1.ADR instead of ADR
                 '/\n+/',                  // remove empty lines
                 '/^(N:[^;\r\n]*)$/m',     // if N doesn't have any semicolons, add some
-            ),
-            array(
+            ],
+            [
                 '\2;type=\5\3:\4',
                 '',
                 '',
                 "\n",
                 '\1;;;;',
-            ), $vcard);
+            ],
+            $vcard
+        );
 
         // convert X-WAB-GENDER to X-GENDER
         if (preg_match('/X-WAB-GENDER:(\d)/', $vcard, $matches)) {
@@ -665,7 +668,7 @@ class rcube_vcard
      */
     public static function rfc2425_fold($val)
     {
-        return preg_replace_callback('/([^\n]{72,})/', array('rcube_vcard', 'rfc2425_fold_callback'), $val);
+        return preg_replace_callback('/([^\n]{72,})/', ['rcube_vcard', 'rfc2425_fold_callback'], $val);
     }
 
     /**
@@ -678,9 +681,9 @@ class rcube_vcard
     private static function vcard_decode($vcard)
     {
         // Perform RFC2425 line unfolding and split lines
-        $vcard  = preg_replace(array("/\r/", "/\n\s+/"), '', $vcard);
+        $vcard  = preg_replace(["/\r/", "/\n\s+/"], '', $vcard);
         $lines  = explode("\n", $vcard);
-        $result = array();
+        $result = [];
 
         for ($i=0; $i < count($lines); $i++) {
             if (!($pos = strpos($lines[$i], ':'))) {
@@ -708,7 +711,7 @@ class rcube_vcard
             }
 
             if (preg_match_all('/([^\\;]+);?/', $prefix, $regs2)) {
-                $entry = array();
+                $entry = [];
                 $field = strtoupper($regs2[1][0]);
                 $enc   = null;
 
@@ -829,7 +832,7 @@ class rcube_vcard
             foreach ((array)$entries as $entry) {
                 $attr = '';
                 if (is_array($entry)) {
-                    $value = array();
+                    $value = [];
                     foreach ($entry as $attrname => $attrvalues) {
                         if (is_int($attrname)) {
                             if (!empty($entry['base64']) || (!empty($entry['encoding']) && $entry['encoding'] == 'B')) {
@@ -883,7 +886,7 @@ class rcube_vcard
     public static function vcard_quote($str, $sep = ';')
     {
         if (is_array($str)) {
-            $r = array();
+            $r = [];
 
             foreach ($str as $part) {
                 $r[] = self::vcard_quote($part, $sep);
@@ -892,7 +895,7 @@ class rcube_vcard
             return(implode($sep, $r));
         }
 
-        return strtr($str, array("\\" => "\\\\", "\r" => '', "\n" => '\n', $sep => "\\$sep"));
+        return strtr($str, ["\\" => "\\\\", "\r" => '', "\n" => '\n', $sep => "\\$sep"]);
     }
 
     /**
@@ -908,11 +911,11 @@ class rcube_vcard
         // break string into parts separated by $sep
         if (!empty($sep)) {
             // Handle properly backslash escaping (#1488896)
-            $rep1 = array("\\\\" => "\010", "\\$sep" => "\007");
-            $rep2 = array("\007" => "\\$sep", "\010" => "\\\\");
+            $rep1 = ["\\\\" => "\010", "\\$sep" => "\007"];
+            $rep2 = ["\007" => "\\$sep", "\010" => "\\\\"];
 
             if (count($parts = explode($sep, strtr($str, $rep1))) > 1) {
-                $result = array();
+                $result = [];
                 foreach ($parts as $s) {
                     $result[] = self::vcard_unquote(strtr($s, $rep2));
                 }
@@ -925,7 +928,7 @@ class rcube_vcard
 
         // some implementations (GMail) use non-standard backslash before colon (#1489085)
         // we will handle properly any backslashed character - removing dummy backslahes
-        // return strtr($str, array("\r" => '', '\\\\' => '\\', '\n' => "\n", '\N' => "\n", '\,' => ',', '\;' => ';'));
+        // return strtr($str, ["\r" => '', '\\\\' => '\\', '\n' => "\n", '\N' => "\n", '\,' => ',', '\;' => ';']);
 
         $str = str_replace("\r", '', $str);
         $pos = 0;
diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php
index 53bf12a2b..b22c9b9a4 100644
--- a/program/lib/Roundcube/rcube_washtml.php
+++ b/program/lib/Roundcube/rcube_washtml.php
@@ -55,7 +55,7 @@ class rcube_washtml
     /**
      * @var array Allowed HTML elements (default)
      */
-    static $html_elements = array('a', 'abbr', 'acronym', 'address', 'area', 'b',
+    static $html_elements = ['a', 'abbr', 'acronym', 'address', 'area', 'b',
         'basefont', 'bdo', 'big', 'blockquote', 'br', 'caption', 'center',
         'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dir', 'div', 'dl',
         'dt', 'em', 'fieldset', 'font', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i',
@@ -87,17 +87,17 @@ class rcube_washtml
         'infinity', 'matrix', 'matrixrow', 'ci', 'cn', 'sep', 'apply',
         'plus', 'minus', 'eq', 'power', 'times', 'divide', 'csymbol', 'root',
         'bvar', 'lowlimit', 'uplimit',
-    );
+    ];
 
     /**
      * @var array Ignore these HTML tags and their content
      */
-    static $ignore_elements = array('script', 'applet', 'embed', 'style');
+    static $ignore_elements = ['script', 'applet', 'embed', 'style'];
 
     /**
      * @var array Allowed HTML attributes
      */
-    static $html_attribs = array('name', 'class', 'title', 'alt', 'width', 'height',
+    static $html_attribs = ['name', 'class', 'title', 'alt', 'width', 'height',
         'align', 'nowrap', 'col', 'row', 'id', 'rowspan', 'colspan', 'cellspacing',
         'cellpadding', 'valign', 'bgcolor', 'color', 'border', 'bordercolorlight',
         'bordercolordark', 'face', 'marginwidth', 'marginheight', 'axis', 'border',
@@ -143,43 +143,43 @@ class rcube_washtml
         'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator',
         'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset',
         'fontsize', 'fontweight', 'fontstyle', 'fontfamily', 'groupalign', 'edge', 'side',
-    );
+    ];
 
     /**
      * @var array Elements which could be empty and be returned in short form ()
      */
-    static $void_elements = array('area', 'base', 'br', 'col', 'command', 'embed', 'hr',
+    static $void_elements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr',
         'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr',
         // MathML
         'sep', 'infinity', 'in', 'plus', 'eq', 'power', 'times', 'divide', 'root',
         'maligngroup', 'none', 'mprescripts',
-    );
+    ];
 
     /**
      * @var array Additional allowed attributes of body element
      */
-    static $body_attribs = array('alink', 'background', 'bgcolor', 'link', 'text', 'vlink');
+    static $body_attribs = ['alink', 'background', 'bgcolor', 'link', 'text', 'vlink'];
 
     /** @var bool State indicating existence of linked objects in HTML */
     public $extlinks = false;
 
     /** @var array Current settings */
-    private $config = array();
+    private $config = [];
 
     /** @var array Registered callback functions for tags */
-    private $handlers = array();
+    private $handlers = [];
 
     /** @var array Allowed HTML elements */
-    private $_html_elements = array();
+    private $_html_elements = [];
 
     /** @var array Ignore these HTML tags but process their content */
-    private $_ignore_elements = array();
+    private $_ignore_elements = [];
 
     /** @var array Elements which could be empty and be returned in short form () */
-    private $_void_elements = array();
+    private $_void_elements = [];
 
     /** @var array Allowed HTML attributes */
-    private $_html_attribs = array();
+    private $_html_attribs = [];
 
     /** @var string A prefix to be added to id/class/for attribute values */
     private $_css_prefix;
@@ -210,7 +210,7 @@ class rcube_washtml
      *         html_attribs: Additional allowed HTML attributes
      *         void_elements: Elements which could be empty and be returned in short form ()
      */
-    public function __construct($p = array())
+    public function __construct($p = [])
     {
         $p['html_elements']   = isset($p['html_elements']) ? (array) $p['html_elements'] : [];
         $p['html_attribs']    = isset($p['html_attribs']) ? (array) $p['html_attribs'] : [];
@@ -252,7 +252,7 @@ class rcube_washtml
      */
     private function wash_style($style)
     {
-        $result = array();
+        $result = [];
 
         // Remove unwanted white-space characters so regular expressions below work better
         $style = preg_replace('/[\n\r\s\t]+/', ' ', $style);
@@ -311,8 +311,8 @@ class rcube_washtml
     private function wash_attribs($node)
     {
         $result = '';
-        $washed = array();
-        $additional_attribs = array();
+        $washed = [];
+        $additional_attribs = [];
 
         if ($node->nodeName == 'body') {
             $additional_attribs = self::$body_attribs;
@@ -362,7 +362,7 @@ class rcube_washtml
                         $out = $value;
                     }
                 }
-                else if ($this->_css_prefix !== null && in_array($key, array('id', 'class', 'for'))) {
+                else if ($this->_css_prefix !== null && in_array($key, ['id', 'class', 'for'])) {
                     $out = preg_replace('/(\S+)/', $this->_css_prefix . '\1', $value);
                 }
                 else if ($key) {
@@ -409,7 +409,7 @@ class rcube_washtml
         }
 
         // allow url(#id) used in SVG
-        if ($uri[0] == '#') {
+        if (isset($uri[0]) && $uri[0] == '#') {
             if ($this->_css_prefix !== null) {
                 $uri = '#' . $this->_css_prefix . substr($uri, 1);
             }
@@ -520,8 +520,8 @@ class rcube_washtml
      */
     private function is_funciri_attribute($tag, $attr)
     {
-        return in_array($attr, array('fill', 'filter', 'stroke', 'marker-start',
-            'marker-end', 'marker-mid', 'clip-path', 'mask', 'cursor'));
+        return in_array($attr, ['fill', 'filter', 'stroke', 'marker-start',
+            'marker-end', 'marker-mid', 'clip-path', 'mask', 'cursor']);
     }
 
     /**
@@ -570,10 +570,12 @@ class rcube_washtml
             // log error message once
             if (empty($this->max_nesting_level_error)) {
                 $this->max_nesting_level_error = true;
-                rcube::raise_error(array('code' => 500, 'type' => 'php',
-                    'line' => __LINE__, 'file' => __FILE__,
-                    'message' => "Maximum nesting level exceeded (xdebug.max_nesting_level={$this->max_nesting_level})"),
-                    true, false);
+                rcube::raise_error([
+                        'code' => 500, 'line' => __LINE__, 'file' => __FILE__,
+                        'message' => "Maximum nesting level exceeded (xdebug.max_nesting_level={$this->max_nesting_level})"
+                    ],
+                    true, false
+                );
             }
 
             return '';
@@ -596,7 +598,7 @@ class rcube_washtml
 
                     $node->setAttribute('href', (string) $uri);
                 }
-                else if (in_array($tagName, array('animate', 'animatecolor', 'set', 'animatetransform'))
+                else if (in_array($tagName, ['animate', 'animatecolor', 'set', 'animatetransform'])
                     && self::attribute_value($node, 'attributename', 'href')
                 ) {
                     // Insecure svg tags
@@ -738,7 +740,7 @@ class rcube_washtml
         $html = trim($html);
 
         // special replacements (not properly handled by washtml class)
-        $html_search = array(
+        $html_search = [
             // space(s) between 
             '/(<\/nobr>)(\s+)()/i',
             // PHP bug #32547 workaround: remove title tag
@@ -752,42 +754,42 @@ class rcube_washtml
             // washtml/DOMDocument cannot handle xml namespaces
             // HTML5 parser cannot handler ]*>/i',
-        );
+        ];
 
-        $html_replace = array(
+        $html_replace = [
             '\\1'.'   '.'\\3',
             '',
             '',
             '',
             '',
             '',
-        );
+        ];
 
         $html = preg_replace($html_search, $html_replace, $html);
 
-        $err = array('line' => __LINE__, 'file' => __FILE__, 'message' => "Could not clean up HTML!");
+        $err = ['line' => __LINE__, 'file' => __FILE__, 'message' => "Could not clean up HTML!"];
         if ($html === null && rcube_utils::preg_error($err)) {
             return '';
         }
 
         // Replace all of those weird MS Word quotes and other high characters
-        $badwordchars = array(
+        $badwordchars = [
             "\xe2\x80\x98", // left single quote
             "\xe2\x80\x99", // right single quote
             "\xe2\x80\x9c", // left double quote
             "\xe2\x80\x9d", // right double quote
             "\xe2\x80\x94", // em dash
             "\xe2\x80\xa6"  // elipses
-        );
+        ];
 
-        $fixedwordchars = array(
+        $fixedwordchars = [
             "'",
             "'",
             '"',
             '"',
             '—',
             '...'
-        );
+        ];
 
         $html = str_replace($badwordchars, $fixedwordchars, $html);
 
@@ -795,7 +797,7 @@ class rcube_washtml
         //        we should probably do not modify content inside comments at all.
 
         // fix (unknown/malformed) HTML tags before "wash"
-        $html = preg_replace_callback('/(<(?!\!)[\/]*)([^\s>]+)([^>]*)/', array($this, 'html_tag_callback'), $html);
+        $html = preg_replace_callback('/(<(?!\!)[\/]*)([^\s>]+)([^>]*)/', [$this, 'html_tag_callback'], $html);
 
         // Remove invalid HTML comments (#1487759)
         // Note: We don't want to remove valid comments, conditional comments
@@ -827,10 +829,11 @@ class rcube_washtml
         }
 
         $tagname = $matches[2];
-        $tagname = preg_replace(array(
-            '/:.*$/',                // Microsoft's Smart Tags 
-            '/[^a-z0-9_\[\]\!?-]/i', // forbidden characters
-        ), '', $tagname);
+        $tagname = preg_replace([
+                '/:.*$/',                // Microsoft's Smart Tags 
+                '/[^a-z0-9_\[\]\!?-]/i', // forbidden characters
+            ], '', $tagname
+        );
 
         // fix invalid closing tags - remove any attributes (#1489446)
         if ($matches[1] == ', one for