diff --git a/phpstan.neon b/phpstan.neon index aecda91a..1a5b7695 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -15,8 +15,6 @@ parameters: - '#Access to an undefined property (calendar|tasklist)::\$itip#' - '#Access to an undefined property (calendar|tasklist)::\$ical#' - '#unknown class (kolabformat|Address|Alarm|Contact|ContactReference|Configuration|Email|RecurrenceRule|Key|Related|Url|Snippet|Telephone)#' - - '#Call to an undefined static method PEAR::raiseError#' - #- '#Class .* constructor invoked with 0 parameters#' - '#class (Address|Affiliation|Alarm|Attachment|Attendee|Duration|ContactReference|Configuration|Dictionary|Email|EmailReference|DayPos|FileDriver|Key|NameComponents|SnippetCollection|RecurrenceRule|Related|Relation|EventCal|Snippet|Telephone|Url|vector.*|cDatetime|XMLObject|CustomProperty) not found#i' - '#Call to method .* on an unknown class (Affiliation|Attachment|Attendee|cDateTime|Dictionary|EventCal|FileDriver|NameComponents|Relation|snippet|vector.*)#' - '#Call to static method .* on an unknown class jqueryui#' @@ -29,7 +27,7 @@ parameters: paths: - plugins - level: 3 + level: 4 scanDirectories: - program/include diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 1fff88f8..099e3267 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -1036,7 +1036,7 @@ $("#rcmfd_new_category").keypress(function(event) { // let the UI generate HTML and CSS representation for this calendar $html = $this->ui->calendar_list_item($id, $prop, $jsenv); - $cal = $jsenv[$id] ?? []; + $cal = $jsenv[$id] ?? []; // @phpstan-ignore-line $cal['editname'] = $editname; $cal['html'] = $html; @@ -3339,6 +3339,7 @@ $("#rcmfd_new_category").keypress(function(event) { $deleted = false; $dontsave = false; $existing = null; + $event_attendee = null; if ($status == 'delegated') { $to = rcube_utils::get_input_value('_to', rcube_utils::INPUT_POST, true); @@ -3440,7 +3441,7 @@ $("#rcmfd_new_category").keypress(function(event) { $existing = $this->find_event($event, $mode); // we'll create a new copy if user decided to change the calendar - if ($existing && $cal_id && $calendar && $calendar['id'] != $existing['calendar']) { + if ($existing && $cal_id && $calendar['id'] != $existing['calendar']) { $existing = null; } @@ -3449,7 +3450,6 @@ $("#rcmfd_new_category").keypress(function(event) { unset($event['free_busy']); } - $event_attendee = null; $update_attendees = []; if ($existing) { @@ -3569,7 +3569,7 @@ $("#rcmfd_new_category").keypress(function(event) { } else { $error_msg = $this->gettext('newerversionexists'); } - } elseif (!$existing && ($status != 'declined' || $this->rc->config->get('kolab_invitation_calendars'))) { + } elseif (empty($existing) && ($status != 'declined' || $this->rc->config->get('kolab_invitation_calendars'))) { if ($status == 'declined' || ($event['status'] ?? '') == 'CANCELLED' || ($event_attendee && ($event_attendee['role'] ?? '') == 'NON-PARTICIPANT') diff --git a/plugins/calendar/drivers/caldav/caldav_calendar.php b/plugins/calendar/drivers/caldav/caldav_calendar.php index 165fd460..ff19b4fd 100644 --- a/plugins/calendar/drivers/caldav/caldav_calendar.php +++ b/plugins/calendar/drivers/caldav/caldav_calendar.php @@ -549,8 +549,10 @@ class caldav_calendar extends kolab_storage_dav_folder protected function get_links($uid) { return []; // TODO + /* $storage = kolab_storage_config::get_instance(); return $storage->get_object_links($uid); + */ } /** @@ -559,8 +561,10 @@ class caldav_calendar extends kolab_storage_dav_folder protected function save_links($uid, $links) { return false; // TODO + /* $storage = kolab_storage_config::get_instance(); return $storage->save_object_links($uid, (array) $links); + */ } /** diff --git a/plugins/calendar/drivers/caldav/caldav_driver.php b/plugins/calendar/drivers/caldav/caldav_driver.php index 85727b0b..43aa3b59 100644 --- a/plugins/calendar/drivers/caldav/caldav_driver.php +++ b/plugins/calendar/drivers/caldav/caldav_driver.php @@ -121,8 +121,8 @@ class caldav_driver extends kolab_driver /** * Get a list of available calendars from this source. * - * @param int $filter Bitmask defining filter criterias - * @param object $tree Reference to hierarchical folder tree object + * @param int $filter Bitmask defining filter criterias + * @param ?kolab_storage_folder_virtual $tree Reference to hierarchical folder tree object * * @return array List of calendars */ @@ -136,9 +136,9 @@ class caldav_driver extends kolab_driver // include virtual folders for a full folder tree /* - if (!is_null($tree)) { - $folders = $this->storage->folder_hierarchy($folders, $tree); - } + if (!is_null($tree)) { + $folders = $this->storage->folder_hierarchy($folders, $tree); + } */ $parents = array_keys($this->calendars); @@ -189,7 +189,7 @@ class caldav_driver extends kolab_driver 'title' => '', // $cal->get_title(), 'color' => $cal->get_color(), 'editable' => $cal->editable, - 'group' => $is_user ? 'other user' : $cal->get_namespace(), + 'group' => $is_user ? 'other user' : $cal->get_namespace(), // @phpstan-ignore-line 'active' => !isset($prefs[$cal->id]['active']) || !empty($prefs[$cal->id]['active']), 'owner' => $cal->get_owner(), 'removable' => !$cal->default, @@ -198,6 +198,7 @@ class caldav_driver extends kolab_driver 'driver' => 'caldav', ]; + // @phpstan-ignore-next-line if (!$is_user) { $calendars[$cal->id] += [ 'default' => $cal->default, diff --git a/plugins/calendar/drivers/calendar_driver.php b/plugins/calendar/drivers/calendar_driver.php index f493fc41..0b7eea80 100644 --- a/plugins/calendar/drivers/calendar_driver.php +++ b/plugins/calendar/drivers/calendar_driver.php @@ -430,9 +430,9 @@ abstract class calendar_driver /** * Build a struct representing the given message reference * - * @param object|string $uri_or_headers rcube_message_header instance holding the message headers - * or an URI from a stored link referencing a mail message. - * @param string $folder IMAP folder the message resides in + * @param rcube_message_header|string $uri_or_headers An object holding the message headers + * or an URI from a stored link referencing a mail message. + * @param string $folder IMAP folder the message resides in * * @return array|false An struct referencing the given IMAP message */ diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php index d7c45094..e3a72d4e 100644 --- a/plugins/calendar/drivers/kolab/kolab_driver.php +++ b/plugins/calendar/drivers/kolab/kolab_driver.php @@ -137,8 +137,8 @@ class kolab_driver extends calendar_driver /** * Get a list of available calendars from this source * - * @param int $filter Bitmask defining filter criterias - * @param object $tree Reference to hierarchical folder tree object + * @param int $filter Bitmask defining filter criterias + * @param ?kolab_storage_folder_virtual $tree Reference to hierarchical folder tree object * * @return array List of calendars */ @@ -489,16 +489,15 @@ class kolab_driver extends calendar_driver } } } + return $ret; - } else { - // save state in local prefs - $prefs['kolab_calendars'] = $this->rc->config->get('kolab_calendars', []); - $prefs['kolab_calendars'][$prop['id']]['active'] = !empty($prop['active']); - $this->rc->user->save_prefs($prefs); - return true; } - return false; + // save state in local prefs + $prefs['kolab_calendars'] = $this->rc->config->get('kolab_calendars', []); + $prefs['kolab_calendars'][$prop['id']]['active'] = !empty($prop['active']); + $this->rc->user->save_prefs($prefs); + return true; } /** @@ -2035,7 +2034,8 @@ class kolab_driver extends calendar_driver unset($request, $response); } catch (Exception $e) { - PEAR::raiseError("Error fetching free/busy information: " . $e->getMessage()); + rcube::raise_error($e); + return false; } // get free-busy url from contacts @@ -2328,7 +2328,7 @@ class kolab_driver extends calendar_driver $special_changes = []; // map kolab event properties to keys the client expects - array_walk($result['changes'], function (&$change, $i) use ($keymap, $prop_keymaps, $special_changes) { + array_walk($result['changes'], function (&$change, $i) use ($keymap, $prop_keymaps, &$special_changes) { if (array_key_exists($change['property'], $keymap)) { $change['property'] = $keymap[$change['property']]; } diff --git a/plugins/calendar/lib/calendar_ui.php b/plugins/calendar/lib/calendar_ui.php index 68f987a3..476f5572 100644 --- a/plugins/calendar/lib/calendar_ui.php +++ b/plugins/calendar/lib/calendar_ui.php @@ -227,6 +227,7 @@ class calendar_ui $calendars = $this->cal->driver->list_calendars(0, $tree); // walk folder tree + // @phpstan-ignore-next-line if (is_object($tree)) { $html = $this->list_tree_html($tree, $calendars, $jsenv, $attrib); @@ -284,7 +285,7 @@ class calendar_ui if (!empty($folder->children)) { $content .= html::tag( 'ul', - ['style' => $is_collapsed ? "display:none;" : null], + ['style' => $is_collapsed ? "display:none;" : null], // @phpstan-ignore-line $this->list_tree_html($folder, $data, $jsenv, $attrib) ); } diff --git a/plugins/kolab_2fa/lib/Kolab2FA/Storage/LDAP.php b/plugins/kolab_2fa/lib/Kolab2FA/Storage/LDAP.php index dbc09ed9..36727f11 100644 --- a/plugins/kolab_2fa/lib/Kolab2FA/Storage/LDAP.php +++ b/plugins/kolab_2fa/lib/Kolab2FA/Storage/LDAP.php @@ -33,7 +33,6 @@ class LDAP extends Base private $cache = []; private $ldapcache = []; private $conn; - private $error; private $ready = false; @@ -53,7 +52,7 @@ class LDAP extends Base $this->ready = $this->conn->bind($bind_dn, $bind_pass); if (!$this->ready) { - throw new Exception("LDAP storage not ready: " . $this->error); + throw new Exception("LDAP storage not ready"); } } diff --git a/plugins/kolab_addressbook/drivers/carddav/carddav_contacts.php b/plugins/kolab_addressbook/drivers/carddav/carddav_contacts.php index a2dbbad5..879ac859 100644 --- a/plugins/kolab_addressbook/drivers/carddav/carddav_contacts.php +++ b/plugins/kolab_addressbook/drivers/carddav/carddav_contacts.php @@ -87,7 +87,6 @@ class carddav_contacts extends rcube_addressbook private $filter; private $result; private $namespace; - private $action; // list of fields used for searching in "All fields" mode private $search_fields = [ @@ -136,8 +135,6 @@ class carddav_contacts extends rcube_addressbook } } } - - $this->action = rcmail::get_instance()->action; } /** diff --git a/plugins/kolab_chat/drivers/mattermost.php b/plugins/kolab_chat/drivers/mattermost.php index 8bac1f1d..f1a2644b 100644 --- a/plugins/kolab_chat/drivers/mattermost.php +++ b/plugins/kolab_chat/drivers/mattermost.php @@ -65,7 +65,7 @@ class kolab_chat_mattermost $team = $_channel['team_name']; } - if ($channel && $team) { + if ($team) { $url .= '/' . urlencode($team) . '/channels/' . urlencode($channel); } } diff --git a/plugins/kolab_files/kolab_files.php b/plugins/kolab_files/kolab_files.php index c8b32d54..a0edfa74 100644 --- a/plugins/kolab_files/kolab_files.php +++ b/plugins/kolab_files/kolab_files.php @@ -148,7 +148,7 @@ class kolab_files extends rcube_plugin require_once $this->home . '/lib/kolab_files_autocomplete.php'; - new kolab_files_autocomplete($this); + new kolab_files_autocomplete(); } /** diff --git a/plugins/kolab_files/lib/kolab_files_autocomplete.php b/plugins/kolab_files/lib/kolab_files_autocomplete.php index be60d514..55fbb032 100644 --- a/plugins/kolab_files/lib/kolab_files_autocomplete.php +++ b/plugins/kolab_files/lib/kolab_files_autocomplete.php @@ -25,17 +25,15 @@ class kolab_files_autocomplete { private $ldap; - private $plugin; private $rc; /** * Class constructor */ - public function __construct($plugin) + public function __construct() { - $this->plugin = $plugin; - $this->rc = rcmail::get_instance(); + $this->rc = rcmail::get_instance(); $search = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC, true); $reqid = rcube_utils::get_input_value('_reqid', rcube_utils::INPUT_GPC); diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php index a79e9ee8..0a8ce533 100644 --- a/plugins/kolab_folders/kolab_folders.php +++ b/plugins/kolab_folders/kolab_folders.php @@ -106,7 +106,7 @@ class kolab_folders extends rcube_plugin } // Create default folders - if ($args['root'] == '' && $args['name'] = '*') { + if ($args['root'] == '' && $args['name'] == '*') { $this->create_default_folders($folders, $args['filter'], $folderdata, $args['mode'] == 'LSUB'); } diff --git a/plugins/kolab_notes/kolab_notes.php b/plugins/kolab_notes/kolab_notes.php index 3285bc56..9ebaa977 100644 --- a/plugins/kolab_notes/kolab_notes.php +++ b/plugins/kolab_notes/kolab_notes.php @@ -1152,7 +1152,7 @@ class kolab_notes extends rcube_plugin // let the UI generate HTML and CSS representation for this calendar $html = $this->ui->folder_list_item($id, $prop, $jsenv, true); - $prop += $jsenv[$id] ?? []; + $prop += $jsenv[$id] ?? []; // @phpstan-ignore-line $prop['editname'] = $editname; $prop['html'] = $html; diff --git a/plugins/kolab_notes/kolab_notes_ui.php b/plugins/kolab_notes/kolab_notes_ui.php index d782d38d..35ae135a 100644 --- a/plugins/kolab_notes/kolab_notes_ui.php +++ b/plugins/kolab_notes/kolab_notes_ui.php @@ -2,7 +2,6 @@ class kolab_notes_ui { - private $action; private $folder; private $rc; private $plugin; @@ -91,6 +90,7 @@ class kolab_notes_ui $lists = $this->plugin->get_lists($tree); $jsenv = []; + // @phpstan-ignore-next-line if (is_object($tree)) { $html = $this->folder_tree_html($tree, $lists, $jsenv, $attrib); } else { @@ -139,7 +139,7 @@ class kolab_notes_ui if (!empty($folder->children)) { $content .= html::tag( 'ul', - ['style' => ($is_collapsed ? "display:none;" : null)], + ['style' => ($is_collapsed ? "display:none;" : null)], // @phpstan-ignore-line $this->folder_tree_html($folder, $data, $jsenv, $attrib) ); } @@ -187,6 +187,7 @@ class kolab_notes_ui $label_id = 'nl:' . $id; $attr = !empty($prop['virtual']) ? ['tabindex' => '0'] : ['href' => $this->rc->url(['_list' => $id])]; + return html::div( implode(' ', $classes), html::a($attr + ['class' => 'listname', 'title' => $title, 'id' => $label_id], $prop['listname'] ?: $prop['name']) . @@ -213,8 +214,6 @@ class kolab_notes_ui ) ) ); - - return ''; } public function listing($attrib) @@ -301,7 +300,6 @@ class kolab_notes_ui */ public function list_editform($action, $list, $folder) { - $this->action = $action; $this->list = $list; $this->folder = is_object($folder) ? $folder->name : ''; // UTF7; diff --git a/plugins/libcalendaring/lib/libcalendaring_vcalendar.php b/plugins/libcalendaring/lib/libcalendaring_vcalendar.php index 41b2ed3a..f07a7869 100644 --- a/plugins/libcalendaring/lib/libcalendaring_vcalendar.php +++ b/plugins/libcalendaring/lib/libcalendaring_vcalendar.php @@ -831,8 +831,7 @@ class libcalendaring_vcalendar implements Iterator $busyEnd = DateTimeParser::parse($busyEnd); if ($busyEnd instanceof \DateInterval) { $tmp = clone $busyStart; - $tmp->add($busyEnd); - $busyEnd = $tmp; + $busyEnd = $tmp->add($busyEnd); } if ($busyEnd && $busyEnd > $busyStart) { @@ -895,7 +894,7 @@ class libcalendaring_vcalendar implements Iterator foreach ($prop->getParts() as $val) { try { [$start, $end] = explode('/', $val); - $start = DateTimeParser::parseDateTime($start); + $start = self::toDateTime(DateTimeParser::parseDateTime($start)); // This is a duration value. if ($end[0] === 'P') { @@ -903,10 +902,10 @@ class libcalendaring_vcalendar implements Iterator $end = clone $start; $end->add($dur); } else { - $end = DateTimeParser::parseDateTime($end); + $end = self::toDateTime(DateTimeParser::parseDateTime($end)); } - $dt[] = [self::toDateTime($start), self::toDateTime($end)]; + $dt[] = [$start, $end]; } catch (Exception $e) { // ignore single date parse errors } @@ -1080,10 +1079,10 @@ class libcalendaring_vcalendar implements Iterator /** * Build a valid iCal format block from the given event * - * @param array $event Hash array with event/task properties from libkolab + * @param array $event Hash array with event/task properties from libkolab * @param VObject\Component\VCalendar $vcal VCalendar object to append event to or false for directly sending data to stdout - * @param ?callable $get_attachment Optional callback function to fetch attachment contents - * @param object $recurrence_id RECURRENCE-ID property when serializing a recurrence exception + * @param ?callable $get_attachment Optional callback function to fetch attachment contents + * @param VObject\Property $recurrence_id RECURRENCE-ID property when serializing a recurrence exception */ private function _to_ical($event, $vcal, $get_attachment, $recurrence_id = null) { @@ -1517,6 +1516,8 @@ class libcalendaring_vcalendar implements Iterator /** * Convert DateTime into libcalendaring_datetime + * + * @return libcalendaring_datetime */ private static function toDateTime($date) { diff --git a/plugins/libkolab/lib/kolab_attachments_handler.php b/plugins/libkolab/lib/kolab_attachments_handler.php index b4d8be26..92453761 100644 --- a/plugins/libkolab/lib/kolab_attachments_handler.php +++ b/plugins/libkolab/lib/kolab_attachments_handler.php @@ -164,8 +164,7 @@ class kolab_attachments_handler } if (!empty($_SESSION[$session_key . '_deleteicon']) - && ($icon = $_SESSION[$session_key . '_deleteicon']) - && is_file($icon) + && is_file($icon = $_SESSION[$session_key . '_deleteicon']) ) { $button = html::img([ 'src' => $icon, diff --git a/plugins/libkolab/lib/kolab_bonnie_api.php b/plugins/libkolab/lib/kolab_bonnie_api.php index 681b40d3..c2ee6a90 100644 --- a/plugins/libkolab/lib/kolab_bonnie_api.php +++ b/plugins/libkolab/lib/kolab_bonnie_api.php @@ -27,7 +27,6 @@ class kolab_bonnie_api { public $ready = false; - private $config = []; private $client = null; @@ -36,8 +35,6 @@ class kolab_bonnie_api */ public function __construct($config) { - $this->config = $config; - $this->client = new kolab_bonnie_api_client($config['uri'], $config['timeout'] ?: 30, (bool)$config['debug']); $this->client->set_secret($config['secret']); diff --git a/plugins/libkolab/lib/kolab_date_recurrence.php b/plugins/libkolab/lib/kolab_date_recurrence.php index d64f4250..3cd9dbe8 100644 --- a/plugins/libkolab/lib/kolab_date_recurrence.php +++ b/plugins/libkolab/lib/kolab_date_recurrence.php @@ -85,7 +85,8 @@ class kolab_date_recurrence $time = false; if ($this->engine && $this->next) { - if (($cnext = new cDateTime($this->engine->getNextOccurence($this->cnext))) && $cnext->isValid()) { + $cnext = new cDateTime($this->engine->getNextOccurence($this->cnext)); + if ($cnext->isValid()) { $next = kolab_format::php_datetime($cnext, $this->start->getTimezone()); $time = $timestamp ? $next->format('U') : $next; diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php index 2d9088be..3e453458 100644 --- a/plugins/libkolab/lib/kolab_format.php +++ b/plugins/libkolab/lib/kolab_format.php @@ -165,7 +165,7 @@ abstract class kolab_format * @param string $version Format version * @param string $xmldata Cached xml data to initialize with * - * @return kolab_format + * @return kolab_format|PEAR_Error */ public static function factory($type, $version = '3.0', $xmldata = null) { @@ -174,6 +174,7 @@ abstract class kolab_format } if (!self::supports($version)) { + // @phpstan-ignore-next-line return PEAR::raiseError("No support for Kolab format version " . $version); } @@ -184,6 +185,7 @@ abstract class kolab_format return new $classname($xmldata, $version); } + // @phpstan-ignore-next-line return PEAR::raiseError("Failed to load Kolab Format wrapper for type " . $type); } diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php index 1cb2f5da..a69901d1 100644 --- a/plugins/libkolab/lib/kolab_format_event.php +++ b/plugins/libkolab/lib/kolab_format_event.php @@ -220,7 +220,7 @@ class kolab_format_event extends kolab_format_xcal $object['exceptions'] = $recurrence_exceptions; // also link with recurrence.EXCEPTIONS for compatibility - if (!empty($object['recurrence']) && isset($object['exceptions'])) { + if (!empty($object['recurrence'])) { $object['recurrence']['EXCEPTIONS'] = &$object['exceptions']; } } diff --git a/plugins/libkolab/lib/kolab_ldap.php b/plugins/libkolab/lib/kolab_ldap.php index 0ce9e408..195c9d1e 100644 --- a/plugins/libkolab/lib/kolab_ldap.php +++ b/plugins/libkolab/lib/kolab_ldap.php @@ -30,7 +30,6 @@ class kolab_ldap extends rcube_ldap_generic private $debug = false; private $fieldmap = []; private $parse_replaces = []; - private $rcache; private $ready = false; diff --git a/plugins/libkolab/lib/kolab_storage.php b/plugins/libkolab/lib/kolab_storage.php index 8c0c0ddb..54e248a5 100644 --- a/plugins/libkolab/lib/kolab_storage.php +++ b/plugins/libkolab/lib/kolab_storage.php @@ -1047,8 +1047,8 @@ class kolab_storage /** * Check the folder tree and add the missing parents as virtual folders * - * @param array $folders Folders list - * @param object $tree Reference to the root node of the folder tree + * @param array $folders Folders list + * @param ?kolab_storage_folder_virtual $tree Reference to the root node of the folder tree * * @return array Flat folders list */ diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php index 924429fe..cbf64db3 100644 --- a/plugins/libkolab/lib/kolab_storage_folder.php +++ b/plugins/libkolab/lib/kolab_storage_folder.php @@ -414,6 +414,7 @@ class kolab_storage_folder extends kolab_storage_folder_api $object['_formatobj']->get_attachments($object); } + // @phpstan-ignore-next-line foreach ($object['_attachments'] as $attach) { if ($attach['id'] == $part) { if ($print) { @@ -779,7 +780,7 @@ class kolab_storage_folder extends kolab_storage_folder_api $object['recurrence']['UNTIL'] = $untildate; unset($object['recurrence']['COUNT']); } else { - if (!$exdates[$exception['start']->format('Y-m-d')]) { + if (empty($exdates[$exception['start']->format('Y-m-d')])) { $object['recurrence']['EXDATE'][] = clone $exception['start']; } unset($exception['recurrence']); @@ -1023,6 +1024,7 @@ class kolab_storage_folder extends kolab_storage_folder_api if (empty($att['content']) && !empty($att['id'])) { // @TODO: use IMAP CATENATE to skip attachment fetch+push operation $msguid = !empty($object['_copyfrom']) ? $object['_copyfrom'] : (!empty($object['_msguid']) ? $object['_msguid'] : $object['uid']); + // @phpstan-ignore-next-line if ($is_file) { $att['path'] = tempnam($temp_dir, 'rcmAttmnt'); if (($fp = fopen($att['path'], 'w')) && $this->get_attachment($msguid, $att['id'], $object['_mailbox'], false, $fp, true)) { @@ -1043,6 +1045,7 @@ class kolab_storage_folder extends kolab_storage_folder_api // directly to IMAP, see rcube_imap_generic::append(). // I.e. use file handles where possible if (!empty($att['path'])) { + // @phpstan-ignore-next-line if ($is_file && $binary) { $files[] = fopen($att['path'], 'r'); $mime->addAttachment($marker, $att['mimetype'], $name, false, $encoding, 'attachment', '', '', '', null, null, '', RCUBE_CHARSET, $headers); @@ -1050,6 +1053,7 @@ class kolab_storage_folder extends kolab_storage_folder_api $mime->addAttachment($att['path'], $att['mimetype'], $name, true, $encoding, 'attachment', '', '', '', null, null, '', RCUBE_CHARSET, $headers); } } else { + // @phpstan-ignore-next-line if (is_resource($att['content']) && $is_file && $binary) { $files[] = $att['content']; $mime->addAttachment($marker, $att['mimetype'], $name, false, $encoding, 'attachment', '', '', '', null, null, '', RCUBE_CHARSET, $headers); @@ -1086,6 +1090,7 @@ class kolab_storage_folder extends kolab_storage_folder_api $message = $tmp; } // write complete message body into temp file + // @phpstan-ignore-next-line elseif ($is_file) { // use common temp dir $body_file = tempnam($temp_dir, 'rcmMsg'); @@ -1141,6 +1146,7 @@ class kolab_storage_folder extends kolab_storage_folder_api } if ($result instanceof PEAR_Error) { + // @phpstan-ignore-next-line return PEAR::raiseError( sprintf("Failed triggering folder %s. Error was: %s", $this->name, $result->getMessage()) ); @@ -1171,6 +1177,7 @@ class kolab_storage_folder extends kolab_storage_folder_api $result = $request->send(); // rcube::write_log('trigger', $result->getBody()); } catch (Exception $e) { + // @phpstan-ignore-next-line return PEAR::raiseError($e->getMessage()); } diff --git a/plugins/tasklist/drivers/caldav/tasklist_caldav_driver.php b/plugins/tasklist/drivers/caldav/tasklist_caldav_driver.php index 273fd4ad..9437700e 100644 --- a/plugins/tasklist/drivers/caldav/tasklist_caldav_driver.php +++ b/plugins/tasklist/drivers/caldav/tasklist_caldav_driver.php @@ -37,7 +37,6 @@ class tasklist_caldav_driver extends tasklist_driver private $lists; private $folders = []; private $tasks = []; - private $tags = []; private $bonnie_api = false; @@ -922,29 +921,28 @@ class tasklist_caldav_driver extends tasklist_driver * * @return array (uid,folder,msguid) tuple */ + /* private function _resolve_task_identity($prop) { - /* - $mailbox = $msguid = null; + $mailbox = $msguid = null; - $this->_parse_id($prop); - $uid = $prop['uid']; - $list_id = $prop['list']; + $this->_parse_id($prop); + $uid = $prop['uid']; + $list_id = $prop['list']; - if ($folder = $this->get_folder($list_id)) { - $mailbox = $folder->get_mailbox_id(); + if ($folder = $this->get_folder($list_id)) { + $mailbox = $folder->get_mailbox_id(); - // get task object from storage in order to get the real object uid an msguid - if ($rec = $folder->get_object($uid)) { - $msguid = $rec['_msguid']; - $uid = $rec['uid']; - } - } + // get task object from storage in order to get the real object uid an msguid + if ($rec = $folder->get_object($uid)) { + $msguid = $rec['_msguid']; + $uid = $rec['uid']; + } + } - return array($uid, $mailbox, $msguid); - */ - return []; + return array($uid, $mailbox, $msguid); } + */ /** * Get a list of pending alarms to be displayed to the user diff --git a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php index 1b6814e8..2f7c59bd 100644 --- a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php +++ b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php @@ -930,7 +930,7 @@ class tasklist_kolab_driver extends tasklist_driver $special_changes = []; // map kolab event properties to keys the client expects - array_walk($result['changes'], function (&$change, $i) use ($keymap, $prop_keymaps, $special_changes) { + array_walk($result['changes'], function (&$change, $i) use ($keymap, $prop_keymaps, &$special_changes) { if (array_key_exists($change['property'], $keymap)) { $change['property'] = $keymap[$change['property']]; } diff --git a/plugins/tasklist/tasklist.php b/plugins/tasklist/tasklist.php index 6b143fb5..e9236291 100644 --- a/plugins/tasklist/tasklist.php +++ b/plugins/tasklist/tasklist.php @@ -652,7 +652,8 @@ class tasklist extends rcube_plugin } // yes, raw input matched a (valid) date - if (strlen($date_str) && strtotime($date_str) && ($date = new DateTime($date_str, $this->timezone))) { + if (strlen($date_str) && strtotime($date_str)) { + $date = new DateTime($date_str, $this->timezone); $rec['date'] = $date->format('Y-m-d'); if (!empty($has_time)) { $rec['time'] = $date->format('H:i'); @@ -983,7 +984,7 @@ class tasklist extends rcube_plugin $ignore = ['changed' => 1, 'attachments' => 1]; foreach (array_unique(array_merge(array_keys($a), array_keys($b))) as $key) { - if (!$ignore[$key] && $a[$key] != $b[$key]) { + if (empty($ignore[$key]) && $a[$key] != $b[$key]) { $diff[] = $key; } } @@ -1026,7 +1027,7 @@ class tasklist extends rcube_plugin if (empty($list['_reload'])) { $this->load_ui(); $list['html'] = $this->ui->tasklist_list_item($insert_id, $list, $jsenv); - $list += $jsenv[$insert_id] ?? []; + $list += $jsenv[$insert_id] ?? []; // @phpstan-ignore-line } $this->rc->output->command('plugin.insert_tasklist', $list); $success = true; @@ -1063,7 +1064,7 @@ class tasklist extends rcube_plugin // let the UI generate HTML and CSS representation for this calendar $html = $this->ui->tasklist_list_item($id, $prop, $jsenv); - $prop += $jsenv[$id] ?? []; + $prop += $jsenv[$id] ?? []; // @phpstan-ignore-line $prop['editname'] = $editname; $prop['html'] = $html; @@ -2274,7 +2275,7 @@ class tasklist extends rcube_plugin } else { $error_msg = $this->gettext('newerversionexists'); } - } elseif (!$existing && ($status != 'declined' || $this->rc->config->get('kolab_invitation_tasklists'))) { + } elseif ($status != 'declined' || $this->rc->config->get('kolab_invitation_tasklists')) { $success = $this->driver->create_task($task); } elseif ($status == 'declined') { $error_msg = null; diff --git a/plugins/tasklist/tasklist_ui.php b/plugins/tasklist/tasklist_ui.php index df25f981..40f9109d 100644 --- a/plugins/tasklist/tasklist_ui.php +++ b/plugins/tasklist/tasklist_ui.php @@ -176,6 +176,7 @@ class tasklist_ui } // walk folder tree + // @phpstan-ignore-next-line FIXME: does it make sense? if (is_object($tree)) { $html = $this->list_tree_html($tree, $lists, $jsenv, $attrib); } else { @@ -224,7 +225,7 @@ class tasklist_ui if (!empty($folder->children)) { $content .= html::tag( 'ul', - ['style' => ($is_collapsed ? "display:none;" : null)], + ['style' => ($is_collapsed ? "display:none;" : null)], // @phpstan-ignore-line $this->list_tree_html($folder, $data, $jsenv, $attrib) ); } @@ -267,7 +268,7 @@ class tasklist_ui if (!empty($prop['title'])) { $title = $prop['title']; } elseif (empty($prop['listname']) || $prop['name'] != $prop['listname'] || strlen($prop['name']) > 25) { - html_entity_decode($prop['name'], ENT_COMPAT, RCUBE_CHARSET); + $title = html_entity_decode($prop['name'], ENT_COMPAT, RCUBE_CHARSET); } if (!empty($prop['virtual'])) {