]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix return type and make type stricter 32548/head
authorCarl Schwan <carl@carlschwan.eu>
Mon, 23 May 2022 08:16:03 +0000 (10:16 +0200)
committerCarl Schwan <carl@carlschwan.eu>
Tue, 24 May 2022 10:05:17 +0000 (12:05 +0200)
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php
build/psalm-baseline.xml

index 4a1205e8606be66cf4370630c5c45479e6ccdfaa..eaa7f1bc2d2067d884c92d0b7124da865158ac4d 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2016, ownCloud, Inc.
  *
@@ -115,30 +116,27 @@ class CommentPropertiesPlugin extends ServerPlugin {
                        return $this->commentsManager->getNumberOfCommentsForObject('files', (string)$node->getId());
                });
 
-               $propFind->handle(self::PROPERTY_NAME_HREF, function () use ($node) {
+               $propFind->handle(self::PROPERTY_NAME_HREF, function () use ($node): ?string {
                        return $this->getCommentsLink($node);
                });
 
-               $propFind->handle(self::PROPERTY_NAME_UNREAD, function () use ($node): ?bool {
+               $propFind->handle(self::PROPERTY_NAME_UNREAD, function () use ($node): ?int {
                        return $this->cachedUnreadCount[$node->getId()] ?? $this->getUnreadCount($node);
                });
        }
 
        /**
         * Returns a reference to the comments node
-        *
-        * @return array|string|null
         */
-       public function getCommentsLink(Node $node) {
+       public function getCommentsLink(Node $node): ?string {
                $href = $this->server->getBaseUri();
                $entryPoint = strpos($href, '/remote.php/');
                if ($entryPoint === false) {
                        // in case we end up somewhere else, unexpectedly.
                        return null;
                }
-               $commentsPart = 'dav/comments/files/' . rawurldecode($node->getId());
-               $href = substr_replace($href, $commentsPart, $entryPoint + strlen('/remote.php/'));
-               return $href;
+               $commentsPart = 'dav/comments/files/' . rawurldecode((string)$node->getId());
+               return substr_replace($href, $commentsPart, $entryPoint + strlen('/remote.php/'));
        }
 
        /**
index fbcbe1ebb62aee0e5f5004834961d1d9ab812bcd..124c0819c33c67c72e6438296fcddbd93d686fcf 100644 (file)
       <code>tryTokenLogin</code>
     </UndefinedInterfaceMethod>
   </file>
-  <file src="apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php">
-    <InvalidScalarArgument occurrences="1">
-      <code>$node-&gt;getId()</code>
-    </InvalidScalarArgument>
-  </file>
   <file src="apps/dav/lib/Connector/Sabre/Directory.php">
     <InvalidPropertyAssignmentValue occurrences="1">
       <code>$nodes</code>