aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-11-25 11:19:47 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-06-20 10:55:20 +0200
commit9725d0032944ebe5a73d59781a66742c5d1ae404 (patch)
treed7f90b66e49297e276241ed3960716cddfbad49a /apps/dav/lib
parent5063bf37ed3e68041adb9a96f430a87d59106491 (diff)
downloadnextcloud-server-9725d0032944ebe5a73d59781a66742c5d1ae404.tar.gz
nextcloud-server-9725d0032944ebe5a73d59781a66742c5d1ae404.zip
Cleanup comments code
- Fix various psalm issues - Add as much typing as possible while preserving stable API Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/Comments/CommentNode.php4
-rw-r--r--apps/dav/lib/Comments/CommentsPlugin.php4
-rw-r--r--apps/dav/lib/Comments/EntityTypeCollection.php17
-rw-r--r--apps/dav/lib/Comments/RootCollection.php28
4 files changed, 15 insertions, 38 deletions
diff --git a/apps/dav/lib/Comments/CommentNode.php b/apps/dav/lib/Comments/CommentNode.php
index b41dbc276e8..690d5d6c709 100644
--- a/apps/dav/lib/Comments/CommentNode.php
+++ b/apps/dav/lib/Comments/CommentNode.php
@@ -165,10 +165,8 @@ class CommentNode implements \Sabre\DAV\INode, \Sabre\DAV\IProperties {
/**
* Returns the last modification time, as a unix timestamp
- *
- * @return int
*/
- public function getLastModified() {
+ public function getLastModified(): ?int {
return null;
}
diff --git a/apps/dav/lib/Comments/CommentsPlugin.php b/apps/dav/lib/Comments/CommentsPlugin.php
index f31e479c212..96e0285018d 100644
--- a/apps/dav/lib/Comments/CommentsPlugin.php
+++ b/apps/dav/lib/Comments/CommentsPlugin.php
@@ -176,7 +176,7 @@ class CommentsPlugin extends ServerPlugin {
}
if (!is_null($args['datetime'])) {
- $args['datetime'] = new \DateTime($args['datetime']);
+ $args['datetime'] = new \DateTime((string)$args['datetime']);
}
$results = $node->findChildren($args['limit'], $args['offset'], $args['datetime']);
@@ -189,7 +189,7 @@ class CommentsPlugin extends ServerPlugin {
$responses[] = new Response(
$this->server->getBaseUri() . $nodePath,
[200 => $resultSet[0][200]],
- 200
+ '200'
);
}
}
diff --git a/apps/dav/lib/Comments/EntityTypeCollection.php b/apps/dav/lib/Comments/EntityTypeCollection.php
index d140a33ec4c..32adcee54f0 100644
--- a/apps/dav/lib/Comments/EntityTypeCollection.php
+++ b/apps/dav/lib/Comments/EntityTypeCollection.php
@@ -42,25 +42,14 @@ use Sabre\DAV\Exception\NotFound;
* @package OCA\DAV\Comments
*/
class EntityTypeCollection extends RootCollection {
-
protected LoggerInterface $logger;
-
- /** @var IUserManager */
- protected $userManager;
+ protected IUserManager $userManager;
/** @var \Closure */
protected $childExistsFunction;
- /**
- * @param string $name
- * @param ICommentsManager $commentsManager
- * @param IUserManager $userManager
- * @param IUserSession $userSession
- * @param LoggerInterface $logger
- * @param \Closure $childExistsFunction
- */
public function __construct(
- $name,
+ string $name,
ICommentsManager $commentsManager,
IUserManager $userManager,
IUserSession $userSession,
@@ -68,7 +57,7 @@ class EntityTypeCollection extends RootCollection {
\Closure $childExistsFunction
) {
$name = trim($name);
- if (empty($name) || !is_string($name)) {
+ if (empty($name)) {
throw new \InvalidArgumentException('"name" parameter must be non-empty string');
}
$this->name = $name;
diff --git a/apps/dav/lib/Comments/RootCollection.php b/apps/dav/lib/Comments/RootCollection.php
index 9832030291e..39d644b4766 100644
--- a/apps/dav/lib/Comments/RootCollection.php
+++ b/apps/dav/lib/Comments/RootCollection.php
@@ -36,26 +36,14 @@ use Sabre\DAV\ICollection;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class RootCollection implements ICollection {
-
/** @var EntityTypeCollection[]|null */
- private $entityTypeCollections;
-
- /** @var ICommentsManager */
- protected $commentsManager;
-
- /** @var string */
- protected $name = 'comments';
-
+ private ?array $entityTypeCollections = null;
+ protected ICommentsManager $commentsManager;
+ protected string $name = 'comments';
protected LoggerInterface $logger;
-
- /** @var IUserManager */
- protected $userManager;
-
- /** @var IUserSession */
- protected $userSession;
-
- /** @var EventDispatcherInterface */
- protected $dispatcher;
+ protected IUserManager $userManager;
+ protected IUserSession $userSession;
+ protected EventDispatcherInterface $dispatcher;
public function __construct(
ICommentsManager $commentsManager,
@@ -149,6 +137,7 @@ class RootCollection implements ICollection {
*/
public function getChildren() {
$this->initCollections();
+ assert(!is_null($this->entityTypeCollections));
return $this->entityTypeCollections;
}
@@ -160,6 +149,7 @@ class RootCollection implements ICollection {
*/
public function childExists($name) {
$this->initCollections();
+ assert(!is_null($this->entityTypeCollections));
return isset($this->entityTypeCollections[$name]);
}
@@ -196,7 +186,7 @@ class RootCollection implements ICollection {
/**
* Returns the last modification time, as a unix timestamp
*
- * @return int
+ * @return ?int
*/
public function getLastModified() {
return null;