]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix more psalm issues 31943/head
authorCarl Schwan <carl@carlschwan.eu>
Thu, 5 May 2022 22:01:08 +0000 (00:01 +0200)
committerCarl Schwan <carl@carlschwan.eu>
Mon, 16 May 2022 09:05:54 +0000 (11:05 +0200)
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
29 files changed:
apps/dav/appinfo/v1/caldav.php
apps/dav/appinfo/v1/carddav.php
apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php
apps/dav/lib/BackgroundJob/EventReminderJob.php
apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php
apps/dav/lib/BackgroundJob/UploadCleanup.php
apps/dav/lib/CalDAV/BirthdayService.php
apps/dav/lib/CalDAV/CachedSubscription.php
apps/dav/lib/CalDAV/CachedSubscriptionObject.php
apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php
apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php
apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php
apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php
apps/dav/lib/CalDAV/Reminder/Notifier.php
apps/dav/lib/CardDAV/CardDavBackend.php
apps/dav/lib/CardDAV/PhotoCache.php
apps/dav/lib/CardDAV/SyncService.php
apps/dav/lib/Connector/PublicAuth.php
apps/dav/lib/Connector/Sabre/Auth.php
apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php
apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php
apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php
apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php
apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php
apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php
apps/dav/lib/Connector/Sabre/FilesPlugin.php
apps/dav/tests/unit/Files/FileSearchBackendTest.php
build/psalm-baseline.xml

index 9036a30f95ca7ab9123fef548e4d2a77715c7d45..6a496a992e61dab164674791880b6c66ea0b6fe0 100644 (file)
@@ -100,7 +100,7 @@ $server->setBaseUri($baseuri);
 
 // 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());
index 8dffad16d8d78f9a0e191406e17f3560f51e3263..a0306118781ef1ffb1229cfc8cf7dda597ddd730 100644 (file)
@@ -38,7 +38,6 @@ use OCA\DAV\Connector\Sabre\Principal;
 use OCP\App\IAppManager;
 use Psr\Log\LoggerInterface;
 use Sabre\CardDAV\Plugin;
-use Psr\Log\LoggerInterface;
 
 $authBackend = new Auth(
        \OC::$server->getSession(),
index 7f1e78248d34770f66690464d0c918933f2a0982..2ae47ee89ea319cb2a537745e7d3129a4d411e42 100644 (file)
@@ -71,12 +71,9 @@ class BuildReminderIndexBackgroundJob extends QueuedJob {
                $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 . ')');
 
index ab7dadd8c0b2f2e8c11332b59002ab76625550eb..55cecf5519d529b3cdcd0c59908fac0d96e6a764 100644 (file)
@@ -52,12 +52,11 @@ class EventReminderJob extends TimedJob {
        }
 
        /**
-        * @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;
                }
index a338a172d66f38735ec589a6c560e79fab867306..8e72e8f076c8cbe57ad404ccd442ac99bf54908f 100644 (file)
@@ -47,12 +47,9 @@ class GenerateBirthdayCalendarBackgroundJob extends QueuedJob {
                $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');
index 76906becb54c23f702bad95b3793569a29c4a955..f612f58cd7ce507ace70013108dba343d3e8365a 100644 (file)
@@ -32,18 +32,15 @@ use OCP\AppFramework\Utility\ITimeFactory;
 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 @@ class UploadCleanup extends TimedJob {
                        return;
                }
 
+               /** @var File[] $files */
                $files = $uploadFolder->getDirectoryListing();
 
                // Remove if all files have an mtime of more than a day
index bdcf0796283ef669ef58e6ae6a62dc41b3bc3d4b..1030768e26f452ab0dfd2c7c4db170443d843794 100644 (file)
@@ -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;
index 18e61450ee9b63a74e91e5ba5a1d0b5eb56f6acf..f42b5f97f5d6b3aabf5db0aeafba84aaedb630ad 100644 (file)
@@ -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) {
index db8c9fa8e801153362fc2da6988219f6f075a48d..3c1373763e127e810266b355afa5024710ea1349 100644 (file)
@@ -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) {
index 2a5a6f1bae3952db08a0f21a99a8f427e4ac8bbc..627959c90f6d80902201693efa9c687556de9f24 100644 (file)
 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
index 1a70f95aa5f69a6e1359189c3ceca1682fb4d2cd..a85892443cc45c432916a01f62512b6fa779bbb6 100644 (file)
@@ -37,7 +37,6 @@ use OCA\DAV\RootCollection;
 use OCP\EventDispatcher\IEventDispatcher;
 use Psr\Log\LoggerInterface;
 use Sabre\VObject\ITip\Message;
-use Psr\Log\LoggerInterface;
 
 class InvitationResponseServer {
 
index 97e942f9da24a09da9a072bce30a30239d6dc8b6..aabf78da1aa8bb2263562da57132229cd5b9854b 100644 (file)
@@ -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);
index 7e0020b5f55e92069643f01b60080753d1cef666..c147b47860e2c6bf5d30dc174d1f14647c016926 100644 (file)
@@ -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;
index 298297fdc38bb7b977c680e63b6fc56f21ba1dd6..cb873020c388d109234c70de8b4328f8379e9f64 100644 (file)
@@ -109,8 +109,6 @@ class PushProvider extends AbstractProvider {
        }
 
        /**
-        * @var VEvent $vevent
-        * @return array
         * @throws \Exception
         */
        protected function extractEventDetails(VEvent $vevent):array {
index 8535c55054a90b84a64c532bf08a1bef0daf5d2c..c658ef2ff016540dd0c156c535c7a6276419a555 100644 (file)
@@ -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']);
        }
 }
index 1c1754ff752f35c50f640a46119e1025fd3727d0..35df5c0b8cafae89e3e31fb858bfc02970dee5fa 100644 (file)
@@ -291,16 +291,15 @@ class CardDavBackend implements BackendInterface, SyncSupport {
        /**
         * @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 @@ class CardDavBackend implements BackendInterface, SyncSupport {
 
                $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 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                        ->execute();
 
                if ($addressBookData) {
-                       $this->dispatcher->dispatchTyped(new AddressBookDeletedEvent((int) $addressBookId, $addressBookData, $shares));
+                       $this->dispatcher->dispatchTyped(new AddressBookDeletedEvent($addressBookId, $addressBookData, $shares));
                }
        }
 
@@ -515,14 +514,14 @@ class CardDavBackend implements BackendInterface, SyncSupport {
         * 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 @@ class CardDavBackend implements BackendInterface, SyncSupport {
         * 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 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                $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 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                $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 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                $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 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                        ->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 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                        }
 
                        // Fetching all changes
-                       $stmt = $qb->execute();
+                       $stmt = $qb->executeQuery();
 
                        $changes = [];
 
@@ -932,7 +931,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                                        $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();
                }
index 3051d2d48ba96b2993aa9a04a1f135a95cfd5879..777a0b0e16945152410be141f944d749b6a86af8 100644 (file)
@@ -63,15 +63,9 @@ class PhotoCache {
        }
 
        /**
-        * @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 @@ class PhotoCache {
                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) {
index b93fd94f7419c355a1e305e1c9985624e1cf70fd..95fdf1d21dae0585dac346e608cd3cdd338c6ae2 100644 (file)
@@ -86,7 +86,7 @@ class SyncService {
         */
        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
index ba5e635e5f353a2514ee6371e6ec026f6a005ff1..cc51a249e7570ef86e444a862a309766aea697c6 100644 (file)
@@ -44,7 +44,7 @@ use Sabre\DAV\Auth\Backend\AbstractBasic;
  */
 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 @@ class PublicAuth extends AbstractBasic {
        }
 
        public function getShare(): IShare {
+               assert($this->share !== null);
                return $this->share;
        }
 }
index 1588e5a2e6c79e173aca89975e3414a07350860e..1610c554b9bba2b72f4e9e0f7d5ae0d59375876a 100644 (file)
@@ -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;
 
index 830c92d2c3061bed1d46c7e0c07c0380538727a6..2d2be631416953e810dbfcb378a7ae0011024b29 100644 (file)
@@ -37,7 +37,7 @@ use Sabre\DAV\Server;
  * @package OCA\DAV\Connector\Sabre
  */
 class BlockLegacyClientPlugin extends ServerPlugin {
-       protected Server $server;
+       protected ?Server $server = null;
        protected IConfig $config;
 
        public function __construct(IConfig $config) {
index c023d918c42a2f58c3068d14aa32c6c95dd98846..c222923bc8e55b72cb0721fbdbbf18c3f9b0c388 100644 (file)
@@ -29,7 +29,7 @@ use Sabre\HTTP\ResponseInterface;
 use Sabre\DAV\Server;
 
 class ChecksumUpdatePlugin extends ServerPlugin {
-       protected Server $server;
+       protected ?Server $server = null;
 
        public function initialize(Server $server) {
                $this->server = $server;
index f9a087daeb0826e33178035d7e0588791a0c2693..4a1205e8606be66cf4370630c5c45479e6ccdfaa 100644 (file)
@@ -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 = [];
index 5dd0dc6f231779d3cc2b262bc3dbaabb7034910f..f3ea94be3b6a138991b9daa3a19dcf364db7801e 100644 (file)
@@ -35,7 +35,7 @@ use Sabre\DAV\Server;
  * or mangle Etag headers.
  */
 class CopyEtagHeaderPlugin extends \Sabre\DAV\ServerPlugin {
-       private Server $server;
+       private ?Server $server = null;
 
        /**
         * This initializes the plugin.
index bc6c6f5c25fbe6f377154898e2993f14d6593a45..8e35afe2e7cc7f5de7f96abc80530da08ada10c1 100644 (file)
@@ -44,7 +44,7 @@ use Sabre\DAV\Server;
  * @package OCA\DAV\Connector\Sabre
  */
 class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin {
-       protected Server $server;
+       protected ?Server $server = null;
 
        /**
         * @param \Sabre\DAV\Server $server
index c803358ede10fa8c872f9f8c9bf94013533d75b4..ea94b5c8933b9435ac4b661ab31b6e69809e89dd 100644 (file)
@@ -112,7 +112,7 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
        /**
         * Log exception
         */
-       public function logException(\Throwable $ex): void {
+       public function logException(\Throwable $ex) {
                $exceptionClass = get_class($ex);
                if (isset($this->nonFatalExceptions[$exceptionClass]) ||
                        (
index 9474ed91f8582f12f297ec75449e20aec68501aa..b784764f8fed3801a8a6378a0bd44b724408558c 100644 (file)
@@ -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 @@ class FilesPlugin extends ServerPlugin {
                        $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) {
index dec5db1b1b0cf00257d52008930552af806f7979..da682a5fb2187dce77b605df0e56e0e04721d7a4 100644 (file)
@@ -29,7 +29,7 @@ namespace OCA\DAV\Tests\Files;
 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 SearchDAV\Query\Query;
 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 @@ class FileSearchBackendTest extends TestCase {
                        ->method('getUID')
                        ->willReturn('test');
 
-               $this->tree = $this->getMockBuilder(CachingTree::class)
+               $this->tree = $this->getMockBuilder(ObjectTree::class)
                        ->disableOriginalConstructor()
                        ->getMock();
 
index d3d497e7e3ce1efcf8655e058fec706143f1ca60..cc644443d5136b711f739be7824ce107ec3ebaf9 100644 (file)
@@ -55,9 +55,6 @@
     </UndefinedFunction>
   </file>
   <file src="apps/dav/appinfo/v1/caldav.php">
-    <TooManyArguments occurrences="1">
-      <code>new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud')</code>
-    </TooManyArguments>
     <UndefinedGlobalVariable occurrences="1">
       <code>$baseuri</code>
     </UndefinedGlobalVariable>
       <code>Uri\split($this-&gt;principalInfo['uri'])</code>
     </UndefinedFunction>
   </file>
-  <file src="apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php">
-    <ParamNameMismatch occurrences="1">
-      <code>$arguments</code>
-    </ParamNameMismatch>
-  </file>
-  <file src="apps/dav/lib/BackgroundJob/EventReminderJob.php">
-    <ParamNameMismatch occurrences="1">
-      <code>$arg</code>
-    </ParamNameMismatch>
-  </file>
-  <file src="apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php">
-    <ParamNameMismatch occurrences="1">
-      <code>$arguments</code>
-    </ParamNameMismatch>
-  </file>
-  <file src="apps/dav/lib/BackgroundJob/UploadCleanup.php">
-    <InvalidArgument occurrences="1">
-      <code>File</code>
-    </InvalidArgument>
-  </file>
   <file src="apps/dav/lib/CalDAV/BirthdayService.php">
     <UndefinedMethod occurrences="2">
       <code>setDateTime</code>
     </UndefinedPropertyFetch>
   </file>
   <file src="apps/dav/lib/CalDAV/CachedSubscription.php">
-    <LessSpecificImplementedReturnType occurrences="1">
-      <code>array</code>
-    </LessSpecificImplementedReturnType>
-    <MoreSpecificImplementedParamType occurrences="1">
-      <code>$calendarData</code>
-    </MoreSpecificImplementedParamType>
     <ParamNameMismatch occurrences="1">
       <code>$calendarData</code>
     </ParamNameMismatch>
   </file>
   <file src="apps/dav/lib/CalDAV/CachedSubscriptionObject.php">
-    <ImplementedReturnTypeMismatch occurrences="1">
-      <code>string|void</code>
-    </ImplementedReturnTypeMismatch>
     <NullableReturnStatement occurrences="1">
       <code>$this-&gt;objectData['calendardata']</code>
     </NullableReturnStatement>
       <code>$paths</code>
     </MoreSpecificImplementedParamType>
   </file>
-  <file src="apps/dav/lib/CalDAV/Publishing/PublishPlugin.php">
-    <InvalidOperand occurrences="2">
-      <code>$canPublish</code>
-      <code>$canShare</code>
-    </InvalidOperand>
-    <InvalidScalarArgument occurrences="2">
-      <code>$canPublish</code>
-      <code>$canShare</code>
-    </InvalidScalarArgument>
-  </file>
   <file src="apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php">
     <UndefinedMethod occurrences="3">
       <code>hasTime</code>
     </UndefinedMethod>
   </file>
   <file src="apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php">
-    <FalsableReturnStatement occurrences="4">
-      <code>$l10n-&gt;l('date', $dt, ['width' =&gt; 'medium'])</code>
-      <code>$l10n-&gt;l('datetime', $dt, ['width' =&gt; 'medium|short'])</code>
-      <code>$l10n-&gt;l('time', $dt, ['width' =&gt; 'short'])</code>
-      <code>$l10n-&gt;l('weekdayName', $dt, ['width' =&gt; 'abbreviated'])</code>
-    </FalsableReturnStatement>
-    <InvalidReturnStatement occurrences="4">
-      <code>$l10n-&gt;l('date', $dt, ['width' =&gt; 'medium'])</code>
-      <code>$l10n-&gt;l('datetime', $dt, ['width' =&gt; 'medium|short'])</code>
-      <code>$l10n-&gt;l('time', $dt, ['width' =&gt; 'short'])</code>
-      <code>$l10n-&gt;l('weekdayName', $dt, ['width' =&gt; 'abbreviated'])</code>
-    </InvalidReturnStatement>
-    <InvalidReturnType occurrences="4">
-      <code>string</code>
-      <code>string</code>
-      <code>string</code>
-      <code>string</code>
-    </InvalidReturnType>
     <UndefinedMethod occurrences="3">
       <code>getDateTime</code>
       <code>getDateTime</code>
       <code>isFloating</code>
     </UndefinedMethod>
   </file>
-  <file src="apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php">
-    <PossiblyInvalidDocblockTag occurrences="1">
-      <code>@var VEvent $vevent</code>
-    </PossiblyInvalidDocblockTag>
-  </file>
   <file src="apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php">
     <UndefinedConstant occurrences="1">
       <code>$provider::NOTIFICATION_TYPE</code>
     </UndefinedConstant>
   </file>
-  <file src="apps/dav/lib/CalDAV/Reminder/Notifier.php">
-    <FalsableReturnStatement occurrences="4">
-      <code>$this-&gt;l10n-&gt;l('date', $dt, ['width' =&gt; 'medium'])</code>
-      <code>$this-&gt;l10n-&gt;l('datetime', $dt, ['width' =&gt; 'medium|short'])</code>
-      <code>$this-&gt;l10n-&gt;l('time', $dt, ['width' =&gt; 'short'])</code>
-      <code>$this-&gt;l10n-&gt;l('weekdayName', $dt, ['width' =&gt; 'abbreviated'])</code>
-    </FalsableReturnStatement>
-    <InvalidReturnStatement occurrences="4">
-      <code>$this-&gt;l10n-&gt;l('date', $dt, ['width' =&gt; 'medium'])</code>
-      <code>$this-&gt;l10n-&gt;l('datetime', $dt, ['width' =&gt; 'medium|short'])</code>
-      <code>$this-&gt;l10n-&gt;l('time', $dt, ['width' =&gt; 'short'])</code>
-      <code>$this-&gt;l10n-&gt;l('weekdayName', $dt, ['width' =&gt; 'abbreviated'])</code>
-    </InvalidReturnStatement>
-    <InvalidReturnType occurrences="4">
-      <code>string</code>
-      <code>string</code>
-      <code>string</code>
-      <code>string</code>
-    </InvalidReturnType>
-  </file>
   <file src="apps/dav/lib/CalDAV/Reminder/ReminderService.php">
     <UndefinedMethod occurrences="3">
       <code>getDateInterval</code>
       <code>'\OCA\DAV\CardDAV\CardDavBackend::deleteCard'</code>
       <code>'\OCA\DAV\CardDAV\CardDavBackend::updateCard'</code>
     </InvalidArgument>
-    <InvalidNullableReturnType occurrences="1">
-      <code>array</code>
-    </InvalidNullableReturnType>
-    <MoreSpecificImplementedParamType occurrences="1">
-      <code>$uris</code>
-    </MoreSpecificImplementedParamType>
-    <NullableReturnStatement occurrences="1">
-      <code>null</code>
-    </NullableReturnStatement>
-    <ParamNameMismatch occurrences="1">
-      <code>$addressBookId</code>
-    </ParamNameMismatch>
-    <RedundantCast occurrences="1">
-      <code>(int)$addressBookId</code>
-    </RedundantCast>
     <TooManyArguments occurrences="3">
       <code>dispatch</code>
       <code>dispatch</code>
       <code>\Sabre\Uri\split($principal)</code>
     </UndefinedFunction>
   </file>
-  <file src="apps/dav/lib/CardDAV/SyncService.php">
-    <InvalidScalarArgument occurrences="1">
-      <code>$targetBookId</code>
-    </InvalidScalarArgument>
-  </file>
   <file src="apps/dav/lib/CardDAV/UserAddressBooks.php">
     <InvalidArgument occurrences="2">
       <code>$this-&gt;principalUri</code>