diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-05-23 10:16:03 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-05-24 12:05:17 +0200 |
commit | 3ada267a0224ac7b1fd642a5eb21a7be700c691a (patch) | |
tree | 05b845aa13722f2f497dcf93507af0ee05f577c6 | |
parent | 74d81655e8b0625b436628c34dfc907f6be7f300 (diff) | |
download | nextcloud-server-3ada267a0224ac7b1fd642a5eb21a7be700c691a.tar.gz nextcloud-server-3ada267a0224ac7b1fd642a5eb21a7be700c691a.zip |
Fix return type and make type stricter
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r-- | apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php | 14 | ||||
-rw-r--r-- | build/psalm-baseline.xml | 5 |
2 files changed, 6 insertions, 13 deletions
diff --git a/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php b/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php index 4a1205e8606..eaa7f1bc2d2 100644 --- a/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php @@ -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/')); } /** diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index fbcbe1ebb62..124c0819c33 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -472,11 +472,6 @@ <code>tryTokenLogin</code> </UndefinedInterfaceMethod> </file> - <file src="apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php"> - <InvalidScalarArgument occurrences="1"> - <code>$node->getId()</code> - </InvalidScalarArgument> - </file> <file src="apps/dav/lib/Connector/Sabre/Directory.php"> <InvalidPropertyAssignmentValue occurrences="1"> <code>$nodes</code> |