PHPStan Level:3

This commit is contained in:
Aleksander Machniak 2024-01-29 13:53:48 +01:00
parent 2103cc317d
commit 198376f46c
42 changed files with 183 additions and 173 deletions

View file

@ -29,7 +29,7 @@ parameters:
paths: paths:
- plugins - plugins
level: 2 level: 3
scanDirectories: scanDirectories:
- program/include - program/include

View file

@ -1036,7 +1036,7 @@ $("#rcmfd_new_category").keypress(function(event) {
// let the UI generate HTML and CSS representation for this calendar // let the UI generate HTML and CSS representation for this calendar
$html = $this->ui->calendar_list_item($id, $prop, $jsenv); $html = $this->ui->calendar_list_item($id, $prop, $jsenv);
$cal = $jsenv[$id]; $cal = $jsenv[$id] ?? [];
$cal['editname'] = $editname; $cal['editname'] = $editname;
$cal['html'] = $html; $cal['html'] = $html;

View file

@ -450,7 +450,7 @@ class caldav_calendar extends kolab_storage_dav_folder
$this->events = [$event['uid'] => $this->_to_driver_event($object, true)]; $this->events = [$event['uid'] => $this->_to_driver_event($object, true)];
return true; return $saved;
} }
/** /**

View file

@ -99,6 +99,8 @@ class caldav_driver extends kolab_driver
/** /**
* Convert kolab_storage_folder into caldav_calendar * Convert kolab_storage_folder into caldav_calendar
*
* @return caldav_calendar|kolab_user_calendar
*/ */
protected function _to_calendar($folder) protected function _to_calendar($folder)
{ {
@ -278,7 +280,7 @@ class caldav_driver extends kolab_driver
* *
* @param string $id Calendar identifier * @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) public function get_calendar($id)
{ {

View file

@ -296,7 +296,7 @@ abstract class calendar_driver
* See FILTER_* constants for possible values. * See FILTER_* constants for possible values.
* @param bool $full If true, recurrence exceptions shall be added * @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); abstract public function get_event($event, $scope = 0, $full = false);
@ -420,11 +420,11 @@ abstract class calendar_driver
* id: Event identifier * id: Event identifier
* calendar: Calendar identifier * calendar: Calendar identifier
* *
* @return string Attachment body * @return string|false Attachment body
*/ */
public function get_attachment_body($id, $event) 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. * or an URI from a stored link referencing a mail message.
* @param string $folder IMAP folder the message resides in * @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) 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 $start Requested period start date/time as unix timestamp
* @param int $end Requested period end 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) public function get_freebusy_list($email, $start, $end)
{ {
@ -551,7 +551,7 @@ abstract class calendar_driver
* id: Event identifier * id: Event identifier
* calendar: Calendar 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 * rev: Revision number
* type: Type of the change (create, update, move, delete) * type: Type of the change (create, update, move, delete)
* date: Change date * date: Change date
@ -573,7 +573,7 @@ abstract class calendar_driver
* @param mixed $rev1 Old Revision * @param mixed $rev1 Old Revision
* @param mixed $rev2 New 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 * property: Revision number
* old: Old property value * old: Old property value
* new: Updated property value * new: Updated property value
@ -591,7 +591,7 @@ abstract class calendar_driver
* calendar: Calendar identifier * calendar: Calendar identifier
* @param mixed $rev Revision number * @param mixed $rev Revision number
* *
* @return array Event object as hash array * @return array|false Event object as hash array
* @see self::get_event() * @see self::get_event()
*/ */
public function get_event_revison($event, $rev) public function get_event_revison($event, $rev)
@ -608,7 +608,7 @@ abstract class calendar_driver
* calendar: Calendar identifier * calendar: Calendar identifier
* @param mixed $rev Revision number * @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) public function restore_event_revision($event, $rev)
{ {
@ -794,7 +794,7 @@ abstract class calendar_driver
public static function parse_contact($contact, $source) public static function parse_contact($contact, $source)
{ {
if (!is_array($contact)) { if (!is_array($contact)) {
return; return null;
} }
if (!empty($contact['birthday']) && is_array($contact['birthday'])) { if (!empty($contact['birthday']) && is_array($contact['birthday'])) {
@ -802,7 +802,7 @@ abstract class calendar_driver
} }
if (empty($contact['birthday'])) { if (empty($contact['birthday'])) {
return; return null;
} }
try { try {
@ -818,7 +818,7 @@ abstract class calendar_driver
true, true,
false false
); );
return; return null;
} }
$rcmail = rcmail::get_instance(); $rcmail = rcmail::get_instance();

View file

@ -1017,7 +1017,7 @@ class database_driver extends calendar_driver
* @param int $scope Bitmask defining the scope to search events in * @param int $scope Bitmask defining the scope to search events in
* @param bool $full If true, recurrence exceptions shall be added * @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) public function get_event($event, $scope = 0, $full = false)
{ {
@ -1072,7 +1072,7 @@ class database_driver extends calendar_driver
return $this->cache[$id]; return $this->cache[$id];
} }
return false; return null;
} }
/** /**

View file

@ -352,7 +352,7 @@ class kolab_driver extends calendar_driver
* *
* @param string $id Calendar identifier (encoded imap folder name) * @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) public function get_calendar($id)
{ {
@ -585,7 +585,7 @@ class kolab_driver extends calendar_driver
* Fetch a single event * Fetch a single event
* *
* @see calendar_driver::get_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) 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) public function list_attachments($event)
{ {
if (!($storage = $this->get_calendar($event['calendar']))) { if (!($storage = $this->get_calendar($event['calendar']))) {
return false; return [];
} }
$event = $storage->get_event($event['id']); $event = $storage->get_event($event['id']);
@ -2260,7 +2260,7 @@ class kolab_driver extends calendar_driver
* *
* @param array $event Hash array with event properties * @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() * @see calendar_driver::get_event_changelog()
*/ */
public function get_event_changelog($event) public function get_event_changelog($event)
@ -2286,7 +2286,7 @@ class kolab_driver extends calendar_driver
* @param mixed $rev1 Old Revision * @param mixed $rev1 Old Revision
* @param mixed $rev2 New 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() * @see calendar_driver::get_event_diff()
*/ */
public function get_event_diff($event, $rev1, $rev2) 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 array $event Hash array with event properties
* @param mixed $rev Revision number * @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() * @see calendar_driver::get_event_revison()
*/ */
public function get_event_revison($event, $rev, $internal = false) public function get_event_revison($event, $rev, $internal = false)

View file

@ -118,7 +118,7 @@ class kolab_invitation_calendar
/** /**
* Getter for the Cyrus mailbox identifier corresponding to this folder * Getter for the Cyrus mailbox identifier corresponding to this folder
* *
* @return string Mailbox ID * @return ?string Mailbox ID
*/ */
public function get_mailbox_id() public function get_mailbox_id()
{ {

View file

@ -63,7 +63,7 @@ class resources_driver_ldap extends resources_driver
$results = $ldap->list_records(); $results = $ldap->list_records();
} }
if ($results instanceof ArrayAccess) { if ($results instanceof Iterator) {
foreach ($results as $i => $rec) { foreach ($results as $i => $rec) {
$results[$i] = $this->decode_resource($rec); $results[$i] = $this->decode_resource($rec);
} }

View file

@ -59,7 +59,7 @@ abstract class resources_driver
* *
* @param string $id Owner identifier * @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) public function get_resource_owner($id)
{ {

View file

@ -142,7 +142,7 @@ class calendar_itip extends libcalendaring_itip
* @param array $event Hash array with event properties * @param array $event Hash array with event properties
* @param string $attendee Attendee email address * @param string $attendee Attendee email address
* *
* @return string Invitation token * @return string|false Invitation token
*/ */
public function store_invitation($event, $attendee) public function store_invitation($event, $attendee)
{ {

View file

@ -336,7 +336,7 @@ class kolab_2fa extends rcube_plugin
* Load driver class for the given authentication factor * Load driver class for the given authentication factor
* *
* @param string $factor Factor identifier (<method>:<id>) * @param string $factor Factor identifier (<method>:<id>)
* @return Kolab2FA\Driver\Base * @return Kolab2FA\Driver\Base|false
*/ */
public function get_driver($factor) public function get_driver($factor)
{ {

View file

@ -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 int $subset Only return this number of records, use negative values for tail
* @param bool $nocount True to skip the count query (select only) * @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) 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 string $gid Group identifier
* @param array $ids List of contact identifiers to be removed * @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) public function remove_from_group($gid, $ids)
{ {
@ -1013,7 +1013,7 @@ class carddav_contacts extends rcube_addressbook
$list = $this->distlists[$gid]; $list = $this->distlists[$gid];
if (!$list) { if (!$list) {
return false; return 0;
} }
if (!is_array($ids)) { if (!is_array($ids)) {
@ -1021,9 +1021,12 @@ class carddav_contacts extends rcube_addressbook
} }
$new_member = []; $new_member = [];
$removed = 0;
foreach ((array) $list['member'] as $member) { foreach ((array) $list['member'] as $member) {
if (!in_array($member['ID'], $ids)) { if (!in_array($member['ID'], $ids)) {
$new_member[] = $member; $new_member[] = $member;
} else {
$removed++;
} }
} }
@ -1040,19 +1043,19 @@ class carddav_contacts extends rcube_addressbook
true, true,
false 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 0;
return true;
} }
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;
} }
/** /**

View file

@ -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 int $subset Only return this number of records, use negative values for tail
* @param bool $nocount True to skip the count query (select only) * @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) public function list_records($cols = null, $subset = 0, $nocount = false)
{ {
@ -877,6 +877,7 @@ class kolab_contacts extends rcube_addressbook
); );
return false; return false;
} else { } else {
// @phpstan-ignore-next-line FIXME: this one might be valid error
$id = $this->uid2id($list['uid']); $id = $this->uid2id($list['uid']);
$this->distlists[$id] = $list; $this->distlists[$id] = $list;
$result = ['id' => $id, 'name' => $name]; $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 $newname New name to set for this group
* @param string $newid New group identifier (if changed, otherwise don't set) * @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) public function rename_group($gid, $newname, &$newid)
{ {
@ -1019,7 +1020,7 @@ class kolab_contacts extends rcube_addressbook
false false
); );
$added = false; $added = 0;
$this->set_error(self::ERROR_SAVING, 'errorsaving'); $this->set_error(self::ERROR_SAVING, 'errorsaving');
} else { } else {
$this->distlists[$gid] = $list; $this->distlists[$gid] = $list;
@ -1044,13 +1045,17 @@ class kolab_contacts extends rcube_addressbook
$this->_fetch_groups(); $this->_fetch_groups();
if (!($list = $this->distlists[$gid])) { if (!($list = $this->distlists[$gid])) {
return false; return 0;
} }
$new_member = []; $new_member = [];
$removed = 0;
foreach ((array)$list['member'] as $member) { foreach ((array)$list['member'] as $member) {
if (!in_array($member['ID'], $ids)) { if (!in_array($member['ID'], $ids)) {
$new_member[] = $member; $new_member[] = $member;
} else {
$removed++;
} }
} }
@ -1067,17 +1072,19 @@ class kolab_contacts extends rcube_addressbook
true, true,
false false
); );
} else {
// remove group assigments in local cache return 0;
foreach ($ids as $id) {
$j = array_search($gid, $this->groupmembers[$id]);
unset($this->groupmembers[$id][$j]);
}
$this->distlists[$gid] = $list;
return true;
} }
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;
} }
/** /**

View file

@ -97,7 +97,7 @@ class kolab_contacts_driver
$folder = kolab_storage::get_folder($folderId); $folder = kolab_storage::get_folder($folderId);
if ($folder && kolab_storage::folder_delete($folder->name)) { if ($folder && kolab_storage::folder_delete($folder->name)) {
return $folderId; return true;
} }
return false; return false;

View file

@ -1022,7 +1022,7 @@ class kolab_addressbook extends rcube_plugin
{ {
$source = trim(rcube_utils::get_input_value('_source', rcube_utils::INPUT_GPC, true)); $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(); $storage = $this->rc->get_storage();
$delimiter = $storage->get_hierarchy_delimiter(); $delimiter = $storage->get_hierarchy_delimiter();

View file

@ -266,7 +266,7 @@ class kolab_chat_mattermost
/** /**
* Returns the Mattermost channels list for the user * 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() protected function get_channels_list()
{ {

View file

@ -449,11 +449,11 @@ class kolab_delegation_engine
$user = $this->parse_ldap_record($record); $user = $this->parse_ldap_record($record);
if ($user['uid']) { if ($uid = $user['uid']) {
$display = rcube_addressbook::compose_search_name($record); $display = rcube_addressbook::compose_search_name($record);
$user = ['name' => $user['uid'], 'display' => $display]; $user = ['name' => $uid, 'display' => $display];
$users[] = $user; $users[] = $user;
$keys[] = $display ?: $user['uid']; $keys[] = $display ?: $uid;
} }
} }

View file

@ -578,7 +578,7 @@ class kolab_folders extends rcube_plugin
* *
* @param string $type Folder type * @param string $type Folder type
* *
* @return string Folder name * @return ?string Folder name
*/ */
public function get_default_folder($type) public function get_default_folder($type)
{ {

View file

@ -892,7 +892,7 @@ class kolab_notes extends rcube_plugin
* *
* @param array $note Hash array with note properties * @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) 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 $note UID string or hash array with note properties
* @param mixed $rev Revision number * @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) public function get_revison($note, $rev)
{ {
@ -949,7 +949,7 @@ class kolab_notes extends rcube_plugin
* @param mixed $rev1 Revision: "from" * @param mixed $rev1 Revision: "from"
* @param mixed $rev2 Revision: "to" * @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) 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. * Command the backend to restore a certain revision of a note.
* This shall replace the current object with an older version. * This shall replace the current object with an older version.
* *
* @param array $note Hash array with note properties (id, list) * @param array $note Hash array with note properties (id, list)
* @param mixed $rev Revision number * @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) 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 // let the UI generate HTML and CSS representation for this calendar
$html = $this->ui->folder_list_item($id, $prop, $jsenv, true); $html = $this->ui->folder_list_item($id, $prop, $jsenv, true);
$prop += (array)$jsenv[$id]; $prop += $jsenv[$id] ?? [];
$prop['editname'] = $editname; $prop['editname'] = $editname;
$prop['html'] = $html; $prop['html'] = $html;

View file

@ -958,14 +958,13 @@ class libcalendaring_itip
return $table->show(); return $table->show();
} }
/** /**
* Create iTIP invitation token for later replies via URL * Create iTIP invitation token for later replies via URL
* *
* @param array $event Hash array with event properties * @param array $event Hash array with event properties
* @param string $attendee Attendee email address * @param string $attendee Attendee email address
* *
* @return string Invitation token * @return string|false Invitation token
*/ */
public function store_invitation($event, $attendee) public function store_invitation($event, $attendee)
{ {
@ -981,7 +980,6 @@ class libcalendaring_itip
public function cancel_itip_invitation($event) public function cancel_itip_invitation($event)
{ {
// empty stub // empty stub
return false;
} }
/** /**

View file

@ -153,7 +153,7 @@ class libcalendaring_recurrence
{ {
// recurrence end date is given // recurrence end date is given
if (isset($this->recurrence['UNTIL']) && $this->recurrence['UNTIL'] instanceof DateTimeInterface) { 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 // Run through all items till we reach the end, or limit of iterations
@ -165,12 +165,13 @@ class libcalendaring_recurrence
} catch (Exception $e) { } catch (Exception $e) {
// do nothing // do nothing
} }
/* /*
if (empty($end) && isset($this->event['start']) && $this->event['start'] instanceof DateTimeInterface) { if (empty($end) && isset($this->event['start']) && $this->event['start'] instanceof DateTimeInterface) {
// determine a reasonable end date if none given // determine a reasonable end date if none given
$end = clone $this->event['start']; $end = clone $this->event['start'];
$end->add(new DateInterval('P100Y')); $end->add(new DateInterval('P100Y'));
} }
*/ */
return isset($end) ? $this->toDateTime($end) : false; return isset($end) ? $this->toDateTime($end) : false;

View file

@ -314,7 +314,7 @@ class libcalendaring_vcalendar implements Iterator
/** /**
* Import objects from an already parsed Sabre\VObject\Component object * 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 * @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 * 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 * @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 $utc Set as UTC date
* @param bool $dateonly Set as VALUE=DATE property * @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) 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; return $params;
} }
/** /**
* Export events to iCalendar format * 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 ?callable $get_attachment Optional callback function to fetch attachment contents
* @param bool $with_timezones Add VTIMEZONE block with timezone definitions for the included events * @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) 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) { if ($write) {
echo "END:VCALENDAR\r\n"; echo "END:VCALENDAR\r\n";
return true; return true;
} else {
return $vcal->serialize();
} }
return $vcal->serialize();
} }
/** /**
@ -1067,7 +1066,7 @@ class libcalendaring_vcalendar implements Iterator
* @param array $object Event * @param array $object Event
* @param ?callable $get_attachment Optional callback function to fetch attachment contents * @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) 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 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 $from Unix timestamp with first date/time in this timezone
* @param int $to Unix timestap with last 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 * @return VObject\Component|false Object representing a VTIMEZONE definition
* or false if no timezone information is available * or false if no timezone information is available
*/ */
public static function get_vtimezone($tzid, $from = 0, $to = 0, $cal = null) 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) { if (empty($this->objects[$this->iteratorkey]) && $this->fp) {
$this->_parse_next(true); $this->_parse_next(true);
} }
return $this->valid();
} }
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
@ -1567,7 +1564,6 @@ class libcalendaring_vcalendar implements Iterator
{ {
return !empty($this->objects[$this->iteratorkey]); return !empty($this->objects[$this->iteratorkey]);
} }
} }

View file

@ -720,7 +720,7 @@ class libcalendaring extends rcube_plugin
try { try {
$interval = new DateInterval(trim($alarm['trigger'], '+-')); $interval = new DateInterval(trim($alarm['trigger'], '+-'));
$interval->invert = $alarm['trigger'][0] == '-'; $interval->invert = $alarm['trigger'][0] == '-' ? 1 : 0;
$notify_time = clone $refdate; $notify_time = clone $refdate;
$notify_time->add($interval); $notify_time->add($interval);
} catch (Exception $e) { } 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 $mime_id Message part ID and object index (e.g. '1.2:0')
* @param string $type Object type filter (optional) * @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) public function mail_get_itip_object($mbox, $uid, $mime_id, $type = null)
{ {

View file

@ -160,9 +160,12 @@ class kolab_bonnie_api_client
/** /**
* Do the HTTP request * 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 { try {
$payload_ = json_encode($payload); $payload_ = json_encode($payload);
@ -175,6 +178,7 @@ class kolab_bonnie_api_client
} }
$this->_debug('REQUEST', $payload, $this->headers); $this->_debug('REQUEST', $payload, $this->headers);
$request = libkolab::http_request($this->url, 'POST', ['timeout' => $this->timeout]); $request = libkolab::http_request($this->url, 'POST', ['timeout' => $this->timeout]);
$request->setHeader($this->headers); $request->setHeader($this->headers);
$request->setAuth($this->username, $this->password); $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 ['id' => $payload['id'], 'error' => $e->getMessage(), 'code' => -32000];
} }
return is_array($result) ? $result : []; return isset($result) && is_array($result) ? $result : [];
} }
/** /**

View file

@ -133,7 +133,7 @@ class kolab_date_recurrence
/** /**
* Get the end date of the last occurence of this recurrence cycle * 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() public function end()
{ {

View file

@ -283,7 +283,7 @@ abstract class kolab_format
* @param cDateTime $cdt The libkolabxml datetime object * @param cDateTime $cdt The libkolabxml datetime object
* @param DateTimeZone $dest_tz The timezone to convert the date to * @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) public static function php_datetime($cdt, $dest_tz = null)
{ {
@ -463,7 +463,7 @@ abstract class kolab_format
* *
* @param float $v Version value to convert * @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) protected function libversion($v = null)
{ {

View file

@ -301,12 +301,12 @@ class kolab_ldap extends rcube_ldap_generic
* *
* @param string $dn DN * @param string $dn DN
* *
* @return array Record data * @return array|null Record data
*/ */
public function get_record($dn) public function get_record($dn)
{ {
if (!$this->ready) { if (!$this->ready) {
return; return null;
} }
if ($rec = $this->get_entry($dn, $this->attributes)) { if ($rec = $this->get_entry($dn, $this->attributes)) {

View file

@ -190,7 +190,7 @@ class kolab_storage
* *
* @param string $type Data type to list folders for (contact,distribution-list,event,task,note) * @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) 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 $folder IMAP folder to access (UTF7-IMAP)
* @param string $type Expected folder type * @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) public static function get_folder($folder, $type = null)
{ {
@ -223,7 +223,7 @@ class kolab_storage
* @param string $uid Object UID * @param string $uid Object UID
* @param string $type Object type (contact,event,task,journal,file,note,configuration) * @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) 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 = []) public static function list_folders($root = '', $mbox = '*', $filter = null, $subscribed = null, &$folderdata = [])
{ {
if (!self::setup()) { if (!self::setup()) {
return null; return [];
} }
// use IMAP subscriptions // use IMAP subscriptions
@ -1192,7 +1192,7 @@ class kolab_storage
* *
* @param string $folder Folder name (UTF7-IMAP) * @param string $folder Folder name (UTF7-IMAP)
* *
* @return string Folder type * @return string|null Folder type
*/ */
public static function folder_type($folder) public static function folder_type($folder)
{ {
@ -1412,12 +1412,12 @@ class kolab_storage
* @param string $type Folder type * @param string $type Folder type
* @param array $props Folder properties (color, etc) * @param array $props Folder properties (color, etc)
* *
* @return string Folder name * @return string|null Folder name
*/ */
public static function create_default_folder($type, $props = []) public static function create_default_folder($type, $props = [])
{ {
if (!self::setup()) { if (!self::setup()) {
return; return null;
} }
$folders = self::$imap->get_metadata('*', [kolab_storage::CTYPE_KEY_PRIVATE]); $folders = self::$imap->get_metadata('*', [kolab_storage::CTYPE_KEY_PRIVATE]);
@ -1442,7 +1442,7 @@ class kolab_storage
} }
if (!$default_name) { if (!$default_name) {
return; return null;
} }
$folder = rcube_charset::convert($default_name, RCUBE_CHARSET, 'UTF7-IMAP'); $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->folder_exists($folder)) {
if (!self::$imap->create_folder($folder)) { if (!self::$imap->create_folder($folder)) {
return; return null;
} }
} }

View file

@ -1011,7 +1011,7 @@ class kolab_storage_cache
* @param string $type Requested object type or * for all * @param string $type Requested object type or * for all
* @param string $folder IMAP folder to read from * @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) 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 * 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 int $msguid Message UID. Set 0 to commit buffered inserts
* @param array $object Kolab object to cache * @param ?array $object Kolab object to cache
*/ */
protected function _extended_insert($msguid, $object) protected function _extended_insert($msguid, $object)
{ {

View file

@ -276,7 +276,7 @@ class kolab_storage_config
* *
* @param string|array $params Object UUID or Message folder, UID, Search headers (Message-Id, Date) * @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) public static function build_member_url($params)
{ {
@ -348,7 +348,7 @@ class kolab_storage_config
* *
* @param string $url Member URI * @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) public static function parse_member_url($url)
{ {
@ -570,12 +570,12 @@ class kolab_storage_config
* @param array $records List of kolab objects * @param array $records List of kolab objects
* @param bool $no_return Don't return anything * @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) public function apply_tags(&$records, $no_return = false)
{ {
if (empty($records) && $no_return) { if (empty($records) && $no_return) {
return; return null;
} }
// first convert categories into tags // first convert categories into tags

View file

@ -113,7 +113,7 @@ class kolab_storage_dav
* @param string $uid Object UID * @param string $uid Object UID
* @param string $type Object type (contact,event,task,journal,file,note,configuration) * @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) public function get_object($uid, $type)
{ {
@ -312,7 +312,7 @@ class kolab_storage_dav
public function folder_selector($type, $attrs, $current = '') public function folder_selector($type, $attrs, $current = '')
{ {
// TODO // TODO
return null; return null; // @phpstan-ignore-line
} }
/** /**
@ -420,7 +420,7 @@ class kolab_storage_dav
* @param string $folder Folder name * @param string $folder Folder name
* @param bool $temp Only subscribe temporarily for the current session * @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) public function folder_subscribe($folder, $temp = false)
{ {
@ -434,7 +434,7 @@ class kolab_storage_dav
* @param string $folder Folder name * @param string $folder Folder name
* @param bool $temp Only remove temporary subscription * @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) public function folder_unsubscribe($folder, $temp = false)
{ {
@ -459,7 +459,7 @@ class kolab_storage_dav
* *
* @param string $folder Folder name * @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) public function folder_activate($folder)
{ {
@ -471,7 +471,7 @@ class kolab_storage_dav
* *
* @param string $folder Folder name * @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) public function folder_deactivate($folder)
{ {

View file

@ -174,12 +174,12 @@ class kolab_storage_dav_cache extends kolab_storage_cache
foreach ($objects as $dav_object) { foreach ($objects as $dav_object) {
if ($object = $this->folder->from_dav($dav_object)) { if ($object = $this->folder->from_dav($dav_object)) {
$object['_raw'] = $dav_object['data']; $object['_raw'] = $dav_object['data'];
$this->_extended_insert(false, $object); $this->_extended_insert(0, $object);
unset($object['_raw']); unset($object['_raw']);
} }
} }
$this->_extended_insert(true, null); $this->_extended_insert(1, null);
// check time limit and abort sync if running too long // check time limit and abort sync if running too long
if (++$i % 25 == 0 && time() - $this->sync_start > $time_limit) { 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 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 $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) 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 * Move an existing cache entry to a new resource
* *
* @param string $uid Entry's UID * @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)
*/ */
public function move($uid, $target, $unused1 = null, $unused2 = null) 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 * @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 = []) 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 * 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 int $force Set to 0 to commit buffered insert, 1 to force an insert
* @param array $object Kolab object to cache * @param ?array $object Kolab object to cache
*/ */
protected function _extended_insert($force, $object) protected function _extended_insert($force, $object)
{ {

View file

@ -200,7 +200,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder
/** /**
* Helper method to extract folder UID * Helper method to extract folder UID
* *
* @return string Folder's UID * @return string|null Folder's UID
*/ */
public function get_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 * @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) 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) 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 // Note: 'attachments' is defined when saving the data into the DAV server
// '_attachments' is defined after fetching the object from the DAV server // '_attachments' is defined after fetching the object from the DAV server
if (is_int($id) && isset($event['attachments'][$id])) { if (is_int($id) && isset($event['attachments'][$id])) {

View file

@ -148,7 +148,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
/** /**
* Helper method to extract folder UID metadata * Helper method to extract folder UID metadata
* *
* @return string Folder's UID * @return string|null Folder's UID
*/ */
public function get_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 * @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) 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 * @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) public function subscribe($subscribed)
{ {
@ -407,9 +407,10 @@ class kolab_storage_folder extends kolab_storage_folder_api
if (substr($part, 0, 2) == 'i:') { if (substr($part, 0, 2) == 'i:') {
// attachment data is stored in XML // attachment data is stored in XML
if ($object = $this->cache->get($msguid)) { if ($object = $this->cache->get($msguid)) {
$object['_attachments'] = [];
// load data from XML (attachment content is not stored in cache) // load data from XML (attachment content is not stored in cache)
if ($object['_formatobj'] && isset($object['_size'])) { if (isset($object['_formatobj']) && isset($object['_size'])) {
$object['_attachments'] = [];
$object['_formatobj']->get_attachments($object); $object['_formatobj']->get_attachments($object);
} }

View file

@ -323,12 +323,12 @@ abstract class kolab_storage_folder_api
/** /**
* Helper method to extract folder UID metadata * Helper method to extract folder UID metadata
* *
* @return string Folder's UID * @return string|null Folder's UID
*/ */
public function get_uid() public function get_uid()
{ {
// To be implemented by extending classes // 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 * @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) public function activate($active)
{ {

View file

@ -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 * @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) public function subscribe($subscribed)
{ {

View file

@ -298,7 +298,7 @@ class tasklist_caldav_driver extends tasklist_driver
* - color: The color of the list * - color: The color of the list
* - showalarms: True if alarms are enabled * - 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) 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 $prop UID string or hash array with task properties
* @param mixed $rev Revision number * @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() * @see tasklist_driver::get_task_revision()
*/ */
public function get_task_revison($prop, $rev) 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 $rev1 Revision: "from"
* @param mixed $rev2 Revision: "to" * @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() * @see tasklist_driver::get_task_diff()
*/ */
public function get_task_diff($prop, $rev1, $rev2) public function get_task_diff($prop, $rev1, $rev2)

View file

@ -109,7 +109,7 @@ class tasklist_database_driver extends tasklist_driver
* *
* @param array $prop Hash array with list properties * @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() * @see tasklist_driver::create_list()
*/ */
public function create_list(&$prop) public function create_list(&$prop)
@ -137,7 +137,7 @@ class tasklist_database_driver extends tasklist_driver
* *
* @param array $prop Hash array with list properties * @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() * @see tasklist_driver::edit_list()
*/ */
public function edit_list(&$prop) public function edit_list(&$prop)
@ -152,7 +152,7 @@ class tasklist_database_driver extends tasklist_driver
$this->rc->user->ID $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. * @param int $filter Bitmask defining filter criterias.
* See FILTER_* constants for possible values. * 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) public function get_task($prop, $filter = 0)
{ {
if (is_string($prop)) { if (is_string($prop)) {
$prop['uid'] = $prop; $prop = ['uid' => $prop];
} }
$query_col = !empty($prop['id']) ? 'task_id' : 'uid'; $query_col = !empty($prop['id']) ? 'task_id' : 'uid';

View file

@ -355,7 +355,7 @@ class tasklist_kolab_driver extends tasklist_driver
* color: The color of the list * color: The color of the list
* showalarms: True if alarms are enabled * 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) public function create_list(&$prop)
{ {
@ -436,7 +436,9 @@ class tasklist_kolab_driver extends tasklist_driver
$prop['_reload'] = true; $prop['_reload'] = true;
} }
return $id; $list['id'] = $id;
return true;
} }
return false; return false;
@ -709,7 +711,7 @@ class tasklist_kolab_driver extends tasklist_driver
* @param int $filter Bitmask defining filter criterias for folders. * @param int $filter Bitmask defining filter criterias for folders.
* See FILTER_* constants for possible values. * 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) 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 * @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() * @see tasklist_driver::get_task_changelog()
*/ */
public function get_task_changelog($prop) 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 $prop UID string or hash array with task properties
* @param mixed $rev Revision number * @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() * @see tasklist_driver::get_task_revision()
*/ */
public function get_task_revison($prop, $rev) 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 $rev1 Revision "from"
* @param mixed $rev2 Revision "to" * @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() * @see tasklist_driver::get_task_diff()
*/ */
public function get_task_diff($prop, $rev1, $rev2) public function get_task_diff($prop, $rev1, $rev2)

View file

@ -104,7 +104,7 @@ abstract class tasklist_driver
* color: The color of the list * color: The color of the list
* showalarms: True if alarms are enabled * 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); abstract public function create_list(&$prop);
@ -218,7 +218,7 @@ abstract class tasklist_driver
* @param int $filter Bitmask defining filter criterias for folders. * @param int $filter Bitmask defining filter criterias for folders.
* See FILTER_* constants for possible values. * 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); abstract public function get_task($prop, $filter = 0);
@ -329,7 +329,7 @@ abstract class tasklist_driver
* referencing a mail message. * referencing a mail message.
* @param string $folder IMAP folder the message resides in * @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) public function get_message_reference($uri_or_headers, $folder = null)
{ {
@ -371,7 +371,7 @@ abstract class tasklist_driver
* id: Task identifier * id: Task identifier
* list: List 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 * rev: Revision number
* type: Type of the change (create, update, move, delete) * type: Type of the change (create, update, move, delete)
* date: Change date * date: Change date
@ -393,7 +393,7 @@ abstract class tasklist_driver
* @param mixed $rev1 Old Revision * @param mixed $rev1 Old Revision
* @param mixed $rev2 New 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 * property: Revision number
* old: Old property value * old: Old property value
* new: Updated property value * new: Updated property value
@ -411,7 +411,7 @@ abstract class tasklist_driver
* list: List identifier * list: List identifier
* @param mixed $rev Revision number * @param mixed $rev Revision number
* *
* @return array Task object as hash array * @return array|false Task object as hash array
* @see self::get_task() * @see self::get_task()
*/ */
public function get_task_revison($task, $rev) public function get_task_revison($task, $rev)

View file

@ -1026,7 +1026,7 @@ class tasklist extends rcube_plugin
if (empty($list['_reload'])) { if (empty($list['_reload'])) {
$this->load_ui(); $this->load_ui();
$list['html'] = $this->ui->tasklist_list_item($insert_id, $list, $jsenv); $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); $this->rc->output->command('plugin.insert_tasklist', $list);
$success = true; $success = true;
@ -1034,11 +1034,9 @@ class tasklist extends rcube_plugin
break; break;
case 'edit': case 'edit':
if ($newid = $this->driver->edit_list($list)) { $list['oldid'] = $list['id'];
$list['oldid'] = $list['id']; if ($success = $this->driver->edit_list($list)) {
$list['id'] = $newid;
$this->rc->output->command('plugin.update_tasklist', $list); $this->rc->output->command('plugin.update_tasklist', $list);
$success = true;
} }
break; break;
@ -1065,7 +1063,7 @@ class tasklist extends rcube_plugin
// let the UI generate HTML and CSS representation for this calendar // let the UI generate HTML and CSS representation for this calendar
$html = $this->ui->tasklist_list_item($id, $prop, $jsenv); $html = $this->ui->tasklist_list_item($id, $prop, $jsenv);
$prop += (array)$jsenv[$id]; $prop += $jsenv[$id] ?? [];
$prop['editname'] = $editname; $prop['editname'] = $editname;
$prop['html'] = $html; $prop['html'] = $html;