diff --git a/phpstan.neon b/phpstan.neon index 0be50305..aecda91a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -29,7 +29,7 @@ parameters: paths: - plugins - level: 2 + level: 3 scanDirectories: - program/include diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index d286eb6b..1fff88f8 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] ?? []; $cal['editname'] = $editname; $cal['html'] = $html; diff --git a/plugins/calendar/drivers/caldav/caldav_calendar.php b/plugins/calendar/drivers/caldav/caldav_calendar.php index a4180020..165fd460 100644 --- a/plugins/calendar/drivers/caldav/caldav_calendar.php +++ b/plugins/calendar/drivers/caldav/caldav_calendar.php @@ -450,7 +450,7 @@ class caldav_calendar extends kolab_storage_dav_folder $this->events = [$event['uid'] => $this->_to_driver_event($object, true)]; - return true; + return $saved; } /** diff --git a/plugins/calendar/drivers/caldav/caldav_driver.php b/plugins/calendar/drivers/caldav/caldav_driver.php index c0e5d250..85727b0b 100644 --- a/plugins/calendar/drivers/caldav/caldav_driver.php +++ b/plugins/calendar/drivers/caldav/caldav_driver.php @@ -99,6 +99,8 @@ class caldav_driver extends kolab_driver /** * Convert kolab_storage_folder into caldav_calendar + * + * @return caldav_calendar|kolab_user_calendar */ protected function _to_calendar($folder) { @@ -278,7 +280,7 @@ class caldav_driver extends kolab_driver * * @param string $id Calendar identifier * - * @return ?caldav_calendar Object nor null if calendar doesn't exist + * @return caldav_calendar|caldav_invitation_calendar|null Object nor null if calendar doesn't exist */ public function get_calendar($id) { diff --git a/plugins/calendar/drivers/calendar_driver.php b/plugins/calendar/drivers/calendar_driver.php index 42e3cbd4..f493fc41 100644 --- a/plugins/calendar/drivers/calendar_driver.php +++ b/plugins/calendar/drivers/calendar_driver.php @@ -296,7 +296,7 @@ abstract class calendar_driver * See FILTER_* constants for possible values. * @param bool $full If true, recurrence exceptions shall be added * - * @return array Event object as hash array + * @return ?array Event object as hash array */ abstract public function get_event($event, $scope = 0, $full = false); @@ -420,11 +420,11 @@ abstract class calendar_driver * id: Event identifier * calendar: Calendar identifier * - * @return string Attachment body + * @return string|false Attachment body */ public function get_attachment_body($id, $event) { - return ''; + return false; } /** @@ -434,7 +434,7 @@ abstract class calendar_driver * or an URI from a stored link referencing a mail message. * @param string $folder IMAP folder the message resides in * - * @return array An struct referencing the given IMAP message + * @return array|false An struct referencing the given IMAP message */ public function get_message_reference($uri_or_headers, $folder = null) { @@ -480,7 +480,7 @@ abstract class calendar_driver * @param int $start Requested period start date/time as unix timestamp * @param int $end Requested period end date/time as unix timestamp * - * @return array List of busy timeslots within the requested range + * @return array|false List of busy timeslots within the requested range */ public function get_freebusy_list($email, $start, $end) { @@ -551,7 +551,7 @@ abstract class calendar_driver * id: Event identifier * calendar: Calendar identifier * - * @return array List of changes, each as a hash array: + * @return array|false List of changes, each as a hash array: * rev: Revision number * type: Type of the change (create, update, move, delete) * date: Change date @@ -573,7 +573,7 @@ abstract class calendar_driver * @param mixed $rev1 Old Revision * @param mixed $rev2 New Revision * - * @return array List of property changes, each as a hash array: + * @return array|false List of property changes, each as a hash array: * property: Revision number * old: Old property value * new: Updated property value @@ -591,7 +591,7 @@ abstract class calendar_driver * calendar: Calendar identifier * @param mixed $rev Revision number * - * @return array Event object as hash array + * @return array|false Event object as hash array * @see self::get_event() */ public function get_event_revison($event, $rev) @@ -608,7 +608,7 @@ abstract class calendar_driver * calendar: Calendar identifier * @param mixed $rev Revision number * - * @return boolean True on success, False on failure + * @return bool True on success, False on failure */ public function restore_event_revision($event, $rev) { @@ -794,7 +794,7 @@ abstract class calendar_driver public static function parse_contact($contact, $source) { if (!is_array($contact)) { - return; + return null; } if (!empty($contact['birthday']) && is_array($contact['birthday'])) { @@ -802,7 +802,7 @@ abstract class calendar_driver } if (empty($contact['birthday'])) { - return; + return null; } try { @@ -818,7 +818,7 @@ abstract class calendar_driver true, false ); - return; + return null; } $rcmail = rcmail::get_instance(); diff --git a/plugins/calendar/drivers/database/database_driver.php b/plugins/calendar/drivers/database/database_driver.php index 15fe3924..db7d5cc5 100644 --- a/plugins/calendar/drivers/database/database_driver.php +++ b/plugins/calendar/drivers/database/database_driver.php @@ -1017,7 +1017,7 @@ class database_driver extends calendar_driver * @param int $scope Bitmask defining the scope to search events in * @param bool $full If true, recurrence exceptions shall be added * - * @return array Hash array with event properties + * @return ?array Hash array with event properties */ public function get_event($event, $scope = 0, $full = false) { @@ -1072,7 +1072,7 @@ class database_driver extends calendar_driver return $this->cache[$id]; } - return false; + return null; } /** diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php index 2114d494..d7c45094 100644 --- a/plugins/calendar/drivers/kolab/kolab_driver.php +++ b/plugins/calendar/drivers/kolab/kolab_driver.php @@ -352,7 +352,7 @@ class kolab_driver extends calendar_driver * * @param string $id Calendar identifier (encoded imap folder name) * - * @return kolab_calendar Object nor null if calendar doesn't exist + * @return kolab_calendar|kolab_invitation_calendar|null Object nor null if calendar doesn't exist */ public function get_calendar($id) { @@ -585,7 +585,7 @@ class kolab_driver extends calendar_driver * Fetch a single event * * @see calendar_driver::get_event() - * @return array Hash array with event properties, false if not found + * @return ?array Hash array with event properties, false if not found */ public function get_event($event, $scope = 0, $full = false) { @@ -621,7 +621,7 @@ class kolab_driver extends calendar_driver } } - return false; + return null; } /** @@ -1843,7 +1843,7 @@ class kolab_driver extends calendar_driver public function list_attachments($event) { if (!($storage = $this->get_calendar($event['calendar']))) { - return false; + return []; } $event = $storage->get_event($event['id']); @@ -2260,7 +2260,7 @@ class kolab_driver extends calendar_driver * * @param array $event Hash array with event properties * - * @return array List of changes, each as a hash array + * @return array|false List of changes, each as a hash array * @see calendar_driver::get_event_changelog() */ public function get_event_changelog($event) @@ -2286,7 +2286,7 @@ class kolab_driver extends calendar_driver * @param mixed $rev1 Old Revision * @param mixed $rev2 New Revision * - * @return array List of property changes, each as a hash array + * @return array|false List of property changes, each as a hash array * @see calendar_driver::get_event_diff() */ public function get_event_diff($event, $rev1, $rev2) @@ -2413,7 +2413,7 @@ class kolab_driver extends calendar_driver * @param array $event Hash array with event properties * @param mixed $rev Revision number * - * @return array Event object as hash array + * @return array|false Event object as hash array * @see calendar_driver::get_event_revison() */ public function get_event_revison($event, $rev, $internal = false) diff --git a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php index 3cdb39b6..b89f772f 100644 --- a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php +++ b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php @@ -118,7 +118,7 @@ class kolab_invitation_calendar /** * Getter for the Cyrus mailbox identifier corresponding to this folder * - * @return string Mailbox ID + * @return ?string Mailbox ID */ public function get_mailbox_id() { diff --git a/plugins/calendar/drivers/ldap/resources_driver_ldap.php b/plugins/calendar/drivers/ldap/resources_driver_ldap.php index c12067fc..c077e451 100644 --- a/plugins/calendar/drivers/ldap/resources_driver_ldap.php +++ b/plugins/calendar/drivers/ldap/resources_driver_ldap.php @@ -63,7 +63,7 @@ class resources_driver_ldap extends resources_driver $results = $ldap->list_records(); } - if ($results instanceof ArrayAccess) { + if ($results instanceof Iterator) { foreach ($results as $i => $rec) { $results[$i] = $this->decode_resource($rec); } diff --git a/plugins/calendar/drivers/resources_driver.php b/plugins/calendar/drivers/resources_driver.php index b7a779bc..22c49c96 100644 --- a/plugins/calendar/drivers/resources_driver.php +++ b/plugins/calendar/drivers/resources_driver.php @@ -59,7 +59,7 @@ abstract class resources_driver * * @param string $id Owner identifier * - * @return array Resource object as hash array + * @return ?array Resource owner object as hash array */ public function get_resource_owner($id) { diff --git a/plugins/calendar/lib/calendar_itip.php b/plugins/calendar/lib/calendar_itip.php index a1cef132..a50ef06f 100644 --- a/plugins/calendar/lib/calendar_itip.php +++ b/plugins/calendar/lib/calendar_itip.php @@ -142,7 +142,7 @@ class calendar_itip extends libcalendaring_itip * @param array $event Hash array with event properties * @param string $attendee Attendee email address * - * @return string Invitation token + * @return string|false Invitation token */ public function store_invitation($event, $attendee) { diff --git a/plugins/kolab_2fa/kolab_2fa.php b/plugins/kolab_2fa/kolab_2fa.php index 69cfd50d..97ce06ae 100644 --- a/plugins/kolab_2fa/kolab_2fa.php +++ b/plugins/kolab_2fa/kolab_2fa.php @@ -336,7 +336,7 @@ class kolab_2fa extends rcube_plugin * Load driver class for the given authentication factor * * @param string $factor Factor identifier (:) - * @return Kolab2FA\Driver\Base + * @return Kolab2FA\Driver\Base|false */ public function get_driver($factor) { diff --git a/plugins/kolab_addressbook/drivers/carddav/carddav_contacts.php b/plugins/kolab_addressbook/drivers/carddav/carddav_contacts.php index aea1db11..a2dbbad5 100644 --- a/plugins/kolab_addressbook/drivers/carddav/carddav_contacts.php +++ b/plugins/kolab_addressbook/drivers/carddav/carddav_contacts.php @@ -290,7 +290,7 @@ class carddav_contacts extends rcube_addressbook * @param int $subset Only return this number of records, use negative values for tail * @param bool $nocount True to skip the count query (select only) * - * @return array Indexed list of contact records, each a hash array + * @return rcube_result_set Indexed list of contact records, each a hash array */ public function list_records($cols = null, $subset = 0, $nocount = false) { @@ -1004,7 +1004,7 @@ class carddav_contacts extends rcube_addressbook * @param string $gid Group identifier * @param array $ids List of contact identifiers to be removed * - * @return bool + * @return int Numer of removed contacts */ public function remove_from_group($gid, $ids) { @@ -1013,7 +1013,7 @@ class carddav_contacts extends rcube_addressbook $list = $this->distlists[$gid]; if (!$list) { - return false; + return 0; } if (!is_array($ids)) { @@ -1021,9 +1021,12 @@ class carddav_contacts extends rcube_addressbook } $new_member = []; + $removed = 0; foreach ((array) $list['member'] as $member) { if (!in_array($member['ID'], $ids)) { $new_member[] = $member; + } else { + $removed++; } } @@ -1040,19 +1043,19 @@ class carddav_contacts extends rcube_addressbook true, false ); - } else { - // remove group assigments in local cache - foreach ($ids as $id) { - $j = array_search($gid, $this->groupmembers[$id]); - unset($this->groupmembers[$id][$j]); - } - $this->distlists[$gid] = $list; - - return true; + return 0; } - return false; + // remove group assigments in local cache + foreach ($ids as $id) { + $j = array_search($gid, $this->groupmembers[$id]); + unset($this->groupmembers[$id][$j]); + } + + $this->distlists[$gid] = $list; + + return $removed; } /** diff --git a/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php b/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php index f062a118..656556bc 100644 --- a/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php +++ b/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php @@ -344,7 +344,7 @@ class kolab_contacts extends rcube_addressbook * @param int $subset Only return this number of records, use negative values for tail * @param bool $nocount True to skip the count query (select only) * - * @return array Indexed list of contact records, each a hash array + * @return rcube_result_set Indexed list of contact records, each a hash array */ public function list_records($cols = null, $subset = 0, $nocount = false) { @@ -877,6 +877,7 @@ class kolab_contacts extends rcube_addressbook ); return false; } else { + // @phpstan-ignore-next-line FIXME: this one might be valid error $id = $this->uid2id($list['uid']); $this->distlists[$id] = $list; $result = ['id' => $id, 'name' => $name]; @@ -924,7 +925,7 @@ class kolab_contacts extends rcube_addressbook * @param string $newname New name to set for this group * @param string $newid New group identifier (if changed, otherwise don't set) * - * @return bool New name on success, false if no data was changed + * @return string|bool New name on success, false if no data was changed */ public function rename_group($gid, $newname, &$newid) { @@ -1019,7 +1020,7 @@ class kolab_contacts extends rcube_addressbook false ); - $added = false; + $added = 0; $this->set_error(self::ERROR_SAVING, 'errorsaving'); } else { $this->distlists[$gid] = $list; @@ -1044,13 +1045,17 @@ class kolab_contacts extends rcube_addressbook $this->_fetch_groups(); if (!($list = $this->distlists[$gid])) { - return false; + return 0; } $new_member = []; + $removed = 0; + foreach ((array)$list['member'] as $member) { if (!in_array($member['ID'], $ids)) { $new_member[] = $member; + } else { + $removed++; } } @@ -1067,17 +1072,19 @@ class kolab_contacts extends rcube_addressbook true, false ); - } else { - // remove group assigments in local cache - foreach ($ids as $id) { - $j = array_search($gid, $this->groupmembers[$id]); - unset($this->groupmembers[$id][$j]); - } - $this->distlists[$gid] = $list; - return true; + + return 0; } - return false; + // remove group assigments in local cache + foreach ($ids as $id) { + $j = array_search($gid, $this->groupmembers[$id]); + unset($this->groupmembers[$id][$j]); + } + + $this->distlists[$gid] = $list; + + return $removed; } /** diff --git a/plugins/kolab_addressbook/drivers/kolab/kolab_contacts_driver.php b/plugins/kolab_addressbook/drivers/kolab/kolab_contacts_driver.php index ad5e8c24..980b8527 100644 --- a/plugins/kolab_addressbook/drivers/kolab/kolab_contacts_driver.php +++ b/plugins/kolab_addressbook/drivers/kolab/kolab_contacts_driver.php @@ -97,7 +97,7 @@ class kolab_contacts_driver $folder = kolab_storage::get_folder($folderId); if ($folder && kolab_storage::folder_delete($folder->name)) { - return $folderId; + return true; } return false; diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php index 61fd84f7..4d695aec 100644 --- a/plugins/kolab_addressbook/kolab_addressbook.php +++ b/plugins/kolab_addressbook/kolab_addressbook.php @@ -1022,7 +1022,7 @@ class kolab_addressbook extends rcube_plugin { $source = trim(rcube_utils::get_input_value('_source', rcube_utils::INPUT_GPC, true)); - if ($source && ($result = $this->driver->folder_delete($source))) { + if ($source && $this->driver->folder_delete($source)) { $storage = $this->rc->get_storage(); $delimiter = $storage->get_hierarchy_delimiter(); diff --git a/plugins/kolab_chat/drivers/mattermost.php b/plugins/kolab_chat/drivers/mattermost.php index c081d002..8bac1f1d 100644 --- a/plugins/kolab_chat/drivers/mattermost.php +++ b/plugins/kolab_chat/drivers/mattermost.php @@ -266,7 +266,7 @@ class kolab_chat_mattermost /** * Returns the Mattermost channels list for the user * - * @return array Channels list (id, name, display_name, etc.) + * @return array|false Channels list (id, name, display_name, etc.) */ protected function get_channels_list() { diff --git a/plugins/kolab_delegation/kolab_delegation_engine.php b/plugins/kolab_delegation/kolab_delegation_engine.php index 8d12d845..0684b593 100644 --- a/plugins/kolab_delegation/kolab_delegation_engine.php +++ b/plugins/kolab_delegation/kolab_delegation_engine.php @@ -449,11 +449,11 @@ class kolab_delegation_engine $user = $this->parse_ldap_record($record); - if ($user['uid']) { + if ($uid = $user['uid']) { $display = rcube_addressbook::compose_search_name($record); - $user = ['name' => $user['uid'], 'display' => $display]; + $user = ['name' => $uid, 'display' => $display]; $users[] = $user; - $keys[] = $display ?: $user['uid']; + $keys[] = $display ?: $uid; } } diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php index 447446ba..a79e9ee8 100644 --- a/plugins/kolab_folders/kolab_folders.php +++ b/plugins/kolab_folders/kolab_folders.php @@ -578,7 +578,7 @@ class kolab_folders extends rcube_plugin * * @param string $type Folder type * - * @return string Folder name + * @return ?string Folder name */ public function get_default_folder($type) { diff --git a/plugins/kolab_notes/kolab_notes.php b/plugins/kolab_notes/kolab_notes.php index 4a09a49c..3285bc56 100644 --- a/plugins/kolab_notes/kolab_notes.php +++ b/plugins/kolab_notes/kolab_notes.php @@ -892,7 +892,7 @@ class kolab_notes extends rcube_plugin * * @param array $note Hash array with note properties * - * @return array List of changes, each as a hash array + * @return array|false List of changes, each as a hash array */ public function get_changelog($note) { @@ -916,7 +916,7 @@ class kolab_notes extends rcube_plugin * @param mixed $note UID string or hash array with note properties * @param mixed $rev Revision number * - * @return array Note object as hash array + * @return array|false Note object as hash array */ public function get_revison($note, $rev) { @@ -949,7 +949,7 @@ class kolab_notes extends rcube_plugin * @param mixed $rev1 Revision: "from" * @param mixed $rev2 Revision: "to" * - * @return array List of property changes, each as a hash array + * @return array|false List of property changes, each as a hash array */ public function get_diff($note, $rev1, $rev2) { @@ -1007,10 +1007,10 @@ class kolab_notes extends rcube_plugin * Command the backend to restore a certain revision of a note. * This shall replace the current object with an older version. * - * @param array $note Hash array with note properties (id, list) - * @param mixed $rev Revision number + * @param array $note Hash array with note properties (id, list) + * @param mixed $rev Revision number * - * @return boolean True on success, False on failure + * @return bool True on success, False on failure */ public function restore_revision($note, $rev) { @@ -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 += (array)$jsenv[$id]; + $prop += $jsenv[$id] ?? []; $prop['editname'] = $editname; $prop['html'] = $html; diff --git a/plugins/libcalendaring/lib/libcalendaring_itip.php b/plugins/libcalendaring/lib/libcalendaring_itip.php index f43e319c..9f9ac578 100644 --- a/plugins/libcalendaring/lib/libcalendaring_itip.php +++ b/plugins/libcalendaring/lib/libcalendaring_itip.php @@ -958,14 +958,13 @@ class libcalendaring_itip return $table->show(); } - /** * Create iTIP invitation token for later replies via URL * * @param array $event Hash array with event properties * @param string $attendee Attendee email address * - * @return string Invitation token + * @return string|false Invitation token */ public function store_invitation($event, $attendee) { @@ -981,7 +980,6 @@ class libcalendaring_itip public function cancel_itip_invitation($event) { // empty stub - return false; } /** diff --git a/plugins/libcalendaring/lib/libcalendaring_recurrence.php b/plugins/libcalendaring/lib/libcalendaring_recurrence.php index f396a2af..3b06bd01 100644 --- a/plugins/libcalendaring/lib/libcalendaring_recurrence.php +++ b/plugins/libcalendaring/lib/libcalendaring_recurrence.php @@ -153,7 +153,7 @@ class libcalendaring_recurrence { // recurrence end date is given if (isset($this->recurrence['UNTIL']) && $this->recurrence['UNTIL'] instanceof DateTimeInterface) { - return $this->recurrence['UNTIL']; + return $this->toDateTime($this->recurrence['UNTIL']); } // Run through all items till we reach the end, or limit of iterations @@ -165,12 +165,13 @@ class libcalendaring_recurrence } catch (Exception $e) { // do nothing } + /* - if (empty($end) && isset($this->event['start']) && $this->event['start'] instanceof DateTimeInterface) { - // determine a reasonable end date if none given - $end = clone $this->event['start']; - $end->add(new DateInterval('P100Y')); - } + if (empty($end) && isset($this->event['start']) && $this->event['start'] instanceof DateTimeInterface) { + // determine a reasonable end date if none given + $end = clone $this->event['start']; + $end->add(new DateInterval('P100Y')); + } */ return isset($end) ? $this->toDateTime($end) : false; diff --git a/plugins/libcalendaring/lib/libcalendaring_vcalendar.php b/plugins/libcalendaring/lib/libcalendaring_vcalendar.php index b27a762b..41b2ed3a 100644 --- a/plugins/libcalendaring/lib/libcalendaring_vcalendar.php +++ b/plugins/libcalendaring/lib/libcalendaring_vcalendar.php @@ -314,7 +314,7 @@ class libcalendaring_vcalendar implements Iterator /** * Import objects from an already parsed Sabre\VObject\Component object * - * @param Sabre\VObject\Component $vobject Component to read from + * @param VObject\Component $vobject Component to read from * * @return array List of events extracted from the file */ @@ -399,7 +399,7 @@ class libcalendaring_vcalendar implements Iterator /** * Convert the given VEvent object to a libkolab compatible array representation * - * @param Sabre\VObject\Component\VEvent|Sabre\VObject\Component\VTodo $ve VEvent object to convert + * @param VObject\Component\VEvent|VObject\Component\VTodo $ve VEvent object to convert * * @return array Hash array with object properties */ @@ -937,7 +937,7 @@ class libcalendaring_vcalendar implements Iterator * @param bool $utc Set as UTC date * @param bool $dateonly Set as VALUE=DATE property * - * @return Sabre\VObject\Property + * @return VObject\Property */ public function datetime_prop($cal, $name, $dt, $utc = false, $dateonly = null, $set_type = false) { @@ -1002,7 +1002,6 @@ class libcalendaring_vcalendar implements Iterator return $params; } - /** * Export events to iCalendar format * @@ -1012,7 +1011,7 @@ class libcalendaring_vcalendar implements Iterator * @param ?callable $get_attachment Optional callback function to fetch attachment contents * @param bool $with_timezones Add VTIMEZONE block with timezone definitions for the included events * - * @return string Events in iCalendar format (http://tools.ietf.org/html/rfc5545) + * @return string|true Events in iCalendar format (http://tools.ietf.org/html/rfc5545) */ public function export($objects, $method = null, $write = false, $get_attachment = null, $with_timezones = true) { @@ -1056,9 +1055,9 @@ class libcalendaring_vcalendar implements Iterator if ($write) { echo "END:VCALENDAR\r\n"; return true; - } else { - return $vcal->serialize(); } + + return $vcal->serialize(); } /** @@ -1067,7 +1066,7 @@ class libcalendaring_vcalendar implements Iterator * @param array $object Event * @param ?callable $get_attachment Optional callback function to fetch attachment contents * - * @return Sabre\VObject\Component\VEvent Sabre component + * @return VObject\Component Sabre component */ public function toSabreComponent($object, $get_attachment = null) { @@ -1416,10 +1415,10 @@ class libcalendaring_vcalendar implements Iterator * @param string $tzid Timezone ID as used in PHP's Date functions * @param int $from Unix timestamp with first date/time in this timezone * @param int $to Unix timestap with last date/time in this timezone - * @param Sabre\VObject\Component\VCalendar $cal Optional VCalendar component + * @param VObject\Component\VCalendar $cal Optional VCalendar component * - * @return Sabre\VObject\Component|false Object representing a VTIMEZONE definition - * or false if no timezone information is available + * @return VObject\Component|false Object representing a VTIMEZONE definition + * or false if no timezone information is available */ public static function get_vtimezone($tzid, $from = 0, $to = 0, $cal = null) { @@ -1552,8 +1551,6 @@ class libcalendaring_vcalendar implements Iterator if (empty($this->objects[$this->iteratorkey]) && $this->fp) { $this->_parse_next(true); } - - return $this->valid(); } #[\ReturnTypeWillChange] @@ -1567,7 +1564,6 @@ class libcalendaring_vcalendar implements Iterator { return !empty($this->objects[$this->iteratorkey]); } - } diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php index 9f80367e..b2461ecc 100644 --- a/plugins/libcalendaring/libcalendaring.php +++ b/plugins/libcalendaring/libcalendaring.php @@ -720,7 +720,7 @@ class libcalendaring extends rcube_plugin try { $interval = new DateInterval(trim($alarm['trigger'], '+-')); - $interval->invert = $alarm['trigger'][0] == '-'; + $interval->invert = $alarm['trigger'][0] == '-' ? 1 : 0; $notify_time = clone $refdate; $notify_time->add($interval); } catch (Exception $e) { @@ -1244,7 +1244,7 @@ class libcalendaring extends rcube_plugin * @param string $mime_id Message part ID and object index (e.g. '1.2:0') * @param string $type Object type filter (optional) * - * @return array Hash array with the parsed iCal + * @return ?array Hash array with the parsed iCal */ public function mail_get_itip_object($mbox, $uid, $mime_id, $type = null) { diff --git a/plugins/libkolab/lib/kolab_bonnie_api_client.php b/plugins/libkolab/lib/kolab_bonnie_api_client.php index 5942eac1..4279cc1a 100644 --- a/plugins/libkolab/lib/kolab_bonnie_api_client.php +++ b/plugins/libkolab/lib/kolab_bonnie_api_client.php @@ -160,9 +160,12 @@ class kolab_bonnie_api_client /** * Do the HTTP request * - * @param string $payload Data to send + * @param array $payload Data to send + * @param bool $sign Enable signed request + * + * @return array */ - protected function send_request($payload, $sign = true) + protected function send_request(array $payload, $sign = true) { try { $payload_ = json_encode($payload); @@ -175,6 +178,7 @@ class kolab_bonnie_api_client } $this->_debug('REQUEST', $payload, $this->headers); + $request = libkolab::http_request($this->url, 'POST', ['timeout' => $this->timeout]); $request->setHeader($this->headers); $request->setAuth($this->username, $this->password); @@ -198,7 +202,7 @@ class kolab_bonnie_api_client return ['id' => $payload['id'], 'error' => $e->getMessage(), 'code' => -32000]; } - return is_array($result) ? $result : []; + return isset($result) && is_array($result) ? $result : []; } /** diff --git a/plugins/libkolab/lib/kolab_date_recurrence.php b/plugins/libkolab/lib/kolab_date_recurrence.php index 202328fb..d64f4250 100644 --- a/plugins/libkolab/lib/kolab_date_recurrence.php +++ b/plugins/libkolab/lib/kolab_date_recurrence.php @@ -133,7 +133,7 @@ class kolab_date_recurrence /** * Get the end date of the last occurence of this recurrence cycle * - * @return DateTime|bool End datetime of the last event or False if recurrence exceeds limit + * @return DateTimeInterface|bool End datetime of the last event or False if recurrence exceeds limit */ public function end() { diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php index 629335e6..2d9088be 100644 --- a/plugins/libkolab/lib/kolab_format.php +++ b/plugins/libkolab/lib/kolab_format.php @@ -283,7 +283,7 @@ abstract class kolab_format * @param cDateTime $cdt The libkolabxml datetime object * @param DateTimeZone $dest_tz The timezone to convert the date to * - * @return libcalendaring_datetime PHP datetime instance + * @return libcalendaring_datetime|null PHP datetime instance, Null on invalid input */ public static function php_datetime($cdt, $dest_tz = null) { @@ -463,7 +463,7 @@ abstract class kolab_format * * @param float $v Version value to convert * - * @return int Constant value of either kolabobject::KolabV2 or kolabobject::KolabV3 or false if kolabobject module isn't available + * @return int|false Constant value of either kolabobject::KolabV2 or kolabobject::KolabV3 or false if kolabobject module isn't available */ protected function libversion($v = null) { diff --git a/plugins/libkolab/lib/kolab_ldap.php b/plugins/libkolab/lib/kolab_ldap.php index 08a46c29..0ce9e408 100644 --- a/plugins/libkolab/lib/kolab_ldap.php +++ b/plugins/libkolab/lib/kolab_ldap.php @@ -301,12 +301,12 @@ class kolab_ldap extends rcube_ldap_generic * * @param string $dn DN * - * @return array Record data + * @return array|null Record data */ public function get_record($dn) { if (!$this->ready) { - return; + return null; } if ($rec = $this->get_entry($dn, $this->attributes)) { diff --git a/plugins/libkolab/lib/kolab_storage.php b/plugins/libkolab/lib/kolab_storage.php index a84c101c..8c0c0ddb 100644 --- a/plugins/libkolab/lib/kolab_storage.php +++ b/plugins/libkolab/lib/kolab_storage.php @@ -190,7 +190,7 @@ class kolab_storage * * @param string $type Data type to list folders for (contact,distribution-list,event,task,note) * - * @return object kolab_storage_folder The folder object + * @return kolab_storage_folder|null The folder object */ public static function get_default_folder($type) { @@ -209,7 +209,7 @@ class kolab_storage * @param string $folder IMAP folder to access (UTF7-IMAP) * @param string $type Expected folder type * - * @return object kolab_storage_folder The folder object + * @return kolab_storage_folder|null The folder object */ public static function get_folder($folder, $type = null) { @@ -223,7 +223,7 @@ class kolab_storage * @param string $uid Object UID * @param string $type Object type (contact,event,task,journal,file,note,configuration) * - * @return array The Kolab object represented as hash array or false if not found + * @return array|false The Kolab object represented as hash array or false if not found */ public static function get_object($uid, $type) { @@ -864,7 +864,7 @@ class kolab_storage public static function list_folders($root = '', $mbox = '*', $filter = null, $subscribed = null, &$folderdata = []) { if (!self::setup()) { - return null; + return []; } // use IMAP subscriptions @@ -1192,7 +1192,7 @@ class kolab_storage * * @param string $folder Folder name (UTF7-IMAP) * - * @return string Folder type + * @return string|null Folder type */ public static function folder_type($folder) { @@ -1412,12 +1412,12 @@ class kolab_storage * @param string $type Folder type * @param array $props Folder properties (color, etc) * - * @return string Folder name + * @return string|null Folder name */ public static function create_default_folder($type, $props = []) { if (!self::setup()) { - return; + return null; } $folders = self::$imap->get_metadata('*', [kolab_storage::CTYPE_KEY_PRIVATE]); @@ -1442,7 +1442,7 @@ class kolab_storage } if (!$default_name) { - return; + return null; } $folder = rcube_charset::convert($default_name, RCUBE_CHARSET, 'UTF7-IMAP'); @@ -1455,7 +1455,7 @@ class kolab_storage if (!self::$imap->folder_exists($folder)) { if (!self::$imap->create_folder($folder)) { - return; + return null; } } diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php index 3d00b077..be7bf574 100644 --- a/plugins/libkolab/lib/kolab_storage_cache.php +++ b/plugins/libkolab/lib/kolab_storage_cache.php @@ -1011,7 +1011,7 @@ class kolab_storage_cache * @param string $type Requested object type or * for all * @param string $folder IMAP folder to read from * - * @return array List of parsed Kolab objects + * @return kolab_storage_dataset List of parsed Kolab objects */ protected function _fetch($index, $type = null, $folder = null) { @@ -1109,8 +1109,8 @@ class kolab_storage_cache /** * Write records into cache using extended inserts to reduce the number of queries to be executed * - * @param int $msguid Message UID. Set 0 to commit buffered inserts - * @param array $object Kolab object to cache + * @param int $msguid Message UID. Set 0 to commit buffered inserts + * @param ?array $object Kolab object to cache */ protected function _extended_insert($msguid, $object) { diff --git a/plugins/libkolab/lib/kolab_storage_config.php b/plugins/libkolab/lib/kolab_storage_config.php index 4fbf5875..c1b2c31d 100644 --- a/plugins/libkolab/lib/kolab_storage_config.php +++ b/plugins/libkolab/lib/kolab_storage_config.php @@ -276,7 +276,7 @@ class kolab_storage_config * * @param string|array $params Object UUID or Message folder, UID, Search headers (Message-Id, Date) * - * @return string $url Member URI + * @return string|null $url Member URI */ public static function build_member_url($params) { @@ -348,7 +348,7 @@ class kolab_storage_config * * @param string $url Member URI * - * @return array Message folder, UID, Search headers (Message-Id, Date) + * @return array|false Message folder, UID, Search headers (Message-Id, Date) */ public static function parse_member_url($url) { @@ -570,12 +570,12 @@ class kolab_storage_config * @param array $records List of kolab objects * @param bool $no_return Don't return anything * - * @return array List of tags + * @return array|null List of tags */ public function apply_tags(&$records, $no_return = false) { if (empty($records) && $no_return) { - return; + return null; } // first convert categories into tags diff --git a/plugins/libkolab/lib/kolab_storage_dav.php b/plugins/libkolab/lib/kolab_storage_dav.php index 24298104..6ba34a82 100644 --- a/plugins/libkolab/lib/kolab_storage_dav.php +++ b/plugins/libkolab/lib/kolab_storage_dav.php @@ -113,7 +113,7 @@ class kolab_storage_dav * @param string $uid Object UID * @param string $type Object type (contact,event,task,journal,file,note,configuration) * - * @return array The Kolab object represented as hash array or false if not found + * @return array|false The Kolab object represented as hash array or false if not found */ public function get_object($uid, $type) { @@ -312,7 +312,7 @@ class kolab_storage_dav public function folder_selector($type, $attrs, $current = '') { // TODO - return null; + return null; // @phpstan-ignore-line } /** @@ -420,7 +420,7 @@ class kolab_storage_dav * @param string $folder Folder name * @param bool $temp Only subscribe temporarily for the current session * - * @return True on success, false on error + * @return bool True on success, false on error */ public function folder_subscribe($folder, $temp = false) { @@ -434,7 +434,7 @@ class kolab_storage_dav * @param string $folder Folder name * @param bool $temp Only remove temporary subscription * - * @return True on success, false on error + * @return bool True on success, false on error */ public function folder_unsubscribe($folder, $temp = false) { @@ -459,7 +459,7 @@ class kolab_storage_dav * * @param string $folder Folder name * - * @return True on success, false on error + * @return bool True on success, false on error */ public function folder_activate($folder) { @@ -471,7 +471,7 @@ class kolab_storage_dav * * @param string $folder Folder name * - * @return True on success, false on error + * @return bool True on success, false on error */ public function folder_deactivate($folder) { diff --git a/plugins/libkolab/lib/kolab_storage_dav_cache.php b/plugins/libkolab/lib/kolab_storage_dav_cache.php index 4c346cf2..5d0d192c 100644 --- a/plugins/libkolab/lib/kolab_storage_dav_cache.php +++ b/plugins/libkolab/lib/kolab_storage_dav_cache.php @@ -174,12 +174,12 @@ class kolab_storage_dav_cache extends kolab_storage_cache foreach ($objects as $dav_object) { if ($object = $this->folder->from_dav($dav_object)) { $object['_raw'] = $dav_object['data']; - $this->_extended_insert(false, $object); + $this->_extended_insert(0, $object); unset($object['_raw']); } } - $this->_extended_insert(true, null); + $this->_extended_insert(1, null); // check time limit and abort sync if running too long if (++$i % 25 == 0 && time() - $this->sync_start > $time_limit) { @@ -328,7 +328,6 @@ class kolab_storage_dav_cache extends kolab_storage_cache * * @param mixed $object Hash array with object properties to save or false to delete the cache entry * @param string $olduid Optional old message UID (for update) - * @param string $unused Unused (kept for compat. with the parent class) */ public function save($object, $olduid = null, $unused = null) { @@ -378,10 +377,7 @@ class kolab_storage_dav_cache extends kolab_storage_cache /** * Move an existing cache entry to a new resource * - * @param string $uid Entry's UID - * @param kolab_storage_folder $target Target storage folder instance - * @param string $unused1 Unused (kept for compat. with the parent class) - * @param string $unused2 Unused (kept for compat. with the parent class) + * @param string $uid Entry's UID */ public function move($uid, $target, $unused1 = null, $unused2 = null) { @@ -449,7 +445,7 @@ class kolab_storage_dav_cache extends kolab_storage_cache * * @param array $query Pseudo-SQL query as list of filter parameter triplets * - * @return int The number of objects of the given type + * @return int|null The number of objects of the given type, Null on error */ public function count($query = []) { @@ -501,8 +497,8 @@ class kolab_storage_dav_cache extends kolab_storage_cache /** * Write records into cache using extended inserts to reduce the number of queries to be executed * - * @param bool $force Set to false to commit buffered insert, true to force an insert - * @param array $object Kolab object to cache + * @param int $force Set to 0 to commit buffered insert, 1 to force an insert + * @param ?array $object Kolab object to cache */ protected function _extended_insert($force, $object) { diff --git a/plugins/libkolab/lib/kolab_storage_dav_folder.php b/plugins/libkolab/lib/kolab_storage_dav_folder.php index 227a7f86..85f39b7c 100644 --- a/plugins/libkolab/lib/kolab_storage_dav_folder.php +++ b/plugins/libkolab/lib/kolab_storage_dav_folder.php @@ -200,7 +200,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder /** * Helper method to extract folder UID * - * @return string Folder's UID + * @return string|null Folder's UID */ public function get_uid() { @@ -244,7 +244,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder * * @param bool $subscribed The desired subscription status: true = subscribed, false = not subscribed * - * @return True on success, false on error + * @return bool True on success, false on error */ public function subscribe($subscribed) { @@ -723,6 +723,8 @@ class kolab_storage_dav_folder extends kolab_storage_folder */ public function get_attachment($id, $event, $unused1 = null, $unused2 = false, $unused3 = null, $unused4 = false) { + /** @var array $event Overwrite type from the parent class */ + // Note: 'attachments' is defined when saving the data into the DAV server // '_attachments' is defined after fetching the object from the DAV server if (is_int($id) && isset($event['attachments'][$id])) { diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php index 34efb1c7..924429fe 100644 --- a/plugins/libkolab/lib/kolab_storage_folder.php +++ b/plugins/libkolab/lib/kolab_storage_folder.php @@ -148,7 +148,7 @@ class kolab_storage_folder extends kolab_storage_folder_api /** * Helper method to extract folder UID metadata * - * @return string Folder's UID + * @return string|null Folder's UID */ public function get_uid() { @@ -216,7 +216,7 @@ class kolab_storage_folder extends kolab_storage_folder_api * * @param bool $active The desired subscription status: true = active, false = not active * - * @return True on success, false on error + * @return bool True on success, false on error */ public function activate($active) { @@ -238,7 +238,7 @@ class kolab_storage_folder extends kolab_storage_folder_api * * @param bool $subscribed The desired subscription status: true = subscribed, false = not subscribed * - * @return True on success, false on error + * @return bool True on success, false on error */ public function subscribe($subscribed) { @@ -407,9 +407,10 @@ class kolab_storage_folder extends kolab_storage_folder_api if (substr($part, 0, 2) == 'i:') { // attachment data is stored in XML if ($object = $this->cache->get($msguid)) { + $object['_attachments'] = []; + // load data from XML (attachment content is not stored in cache) - if ($object['_formatobj'] && isset($object['_size'])) { - $object['_attachments'] = []; + if (isset($object['_formatobj']) && isset($object['_size'])) { $object['_formatobj']->get_attachments($object); } diff --git a/plugins/libkolab/lib/kolab_storage_folder_api.php b/plugins/libkolab/lib/kolab_storage_folder_api.php index 42b50917..cfc65710 100644 --- a/plugins/libkolab/lib/kolab_storage_folder_api.php +++ b/plugins/libkolab/lib/kolab_storage_folder_api.php @@ -323,12 +323,12 @@ abstract class kolab_storage_folder_api /** * Helper method to extract folder UID metadata * - * @return string Folder's UID + * @return string|null Folder's UID */ public function get_uid() { // To be implemented by extending classes - return false; + return null; } /** @@ -346,7 +346,7 @@ abstract class kolab_storage_folder_api * * @param bool $active The desired subscription status: true = active, false = not active * - * @return True on success, false on error + * @return bool True on success, false on error */ public function activate($active) { diff --git a/plugins/libkolab/lib/kolab_storage_folder_user.php b/plugins/libkolab/lib/kolab_storage_folder_user.php index 57e9e039..5f29b1e3 100644 --- a/plugins/libkolab/lib/kolab_storage_folder_user.php +++ b/plugins/libkolab/lib/kolab_storage_folder_user.php @@ -104,7 +104,7 @@ class kolab_storage_folder_user extends kolab_storage_folder_virtual * * @param bool $subscribed The desired subscription status: true = subscribed, false = not subscribed * - * @return True on success, false on error + * @return bool True on success, false on error */ public function subscribe($subscribed) { diff --git a/plugins/tasklist/drivers/caldav/tasklist_caldav_driver.php b/plugins/tasklist/drivers/caldav/tasklist_caldav_driver.php index aef961c7..273fd4ad 100644 --- a/plugins/tasklist/drivers/caldav/tasklist_caldav_driver.php +++ b/plugins/tasklist/drivers/caldav/tasklist_caldav_driver.php @@ -298,7 +298,7 @@ class tasklist_caldav_driver extends tasklist_driver * - color: The color of the list * - showalarms: True if alarms are enabled * - * @return mixed ID of the new list on success, False on error + * @return string|false ID of the new list on success, False on error */ public function create_list(&$prop) { @@ -723,7 +723,7 @@ class tasklist_caldav_driver extends tasklist_driver * @param mixed $prop UID string or hash array with task properties * @param mixed $rev Revision number * - * @return array Task object as hash array + * @return array|false Task object as hash array * @see tasklist_driver::get_task_revision() */ public function get_task_revison($prop, $rev) @@ -804,7 +804,7 @@ class tasklist_caldav_driver extends tasklist_driver * @param mixed $rev1 Revision: "from" * @param mixed $rev2 Revision: "to" * - * @return array List of property changes, each as a hash array + * @return array|false List of property changes, each as a hash array * @see tasklist_driver::get_task_diff() */ public function get_task_diff($prop, $rev1, $rev2) diff --git a/plugins/tasklist/drivers/database/tasklist_database_driver.php b/plugins/tasklist/drivers/database/tasklist_database_driver.php index 81475956..8d244636 100644 --- a/plugins/tasklist/drivers/database/tasklist_database_driver.php +++ b/plugins/tasklist/drivers/database/tasklist_database_driver.php @@ -109,7 +109,7 @@ class tasklist_database_driver extends tasklist_driver * * @param array $prop Hash array with list properties * - * @return mixed ID of the new list on success, False on error + * @return string|false ID of the new list on success, False on error * @see tasklist_driver::create_list() */ public function create_list(&$prop) @@ -137,7 +137,7 @@ class tasklist_database_driver extends tasklist_driver * * @param array $prop Hash array with list properties * - * @return bool True on success, Fales on failure + * @return bool|string True on success, Fales on failure * @see tasklist_driver::edit_list() */ public function edit_list(&$prop) @@ -152,7 +152,7 @@ class tasklist_database_driver extends tasklist_driver $this->rc->user->ID ); - return $this->db->affected_rows($query); + return $this->db->affected_rows($query) > 0; } /** @@ -366,12 +366,12 @@ class tasklist_database_driver extends tasklist_driver * @param int $filter Bitmask defining filter criterias. * See FILTER_* constants for possible values. * - * @return array Hash array with task properties or false if not found + * @return array|false Hash array with task properties or false if not found */ public function get_task($prop, $filter = 0) { if (is_string($prop)) { - $prop['uid'] = $prop; + $prop = ['uid' => $prop]; } $query_col = !empty($prop['id']) ? 'task_id' : 'uid'; diff --git a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php index e2d5bd49..1b6814e8 100644 --- a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php +++ b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php @@ -355,7 +355,7 @@ class tasklist_kolab_driver extends tasklist_driver * color: The color of the list * showalarms: True if alarms are enabled * - * @return mixed ID of the new list on success, False on error + * @return string|false ID of the new list on success, False on error */ public function create_list(&$prop) { @@ -436,7 +436,9 @@ class tasklist_kolab_driver extends tasklist_driver $prop['_reload'] = true; } - return $id; + $list['id'] = $id; + + return true; } return false; @@ -709,7 +711,7 @@ class tasklist_kolab_driver extends tasklist_driver * @param int $filter Bitmask defining filter criterias for folders. * See FILTER_* constants for possible values. * - * @return array Hash array with task properties or false if not found + * @return array|false Hash array with task properties or false if not found */ public function get_task($prop, $filter = 0) { @@ -734,7 +736,7 @@ class tasklist_kolab_driver extends tasklist_driver } } - return $this->tasks[$id]; + return $this->tasks[$id] ?? false; } /** @@ -788,7 +790,7 @@ class tasklist_kolab_driver extends tasklist_driver * * @param array $prop Hash array with task properties * - * @return array List of changes, each as a hash array + * @return array|false List of changes, each as a hash array * @see tasklist_driver::get_task_changelog() */ public function get_task_changelog($prop) @@ -813,7 +815,7 @@ class tasklist_kolab_driver extends tasklist_driver * @param mixed $prop UID string or hash array with task properties * @param mixed $rev Revision number * - * @return array Task object as hash array + * @return array|false Task object as hash array * @see tasklist_driver::get_task_revision() */ public function get_task_revison($prop, $rev) @@ -892,7 +894,7 @@ class tasklist_kolab_driver extends tasklist_driver * @param mixed $rev1 Revision "from" * @param mixed $rev2 Revision "to" * - * @return array List of property changes, each as a hash array + * @return array|false List of property changes, each as a hash array * @see tasklist_driver::get_task_diff() */ public function get_task_diff($prop, $rev1, $rev2) diff --git a/plugins/tasklist/drivers/tasklist_driver.php b/plugins/tasklist/drivers/tasklist_driver.php index c166f399..e7c42d73 100644 --- a/plugins/tasklist/drivers/tasklist_driver.php +++ b/plugins/tasklist/drivers/tasklist_driver.php @@ -104,7 +104,7 @@ abstract class tasklist_driver * color: The color of the list * showalarms: True if alarms are enabled * - * @return mixed ID of the new list on success, False on error + * @return string|false ID of the new list on success, False on error */ abstract public function create_list(&$prop); @@ -218,7 +218,7 @@ abstract class tasklist_driver * @param int $filter Bitmask defining filter criterias for folders. * See FILTER_* constants for possible values. * - * @return array Hash array with task properties or false if not found + * @return array|false Hash array with task properties or false if not found */ abstract public function get_task($prop, $filter = 0); @@ -329,7 +329,7 @@ abstract class tasklist_driver * referencing a mail message. * @param string $folder IMAP folder the message resides in * - * @return array An struct referencing the given IMAP message + * @return array|false A struct referencing the given IMAP message */ public function get_message_reference($uri_or_headers, $folder = null) { @@ -371,7 +371,7 @@ abstract class tasklist_driver * id: Task identifier * list: List identifier * - * @return array List of changes, each as a hash array: + * @return array|false List of changes, each as a hash array: * rev: Revision number * type: Type of the change (create, update, move, delete) * date: Change date @@ -393,7 +393,7 @@ abstract class tasklist_driver * @param mixed $rev1 Old Revision * @param mixed $rev2 New Revision * - * @return array List of property changes, each as a hash array: + * @return array|false List of property changes, each as a hash array: * property: Revision number * old: Old property value * new: Updated property value @@ -411,7 +411,7 @@ abstract class tasklist_driver * list: List identifier * @param mixed $rev Revision number * - * @return array Task object as hash array + * @return array|false Task object as hash array * @see self::get_task() */ public function get_task_revison($task, $rev) diff --git a/plugins/tasklist/tasklist.php b/plugins/tasklist/tasklist.php index 5e826146..6b143fb5 100644 --- a/plugins/tasklist/tasklist.php +++ b/plugins/tasklist/tasklist.php @@ -1026,7 +1026,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 += (array)$jsenv[$insert_id]; + $list += $jsenv[$insert_id] ?? []; } $this->rc->output->command('plugin.insert_tasklist', $list); $success = true; @@ -1034,11 +1034,9 @@ class tasklist extends rcube_plugin break; case 'edit': - if ($newid = $this->driver->edit_list($list)) { - $list['oldid'] = $list['id']; - $list['id'] = $newid; + $list['oldid'] = $list['id']; + if ($success = $this->driver->edit_list($list)) { $this->rc->output->command('plugin.update_tasklist', $list); - $success = true; } break; @@ -1065,7 +1063,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 += (array)$jsenv[$id]; + $prop += $jsenv[$id] ?? []; $prop['editname'] = $editname; $prop['html'] = $html;