diff --git a/apps/dav/appinfo/v1/caldav.php b/apps/dav/appinfo/v1/caldav.php index 9036a30f95ca7..6a496a992e61d 100644 --- a/apps/dav/appinfo/v1/caldav.php +++ b/apps/dav/appinfo/v1/caldav.php @@ -100,7 +100,7 @@ // Add plugins $server->addPlugin(new MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav'))); -$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud')); +$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend)); $server->addPlugin(new \Sabre\CalDAV\Plugin()); $server->addPlugin(new LegacyDAVACL()); diff --git a/apps/dav/appinfo/v1/carddav.php b/apps/dav/appinfo/v1/carddav.php index 8dffad16d8d78..a0306118781ef 100644 --- a/apps/dav/appinfo/v1/carddav.php +++ b/apps/dav/appinfo/v1/carddav.php @@ -38,7 +38,6 @@ use OCP\App\IAppManager; use Psr\Log\LoggerInterface; use Sabre\CardDAV\Plugin; -use Psr\Log\LoggerInterface; $authBackend = new Auth( \OC::$server->getSession(), diff --git a/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php b/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php index 7f1e78248d347..2ae47ee89ea31 100644 --- a/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php +++ b/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php @@ -71,12 +71,9 @@ public function __construct(IDBConnection $db, $this->timeFactory = $timeFactory; } - /** - * @param $arguments - */ - public function run($arguments) { - $offset = (int) $arguments['offset']; - $stopAt = (int) $arguments['stopAt']; + public function run($argument) { + $offset = (int) $argument['offset']; + $stopAt = (int) $argument['stopAt']; $this->logger->info('Building calendar reminder index (' . $offset .'/' . $stopAt . ')'); diff --git a/apps/dav/lib/BackgroundJob/EventReminderJob.php b/apps/dav/lib/BackgroundJob/EventReminderJob.php index ab7dadd8c0b2f..55cecf5519d52 100644 --- a/apps/dav/lib/BackgroundJob/EventReminderJob.php +++ b/apps/dav/lib/BackgroundJob/EventReminderJob.php @@ -52,12 +52,11 @@ public function __construct(ITimeFactory $time, } /** - * @param $arg * @throws \OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException * @throws \OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException * @throws \OC\User\NoUserException */ - public function run($arg):void { + public function run($argument):void { if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') { return; } diff --git a/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php b/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php index a338a172d66f3..8e72e8f076c8c 100644 --- a/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php +++ b/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php @@ -47,12 +47,9 @@ public function __construct(ITimeFactory $time, $this->config = $config; } - /** - * @param array $arguments - */ - public function run($arguments) { - $userId = $arguments['userId']; - $purgeBeforeGenerating = $arguments['purgeBeforeGenerating'] ?? false; + public function run($argument) { + $userId = $argument['userId']; + $purgeBeforeGenerating = $argument['purgeBeforeGenerating'] ?? false; // make sure admin didn't change his mind $isGloballyEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'); diff --git a/apps/dav/lib/BackgroundJob/UploadCleanup.php b/apps/dav/lib/BackgroundJob/UploadCleanup.php index 76906becb54c2..f612f58cd7ce5 100644 --- a/apps/dav/lib/BackgroundJob/UploadCleanup.php +++ b/apps/dav/lib/BackgroundJob/UploadCleanup.php @@ -32,18 +32,15 @@ use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\TimedJob; +use OCP\Files\Node; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; class UploadCleanup extends TimedJob { - - /** @var IRootFolder */ - private $rootFolder; - - /** @var IJobList */ - private $jobList; + private IRootFolder $rootFolder; + private IJobList $jobList; public function __construct(ITimeFactory $time, IRootFolder $rootFolder, IJobList $jobList) { parent::__construct($time); @@ -71,6 +68,7 @@ protected function run($argument) { return; } + /** @var File[] $files */ $files = $uploadFolder->getDirectoryListing(); // Remove if all files have an mtime of more than a day diff --git a/apps/dav/lib/CalDAV/BirthdayService.php b/apps/dav/lib/CalDAV/BirthdayService.php index bdcf0796283ef..1030768e26f45 100644 --- a/apps/dav/lib/CalDAV/BirthdayService.php +++ b/apps/dav/lib/CalDAV/BirthdayService.php @@ -53,34 +53,15 @@ */ 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 @@ public function __construct(CalDavBackend $calDavBackEnd, $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 @@ public function onCardChanged(int $addressBookId, } } - /** - * @param int $addressBookId - * @param string $cardUri - */ public function onCardDeleted(int $addressBookId, - string $cardUri) { + string $cardUri): void { if (!$this->isGloballyEnabled()) { return; } @@ -156,11 +128,9 @@ public function onCardDeleted(int $addressBookId, } /** - * @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 18e61450ee9b6..f42b5f97f5d6b 100644 --- a/apps/dav/lib/CalDAV/CachedSubscription.php +++ b/apps/dav/lib/CalDAV/CachedSubscription.php @@ -31,6 +31,7 @@ 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 @@ public function getPrincipalURI():string { /** * @return array */ - public function getACL():array { + public function getACL() { return [ [ 'privilege' => '{DAV:}read', @@ -79,7 +80,7 @@ public function getACL():array { /** * @return array */ - public function getChildACL():array { + public function getChildACL() { return [ [ 'privilege' => '{DAV:}read', @@ -139,9 +140,9 @@ public function getChild($name) { } /** - * @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 @@ public function getMultipleChildren(array $paths):array { /** * @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 db8c9fa8e8011..3c1373763e127 100644 --- a/apps/dav/lib/CalDAV/CachedSubscriptionObject.php +++ b/apps/dav/lib/CalDAV/CachedSubscriptionObject.php @@ -50,7 +50,7 @@ public function get() { /** * @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 2a5a6f1bae395..627959c90f6d8 100644 --- a/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php +++ b/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php @@ -23,11 +23,11 @@ namespace OCA\DAV\CalDAV\ICSExportPlugin; use OCP\IConfig; +use Psr\Log\LoggerInterface; use Sabre\HTTP\ResponseInterface; use Sabre\VObject\DateTimeParser; use Sabre\VObject\InvalidDataException; use Sabre\VObject\Property\ICalendar\Duration; -use Psr\Log\LoggerInterface; /** * Class ICSExportPlugin diff --git a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php index 1a70f95aa5f69..a85892443cc45 100644 --- a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php +++ b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php @@ -37,7 +37,6 @@ use OCP\EventDispatcher\IEventDispatcher; use Psr\Log\LoggerInterface; use Sabre\VObject\ITip\Message; -use Psr\Log\LoggerInterface; class InvitationResponseServer { diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php index 97e942f9da24a..aabf78da1aa8b 100644 --- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php +++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php @@ -134,8 +134,8 @@ public function propFind(PropFind $propFind, INode $node) { $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 7e0020b5f55e9..c147b47860e2c 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\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 @@ private function addBulletList(IEMailTemplate $template, } } - /** - * @param string $path - * @return string - */ private function getAbsoluteImagePath(string $path):string { return $this->urlGenerator->getAbsoluteURL( $this->urlGenerator->imagePath('core', $path) @@ -207,9 +203,8 @@ private function getOrganizerEMailAndNameFromEvent(VEvent $vevent):?array { } /** - * @param array $emails - * @param string $defaultLanguage - * @return array + * @param array $emails + * @return array */ private function sortEMailAddressesByLanguage(array $emails, string $defaultLanguage):array { @@ -234,7 +229,7 @@ private function sortEMailAddressesByLanguage(array $emails, /** * @param VEvent $vevent - * @return array + * @return array */ private function getAllEMailAddressesFromEvent(VEvent $vevent):array { $emailAddresses = []; @@ -277,7 +272,7 @@ private function getAllEMailAddressesFromEvent(VEvent $vevent):array { $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 @@ private function getAllEMailAddressesFromEvent(VEvent $vevent):array { } 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 @@ private function getCUTypeOfAttendee(VObject\Property $attendee):string { 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 @@ private function getPartstatOfAttendee(VObject\Property $attendee):string { 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 @@ private function getEMailAddressOfAttendee(VObject\Property $attendee):?string { } /** - * @param array $users - * @return array + * @param IUser[] $users + * @return array */ private function getEMailAddressesOfAllUsersWithWriteAccessToCalendar(array $users):array { $emailAddresses = []; @@ -366,12 +346,9 @@ private function getEMailAddressesOfAllUsersWithWriteAccessToCalendar(array $use } /** - * @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 @@ private function generateDateString(IL10N $l10n, VEvent $vevent):string { . ' (' . $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 298297fdc38bb..cb873020c388d 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php @@ -109,8 +109,6 @@ public function send(VEvent $vevent, } /** - * @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 8535c55054a90..c658ef2ff0165 100644 --- a/apps/dav/lib/CalDAV/Reminder/Notifier.php +++ b/apps/dav/lib/CalDAV/Reminder/Notifier.php @@ -298,7 +298,7 @@ private function isDayEqual(DateTime $dtStart, * @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 @@ private function getWeekDayName(DateTime $dt):string { * @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 @@ private function getDateString(DateTime $dt):string { * @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 @@ private function getDateTimeString(DateTime $dt):string { * @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']); } } diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 1c1754ff752f3..35df5c0b8cafa 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -291,16 +291,15 @@ private function getUserDisplayName($uid) { /** * @param int $addressBookId */ - public function getAddressBookById($addressBookId) { + public function getAddressBookById(int $addressBookId): ?array { $query = $this->db->getQueryBuilder(); $result = $query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken']) ->from('addressbooks') - ->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId))) - ->execute(); - + ->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId, IQueryBuilder::PARAM_INT))) + ->executeQuery(); $row = $result->fetch(); $result->closeCursor(); - if ($row === false) { + if (!$row) { return null; } @@ -457,7 +456,7 @@ public function createAddressBook($principalUri, $url, array $properties) { $addressBookId = $query->getLastInsertId(); $addressBookRow = $this->getAddressBookById($addressBookId); - $this->dispatcher->dispatchTyped(new AddressBookCreatedEvent((int)$addressBookId, $addressBookRow)); + $this->dispatcher->dispatchTyped(new AddressBookCreatedEvent($addressBookId, $addressBookRow)); return $addressBookId; } @@ -495,7 +494,7 @@ public function deleteAddressBook($addressBookId) { ->execute(); if ($addressBookData) { - $this->dispatcher->dispatchTyped(new AddressBookDeletedEvent((int) $addressBookId, $addressBookData, $shares)); + $this->dispatcher->dispatchTyped(new AddressBookDeletedEvent($addressBookId, $addressBookData, $shares)); } } @@ -515,14 +514,14 @@ public function deleteAddressBook($addressBookId) { * calculating them. If they are specified, you can also ommit carddata. * This may speed up certain requests, especially with large cards. * - * @param mixed $addressBookId + * @param mixed $addressbookId * @return array */ - public function getCards($addressBookId) { + public function getCards($addressbookId) { $query = $this->db->getQueryBuilder(); $query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata', 'uid']) ->from($this->dbCardsTable) - ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); + ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressbookId))); $cards = []; @@ -588,7 +587,7 @@ public function getCard($addressBookId, $cardUri) { * If the backend supports this, it may allow for some speed-ups. * * @param mixed $addressBookId - * @param string[] $uris + * @param array $uris * @return array */ public function getMultipleCards($addressBookId, array $uris) { @@ -689,7 +688,7 @@ public function createCard($addressBookId, $cardUri, $cardData) { $addressBookData = $this->getAddressBookById($addressBookId); $shares = $this->getShares($addressBookId); $objectRow = $this->getCard($addressBookId, $cardUri); - $this->dispatcher->dispatchTyped(new CardCreatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow)); + $this->dispatcher->dispatchTyped(new CardCreatedEvent($addressBookId, $addressBookData, $shares, $objectRow)); $this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::createCard', new GenericEvent(null, [ 'addressBookId' => $addressBookId, @@ -753,7 +752,7 @@ public function updateCard($addressBookId, $cardUri, $cardData) { $addressBookData = $this->getAddressBookById($addressBookId); $shares = $this->getShares($addressBookId); $objectRow = $this->getCard($addressBookId, $cardUri); - $this->dispatcher->dispatchTyped(new CardUpdatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow)); + $this->dispatcher->dispatchTyped(new CardUpdatedEvent($addressBookId, $addressBookData, $shares, $objectRow)); $this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::updateCard', new GenericEvent(null, [ 'addressBookId' => $addressBookId, @@ -784,13 +783,13 @@ public function deleteCard($addressBookId, $cardUri) { $ret = $query->delete($this->dbCardsTable) ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))) ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($cardUri))) - ->execute(); + ->executeStatement(); $this->addChange($addressBookId, $cardUri, 3); if ($ret === 1) { if ($cardId !== null) { - $this->dispatcher->dispatchTyped(new CardDeletedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow)); + $this->dispatcher->dispatchTyped(new CardDeletedEvent($addressBookId, $addressBookData, $shares, $objectRow)); $this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', new GenericEvent(null, [ 'addressBookId' => $addressBookId, @@ -868,12 +867,12 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, ->where( $qb->expr()->eq('id', $qb->createNamedParameter($addressBookId)) ); - $stmt = $qb->execute(); + $stmt = $qb->executeQuery(); $currentToken = $stmt->fetchOne(); $stmt->closeCursor(); if (is_null($currentToken)) { - return null; + return []; } $result = [ @@ -900,7 +899,7 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, } // Fetching all changes - $stmt = $qb->execute(); + $stmt = $qb->executeQuery(); $changes = []; @@ -932,7 +931,7 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $qb->expr()->eq('addressbookid', $qb->createNamedParameter($addressBookId)) ); // No synctoken supplied, this is the initial sync. - $stmt = $qb->execute(); + $stmt = $qb->executeQuery(); $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN); $stmt->closeCursor(); } diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php index 3051d2d48ba96..777a0b0e16945 100644 --- a/apps/dav/lib/CardDAV/PhotoCache.php +++ b/apps/dav/lib/CardDAV/PhotoCache.php @@ -63,15 +63,9 @@ public function __construct(IAppData $appData, LoggerInterface $logger) { } /** - * @param int $addressBookId - * @param string $cardUri - * @param int $size - * @param Card $card - * - * @return ISimpleFile * @throws NotFoundException */ - public function get($addressBookId, $cardUri, $size, Card $card) { + public function get(int $addressBookId, string $cardUri, int $size, Card $card): ISimpleFile { $folder = $this->getFolder($addressBookId, $cardUri); if ($this->isEmpty($folder)) { @@ -120,7 +114,10 @@ private function hasPhoto(ISimpleFolder $folder): bool { return !$folder->fileExists('nophoto'); } - private function getFile(ISimpleFolder $folder, int $size): ISimpleFile { + /** + * @param float|-1 $size + */ + private function getFile(ISimpleFolder $folder, $size): ISimpleFile { $ext = $this->getExtension($folder); if ($size === -1) { diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php index b93fd94f7419c..95fdf1d21dae0 100644 --- a/apps/dav/lib/CardDAV/SyncService.php +++ b/apps/dav/lib/CardDAV/SyncService.php @@ -86,7 +86,7 @@ public function __construct(CardDavBackend $backend, */ public function syncRemoteAddressBook($url, $userName, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) { // 1. create addressbook - $book = $this->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetProperties); + $book = $this->ensureSystemAddressBookExists($targetPrincipal, (string)$targetBookId, $targetProperties); $addressBookId = $book['id']; // 2. query changes diff --git a/apps/dav/lib/Connector/PublicAuth.php b/apps/dav/lib/Connector/PublicAuth.php index ba5e635e5f353..cc51a249e7570 100644 --- a/apps/dav/lib/Connector/PublicAuth.php +++ b/apps/dav/lib/Connector/PublicAuth.php @@ -44,7 +44,7 @@ */ class PublicAuth extends AbstractBasic { private const BRUTEFORCE_ACTION = 'public_webdav_auth'; - private IShare $share; + private ?IShare $share = null; private IManager $shareManager; private ISession $session; private IRequest $request; @@ -121,6 +121,7 @@ protected function validateUserPass($username, $password) { } public function getShare(): IShare { + assert($this->share !== null); return $this->share; } } diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php index 1588e5a2e6c79..1610c554b9bba 100644 --- a/apps/dav/lib/Connector/Sabre/Auth.php +++ b/apps/dav/lib/Connector/Sabre/Auth.php @@ -54,7 +54,7 @@ class Auth extends AbstractBasic { private ISession $session; private Session $userSession; private IRequest $request; - private string $currentUser; + private ?string $currentUser = null; private Manager $twoFactorManager; private Throttler $throttler; diff --git a/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php b/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php index 830c92d2c3061..2d2be63141695 100644 --- a/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php +++ b/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php @@ -37,7 +37,7 @@ * @package OCA\DAV\Connector\Sabre */ class BlockLegacyClientPlugin extends ServerPlugin { - protected Server $server; + protected ?Server $server = null; protected IConfig $config; public function __construct(IConfig $config) { diff --git a/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php b/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php index c023d918c42a2..c222923bc8e55 100644 --- a/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php +++ b/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php @@ -29,7 +29,7 @@ use Sabre\DAV\Server; class ChecksumUpdatePlugin extends ServerPlugin { - protected Server $server; + protected ?Server $server = null; public function initialize(Server $server) { $this->server = $server; diff --git a/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php b/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php index f9a087daeb082..4a1205e8606be 100644 --- a/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php @@ -36,7 +36,7 @@ class CommentPropertiesPlugin extends ServerPlugin { public const PROPERTY_NAME_COUNT = '{http://owncloud.org/ns}comments-count'; public const PROPERTY_NAME_UNREAD = '{http://owncloud.org/ns}comments-unread'; - protected Server $server; + protected ?Server $server = null; private ICommentsManager $commentsManager; private IUserSession $userSession; private array $cachedUnreadCount = []; diff --git a/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php b/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php index 5dd0dc6f23177..f3ea94be3b6a1 100644 --- a/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php +++ b/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php @@ -35,7 +35,7 @@ * or mangle Etag headers. */ class CopyEtagHeaderPlugin extends \Sabre\DAV\ServerPlugin { - private Server $server; + private ?Server $server = null; /** * This initializes the plugin. diff --git a/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php b/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php index bc6c6f5c25fbe..8e35afe2e7cc7 100644 --- a/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php +++ b/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php @@ -44,7 +44,7 @@ * @package OCA\DAV\Connector\Sabre */ class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin { - protected Server $server; + protected ?Server $server = null; /** * @param \Sabre\DAV\Server $server diff --git a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php index c803358ede10f..ea94b5c8933b9 100644 --- a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php +++ b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php @@ -112,7 +112,7 @@ public function initialize(\Sabre\DAV\Server $server) { /** * Log exception */ - public function logException(\Throwable $ex): void { + public function logException(\Throwable $ex) { $exceptionClass = get_class($ex); if (isset($this->nonFatalExceptions[$exceptionClass]) || ( diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index 9474ed91f8582..b784764f8fed3 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -86,7 +86,7 @@ class FilesPlugin extends ServerPlugin { public const FILE_METADATA_SIZE = '{http://nextcloud.org/ns}file-metadata-size'; /** Reference to main server object */ - private Server $server; + private ?Server $server = null; private Tree $tree; private IUserSession $userSession; @@ -345,7 +345,7 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) $propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) { return json_encode($this->previewManager->isAvailable($node->getFileInfo())); }); - $propFind->handle(self::SIZE_PROPERTYNAME, function () use ($node): int { + $propFind->handle(self::SIZE_PROPERTYNAME, function () use ($node): ?int { return $node->getSize(); }); $propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) { diff --git a/apps/dav/tests/unit/Files/FileSearchBackendTest.php b/apps/dav/tests/unit/Files/FileSearchBackendTest.php index dec5db1b1b0cf..da682a5fb2187 100644 --- a/apps/dav/tests/unit/Files/FileSearchBackendTest.php +++ b/apps/dav/tests/unit/Files/FileSearchBackendTest.php @@ -29,7 +29,7 @@ use OC\Files\Search\SearchComparison; use OC\Files\Search\SearchQuery; use OC\Files\View; -use OCA\DAV\Connector\Sabre\CachingTree; +use OCA\DAV\Connector\Sabre\ObjectTree; use OCA\DAV\Connector\Sabre\Directory; use OCA\DAV\Connector\Sabre\File; use OCA\DAV\Connector\Sabre\FilesPlugin; @@ -48,7 +48,7 @@ use Test\TestCase; class FileSearchBackendTest extends TestCase { - /** @var CachingTree|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ObjectTree|\PHPUnit\Framework\MockObject\MockObject */ private $tree; /** @var IUser */ @@ -80,7 +80,7 @@ protected function setUp(): void { ->method('getUID') ->willReturn('test'); - $this->tree = $this->getMockBuilder(CachingTree::class) + $this->tree = $this->getMockBuilder(ObjectTree::class) ->disableOriginalConstructor() ->getMock(); diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index d3d497e7e3ce1..cc644443d5136 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -55,9 +55,6 @@ - - new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud') - $baseuri @@ -122,26 +119,6 @@ Uri\split($this->principalInfo['uri']) - - - $arguments - - - - - $arg - - - - - $arguments - - - - - File - - setDateTime @@ -155,20 +132,11 @@ - - array - - - $calendarData - $calendarData - - string|void - $this->objectData['calendardata'] @@ -263,16 +231,6 @@ $paths - - - $canPublish - $canShare - - - $canPublish - $canShare - - hasTime @@ -281,60 +239,17 @@ - - $l10n->l('date', $dt, ['width' => 'medium']) - $l10n->l('datetime', $dt, ['width' => 'medium|short']) - $l10n->l('time', $dt, ['width' => 'short']) - $l10n->l('weekdayName', $dt, ['width' => 'abbreviated']) - - - $l10n->l('date', $dt, ['width' => 'medium']) - $l10n->l('datetime', $dt, ['width' => 'medium|short']) - $l10n->l('time', $dt, ['width' => 'short']) - $l10n->l('weekdayName', $dt, ['width' => 'abbreviated']) - - - string - string - string - string - getDateTime getDateTime isFloating - - - @var VEvent $vevent - - $provider::NOTIFICATION_TYPE - - - $this->l10n->l('date', $dt, ['width' => 'medium']) - $this->l10n->l('datetime', $dt, ['width' => 'medium|short']) - $this->l10n->l('time', $dt, ['width' => 'short']) - $this->l10n->l('weekdayName', $dt, ['width' => 'abbreviated']) - - - $this->l10n->l('date', $dt, ['width' => 'medium']) - $this->l10n->l('datetime', $dt, ['width' => 'medium|short']) - $this->l10n->l('time', $dt, ['width' => 'short']) - $this->l10n->l('weekdayName', $dt, ['width' => 'abbreviated']) - - - string - string - string - string - - getDateInterval @@ -457,21 +372,6 @@ '\OCA\DAV\CardDAV\CardDavBackend::deleteCard' '\OCA\DAV\CardDAV\CardDavBackend::updateCard' - - array - - - $uris - - - null - - - $addressBookId - - - (int)$addressBookId - dispatch dispatch @@ -511,11 +411,6 @@ \Sabre\Uri\split($principal) - - - $targetBookId - - $this->principalUri