diff options
Diffstat (limited to 'apps/dav/lib/CalDAV')
9 files changed, 44 insertions, 131 deletions
diff --git a/apps/dav/lib/CalDAV/BirthdayService.php b/apps/dav/lib/CalDAV/BirthdayService.php index bdcf0796283..1030768e26f 100644 --- a/apps/dav/lib/CalDAV/BirthdayService.php +++ b/apps/dav/lib/CalDAV/BirthdayService.php @@ -53,34 +53,15 @@ use Sabre\VObject\Reader; */ class BirthdayService { public const BIRTHDAY_CALENDAR_URI = 'contact_birthdays'; - - /** @var GroupPrincipalBackend */ - private $principalBackend; - - /** @var CalDavBackend */ - private $calDavBackEnd; - - /** @var CardDavBackend */ - private $cardDavBackEnd; - - /** @var IConfig */ - private $config; - - /** @var IDBConnection */ - private $dbConnection; - - /** @var IL10N */ - private $l10n; + private GroupPrincipalBackend $principalBackend; + private CalDavBackend $calDavBackEnd; + private CardDavBackend $cardDavBackEnd; + private IConfig $config; + private IDBConnection $dbConnection; + private IL10N $l10n; /** * BirthdayService constructor. - * - * @param CalDavBackend $calDavBackEnd - * @param CardDavBackend $cardDavBackEnd - * @param GroupPrincipalBackend $principalBackend - * @param IConfig $config - * @param IDBConnection $dbConnection - * @param IL10N $l10n */ public function __construct(CalDavBackend $calDavBackEnd, CardDavBackend $cardDavBackEnd, @@ -96,14 +77,9 @@ class BirthdayService { $this->l10n = $l10n; } - /** - * @param int $addressBookId - * @param string $cardUri - * @param string $cardData - */ public function onCardChanged(int $addressBookId, string $cardUri, - string $cardData) { + string $cardData): void { if (!$this->isGloballyEnabled()) { return; } @@ -129,12 +105,8 @@ class BirthdayService { } } - /** - * @param int $addressBookId - * @param string $cardUri - */ public function onCardDeleted(int $addressBookId, - string $cardUri) { + string $cardUri): void { if (!$this->isGloballyEnabled()) { return; } @@ -156,11 +128,9 @@ class BirthdayService { } /** - * @param string $principal - * @return array|null * @throws \Sabre\DAV\Exception\BadRequest */ - public function ensureCalendarExists(string $principal):?array { + public function ensureCalendarExists(string $principal): ?array { $calendar = $this->calDavBackEnd->getCalendarByUri($principal, self::BIRTHDAY_CALENDAR_URI); if (!is_null($calendar)) { return $calendar; diff --git a/apps/dav/lib/CalDAV/CachedSubscription.php b/apps/dav/lib/CalDAV/CachedSubscription.php index 18e61450ee9..f42b5f97f5d 100644 --- a/apps/dav/lib/CalDAV/CachedSubscription.php +++ b/apps/dav/lib/CalDAV/CachedSubscription.php @@ -31,6 +31,7 @@ use OCA\DAV\Exception\UnsupportedLimitOnInitialSyncException; use Sabre\CalDAV\Backend\BackendInterface; use Sabre\DAV\Exception\MethodNotAllowed; use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\INode; use Sabre\DAV\PropPatch; /** @@ -51,7 +52,7 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar { /** * @return array */ - public function getACL():array { + public function getACL() { return [ [ 'privilege' => '{DAV:}read', @@ -79,7 +80,7 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar { /** * @return array */ - public function getChildACL():array { + public function getChildACL() { return [ [ 'privilege' => '{DAV:}read', @@ -139,9 +140,9 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar { } /** - * @return array + * @return INode[] */ - public function getChildren():array { + public function getChildren(): array { $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id'], CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION); $children = []; @@ -169,8 +170,8 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar { /** * @param string $name - * @param null $calendarData - * @return null|string|void + * @param null|resource|string $calendarData + * @return null|string * @throws MethodNotAllowed */ public function createFile($name, $calendarData = null) { diff --git a/apps/dav/lib/CalDAV/CachedSubscriptionObject.php b/apps/dav/lib/CalDAV/CachedSubscriptionObject.php index db8c9fa8e80..3c1373763e1 100644 --- a/apps/dav/lib/CalDAV/CachedSubscriptionObject.php +++ b/apps/dav/lib/CalDAV/CachedSubscriptionObject.php @@ -50,7 +50,7 @@ class CachedSubscriptionObject extends \Sabre\CalDAV\CalendarObject { /** * @param resource|string $calendarData - * @return string|void + * @return string * @throws MethodNotAllowed */ public function put($calendarData) { diff --git a/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php b/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php index 0c76e4f5e10..627959c90f6 100644 --- a/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php +++ b/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php @@ -35,10 +35,7 @@ use Sabre\VObject\Property\ICalendar\Duration; * @package OCA\DAV\CalDAV\ICSExportPlugin */ class ICSExportPlugin extends \Sabre\CalDAV\ICSExportPlugin { - - /** @var IConfig */ - private $config; - + private IConfig $config; private LoggerInterface $logger; /** @var string */ diff --git a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php index c8da92c8277..a85892443cc 100644 --- a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php +++ b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php @@ -100,7 +100,7 @@ class InvitationResponseServer { )); // wait with registering these until auth is handled and the filesystem is setup - $this->server->on('beforeMethod:*', function () use ($root) { + $this->server->on('beforeMethod:*', function () use ($root): void { // register plugins from apps $pluginManager = new PluginManager( \OC::$server, diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php index 97e942f9da2..aabf78da1aa 100644 --- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php +++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php @@ -134,8 +134,8 @@ class PublishPlugin extends ServerPlugin { $canPublish = (!$node->isSubscription() && $node->canWrite()); if ($this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes') { - $canShare &= ($node->getOwner() === $node->getPrincipalURI()); - $canPublish &= ($node->getOwner() === $node->getPrincipalURI()); + $canShare = $canShare && ($node->getOwner() === $node->getPrincipalURI()); + $canPublish = $canPublish && ($node->getOwner() === $node->getPrincipalURI()); } return new AllowedSharingModes($canShare, $canPublish); diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php index 7e0020b5f55..c147b47860e 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php @@ -38,6 +38,7 @@ use OCP\IURLGenerator; use OCP\L10N\IFactory as L10NFactory; use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; +use OCP\IUser; use Psr\Log\LoggerInterface; use Sabre\VObject; use Sabre\VObject\Component\VEvent; @@ -54,8 +55,7 @@ class EmailProvider extends AbstractProvider { /** @var string */ public const NOTIFICATION_TYPE = 'EMAIL'; - /** @var IMailer */ - private $mailer; + private IMailer $mailer; public function __construct(IConfig $config, IMailer $mailer, @@ -168,10 +168,6 @@ class EmailProvider extends AbstractProvider { } } - /** - * @param string $path - * @return string - */ private function getAbsoluteImagePath(string $path):string { return $this->urlGenerator->getAbsoluteURL( $this->urlGenerator->imagePath('core', $path) @@ -207,9 +203,8 @@ class EmailProvider extends AbstractProvider { } /** - * @param array $emails - * @param string $defaultLanguage - * @return array + * @param array<string, array{LANG?: string}> $emails + * @return array<string, string[]> */ private function sortEMailAddressesByLanguage(array $emails, string $defaultLanguage):array { @@ -234,7 +229,7 @@ class EmailProvider extends AbstractProvider { /** * @param VEvent $vevent - * @return array + * @return array<string, array{LANG?: string}> */ private function getAllEMailAddressesFromEvent(VEvent $vevent):array { $emailAddresses = []; @@ -277,7 +272,7 @@ class EmailProvider extends AbstractProvider { $properties = []; $langProp = $attendee->offsetGet('LANG'); - if ($langProp instanceof VObject\Parameter) { + if ($langProp instanceof VObject\Parameter && $langProp->getValue() !== null) { $properties['LANG'] = $langProp->getValue(); } @@ -287,18 +282,15 @@ class EmailProvider extends AbstractProvider { } if (isset($vevent->ORGANIZER) && $this->hasAttendeeMailURI($vevent->ORGANIZER)) { - $emailAddresses[$this->getEMailAddressOfAttendee($vevent->ORGANIZER)] = []; + $organizerEmailAddress = $this->getEMailAddressOfAttendee($vevent->ORGANIZER); + if ($organizerEmailAddress !== null) { + $emailAddresses[$organizerEmailAddress] = []; + } } return $emailAddresses; } - - - /** - * @param VObject\Property $attendee - * @return string - */ private function getCUTypeOfAttendee(VObject\Property $attendee):string { $cuType = $attendee->offsetGet('CUTYPE'); if ($cuType instanceof VObject\Parameter) { @@ -308,10 +300,6 @@ class EmailProvider extends AbstractProvider { return 'INDIVIDUAL'; } - /** - * @param VObject\Property $attendee - * @return string - */ private function getPartstatOfAttendee(VObject\Property $attendee):string { $partstat = $attendee->offsetGet('PARTSTAT'); if ($partstat instanceof VObject\Parameter) { @@ -321,19 +309,11 @@ class EmailProvider extends AbstractProvider { return 'NEEDS-ACTION'; } - /** - * @param VObject\Property $attendee - * @return bool - */ - private function hasAttendeeMailURI(VObject\Property $attendee):bool { + private function hasAttendeeMailURI(VObject\Property $attendee): bool { return stripos($attendee->getValue(), 'mailto:') === 0; } - /** - * @param VObject\Property $attendee - * @return string|null - */ - private function getEMailAddressOfAttendee(VObject\Property $attendee):?string { + private function getEMailAddressOfAttendee(VObject\Property $attendee): ?string { if (!$this->hasAttendeeMailURI($attendee)) { return null; } @@ -342,8 +322,8 @@ class EmailProvider extends AbstractProvider { } /** - * @param array $users - * @return array + * @param IUser[] $users + * @return array<string, array{LANG?: string}> */ private function getEMailAddressesOfAllUsersWithWriteAccessToCalendar(array $users):array { $emailAddresses = []; @@ -366,12 +346,9 @@ class EmailProvider extends AbstractProvider { } /** - * @param IL10N $l10n - * @param VEvent $vevent - * @return string * @throws \Exception */ - private function generateDateString(IL10N $l10n, VEvent $vevent):string { + private function generateDateString(IL10N $l10n, VEvent $vevent): string { $isAllDay = $vevent->DTSTART instanceof Property\ICalendar\Date; /** @var Property\ICalendar\Date | Property\ICalendar\DateTime $dtstart */ @@ -437,57 +414,27 @@ class EmailProvider extends AbstractProvider { . ' (' . $startTimezone . ')'; } - /** - * @param DateTime $dtStart - * @param DateTime $dtEnd - * @return bool - */ private function isDayEqual(DateTime $dtStart, DateTime $dtEnd):bool { return $dtStart->format('Y-m-d') === $dtEnd->format('Y-m-d'); } - /** - * @param IL10N $l10n - * @param DateTime $dt - * @return string - */ private function getWeekDayName(IL10N $l10n, DateTime $dt):string { - return $l10n->l('weekdayName', $dt, ['width' => 'abbreviated']); + return (string)$l10n->l('weekdayName', $dt, ['width' => 'abbreviated']); } - /** - * @param IL10N $l10n - * @param DateTime $dt - * @return string - */ private function getDateString(IL10N $l10n, DateTime $dt):string { - return $l10n->l('date', $dt, ['width' => 'medium']); + return (string)$l10n->l('date', $dt, ['width' => 'medium']); } - /** - * @param IL10N $l10n - * @param DateTime $dt - * @return string - */ private function getDateTimeString(IL10N $l10n, DateTime $dt):string { - return $l10n->l('datetime', $dt, ['width' => 'medium|short']); + return (string)$l10n->l('datetime', $dt, ['width' => 'medium|short']); } - /** - * @param IL10N $l10n - * @param DateTime $dt - * @return string - */ private function getTimeString(IL10N $l10n, DateTime $dt):string { - return $l10n->l('time', $dt, ['width' => 'short']); + return (string)$l10n->l('time', $dt, ['width' => 'short']); } - /** - * @param VEvent $vevent - * @param IL10N $l10n - * @return string - */ private function getTitleFromVEvent(VEvent $vevent, IL10N $l10n):string { if (isset($vevent->SUMMARY)) { return (string)$vevent->SUMMARY; diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php index 298297fdc38..cb873020c38 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php @@ -109,8 +109,6 @@ class PushProvider extends AbstractProvider { } /** - * @var VEvent $vevent - * @return array * @throws \Exception */ protected function extractEventDetails(VEvent $vevent):array { diff --git a/apps/dav/lib/CalDAV/Reminder/Notifier.php b/apps/dav/lib/CalDAV/Reminder/Notifier.php index 8535c55054a..c658ef2ff01 100644 --- a/apps/dav/lib/CalDAV/Reminder/Notifier.php +++ b/apps/dav/lib/CalDAV/Reminder/Notifier.php @@ -298,7 +298,7 @@ class Notifier implements INotifier { * @return string */ private function getWeekDayName(DateTime $dt):string { - return $this->l10n->l('weekdayName', $dt, ['width' => 'abbreviated']); + return (string)$this->l10n->l('weekdayName', $dt, ['width' => 'abbreviated']); } /** @@ -306,7 +306,7 @@ class Notifier implements INotifier { * @return string */ private function getDateString(DateTime $dt):string { - return $this->l10n->l('date', $dt, ['width' => 'medium']); + return (string)$this->l10n->l('date', $dt, ['width' => 'medium']); } /** @@ -314,7 +314,7 @@ class Notifier implements INotifier { * @return string */ private function getDateTimeString(DateTime $dt):string { - return $this->l10n->l('datetime', $dt, ['width' => 'medium|short']); + return (string)$this->l10n->l('datetime', $dt, ['width' => 'medium|short']); } /** @@ -322,6 +322,6 @@ class Notifier implements INotifier { * @return string */ private function getTimeString(DateTime $dt):string { - return $this->l10n->l('time', $dt, ['width' => 'short']); + return (string)$this->l10n->l('time', $dt, ['width' => 'short']); } } |