Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-04-12 15:01:13 +0300
committerCarl Schwan <carl@carlschwan.eu>2022-05-05 23:03:59 +0300
commit829490ab7a02579c6b31573c3f53428e86cbf2e0 (patch)
tree1f644d168039ea1875398234419ace13f49dac5f /apps/dav/lib/Connector/Sabre
parent0690646d09430ce363b07bc2cd59283e303314eb (diff)
Cleanup dav
- Remove unused class AppEnabledPlugin - Add more type hinting when possible Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/dav/lib/Connector/Sabre')
-rw-r--r--apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php88
-rw-r--r--apps/dav/lib/Connector/Sabre/Auth.php47
-rw-r--r--apps/dav/lib/Connector/Sabre/BearerAuth.php20
-rw-r--r--apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php13
-rw-r--r--apps/dav/lib/Connector/Sabre/CachingTree.php9
-rw-r--r--apps/dav/lib/Connector/Sabre/ChecksumList.php7
-rw-r--r--apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php10
-rw-r--r--apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php40
-rw-r--r--apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php4
-rw-r--r--apps/dav/lib/Connector/Sabre/Directory.php25
-rw-r--r--apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php4
-rw-r--r--apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php21
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesPlugin.php81
-rw-r--r--apps/dav/lib/Connector/Sabre/ServerFactory.php37
-rw-r--r--apps/dav/lib/Connector/Sabre/SharesPlugin.php50
15 files changed, 117 insertions, 339 deletions
diff --git a/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php b/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php
deleted file mode 100644
index 244e5de0683..00000000000
--- a/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Georg Ehrke <oc.list@georgehrke.com>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OCA\DAV\Connector\Sabre;
-
-use OCP\App\IAppManager;
-use Sabre\DAV\Exception\Forbidden;
-use Sabre\DAV\ServerPlugin;
-
-/**
- * Plugin to check if an app is enabled for the current user
- */
-class AppEnabledPlugin extends ServerPlugin {
-
- /**
- * Reference to main server object
- *
- * @var \Sabre\DAV\Server
- */
- private $server;
-
- /**
- * @var string
- */
- private $app;
-
- /**
- * @var \OCP\App\IAppManager
- */
- private $appManager;
-
- /**
- * @param string $app
- * @param \OCP\App\IAppManager $appManager
- */
- public function __construct($app, IAppManager $appManager) {
- $this->app = $app;
- $this->appManager = $appManager;
- }
-
- /**
- * This initializes the plugin.
- *
- * This function is called by \Sabre\DAV\Server, after
- * addPlugin is called.
- *
- * This method should set up the required event subscriptions.
- *
- * @param \Sabre\DAV\Server $server
- * @return void
- */
- public function initialize(\Sabre\DAV\Server $server) {
- $this->server = $server;
- $this->server->on('beforeMethod:*', [$this, 'checkAppEnabled'], 30);
- }
-
- /**
- * This method is called before any HTTP after auth and checks if the user has access to the app
- *
- * @throws \Sabre\DAV\Exception\Forbidden
- * @return bool
- */
- public function checkAppEnabled() {
- if (!$this->appManager->isEnabledForUser($this->app)) {
- throw new Forbidden();
- }
- }
-}
diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php
index d81a3f9d667..1588e5a2e6c 100644
--- a/apps/dav/lib/Connector/Sabre/Auth.php
+++ b/apps/dav/lib/Connector/Sabre/Auth.php
@@ -51,33 +51,19 @@ use Sabre\HTTP\ResponseInterface;
class Auth extends AbstractBasic {
public const DAV_AUTHENTICATED = 'AUTHENTICATED_TO_DAV_BACKEND';
- /** @var ISession */
- private $session;
- /** @var Session */
- private $userSession;
- /** @var IRequest */
- private $request;
- /** @var string */
- private $currentUser;
- /** @var Manager */
- private $twoFactorManager;
- /** @var Throttler */
- private $throttler;
+ private ISession $session;
+ private Session $userSession;
+ private IRequest $request;
+ private string $currentUser;
+ private Manager $twoFactorManager;
+ private Throttler $throttler;
- /**
- * @param ISession $session
- * @param Session $userSession
- * @param IRequest $request
- * @param Manager $twoFactorManager
- * @param Throttler $throttler
- * @param string $principalPrefix
- */
public function __construct(ISession $session,
Session $userSession,
IRequest $request,
Manager $twoFactorManager,
Throttler $throttler,
- $principalPrefix = 'principals/users/') {
+ string $principalPrefix = 'principals/users/') {
$this->session = $session;
$this->userSession = $userSession;
$this->twoFactorManager = $twoFactorManager;
@@ -97,11 +83,8 @@ class Auth extends AbstractBasic {
* account was changed.
*
* @see https://github.com/owncloud/core/issues/13245
- *
- * @param string $username
- * @return bool
*/
- public function isDavAuthenticated($username) {
+ public function isDavAuthenticated(string $username): bool {
return !is_null($this->session->get(self::DAV_AUTHENTICATED)) &&
$this->session->get(self::DAV_AUTHENTICATED) === $username;
}
@@ -144,9 +127,7 @@ class Auth extends AbstractBasic {
}
/**
- * @param RequestInterface $request
- * @param ResponseInterface $response
- * @return array
+ * @return array{bool, string}
* @throws NotAuthenticated
* @throws ServiceUnavailable
*/
@@ -165,10 +146,8 @@ class Auth extends AbstractBasic {
/**
* Checks whether a CSRF check is required on the request
- *
- * @return bool
*/
- private function requiresCSRFCheck() {
+ private function requiresCSRFCheck(): bool {
// GET requires no check at all
if ($this->request->getMethod() === 'GET') {
return false;
@@ -203,12 +182,10 @@ class Auth extends AbstractBasic {
}
/**
- * @param RequestInterface $request
- * @param ResponseInterface $response
- * @return array
+ * @return array{bool, string}
* @throws NotAuthenticated
*/
- private function auth(RequestInterface $request, ResponseInterface $response) {
+ private function auth(RequestInterface $request, ResponseInterface $response): array {
$forcedLogout = false;
if (!$this->request->passesCSRFCheck() &&
diff --git a/apps/dav/lib/Connector/Sabre/BearerAuth.php b/apps/dav/lib/Connector/Sabre/BearerAuth.php
index d28a9cfdb84..5a69d07b002 100644
--- a/apps/dav/lib/Connector/Sabre/BearerAuth.php
+++ b/apps/dav/lib/Connector/Sabre/BearerAuth.php
@@ -31,21 +31,11 @@ use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
class BearerAuth extends AbstractBearer {
- /** @var IUserSession */
- private $userSession;
- /** @var ISession */
- private $session;
- /** @var IRequest */
- private $request;
- /** @var string */
- private $principalPrefix;
+ private IUserSession $userSession;
+ private ISession $session;
+ private IRequest $request;
+ private string $principalPrefix;
- /**
- * @param IUserSession $userSession
- * @param ISession $session
- * @param string $principalPrefix
- * @param IRequest $request
- */
public function __construct(IUserSession $userSession,
ISession $session,
IRequest $request,
@@ -90,7 +80,7 @@ class BearerAuth extends AbstractBearer {
* @param RequestInterface $request
* @param ResponseInterface $response
*/
- public function challenge(RequestInterface $request, ResponseInterface $response) {
+ public function challenge(RequestInterface $request, ResponseInterface $response): void {
$response->setStatus(401);
}
}
diff --git a/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php b/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php
index 8e2ea4d4e16..830c92d2c30 100644
--- a/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php
@@ -28,6 +28,7 @@ namespace OCA\DAV\Connector\Sabre;
use OCP\IConfig;
use Sabre\DAV\ServerPlugin;
use Sabre\HTTP\RequestInterface;
+use Sabre\DAV\Server;
/**
* Class BlockLegacyClientPlugin is used to detect old legacy sync clients and
@@ -36,23 +37,17 @@ use Sabre\HTTP\RequestInterface;
* @package OCA\DAV\Connector\Sabre
*/
class BlockLegacyClientPlugin extends ServerPlugin {
- /** @var \Sabre\DAV\Server */
- protected $server;
- /** @var IConfig */
- protected $config;
+ protected Server $server;
+ protected IConfig $config;
- /**
- * @param IConfig $config
- */
public function __construct(IConfig $config) {
$this->config = $config;
}
/**
- * @param \Sabre\DAV\Server $server
* @return void
*/
- public function initialize(\Sabre\DAV\Server $server) {
+ public function initialize(Server $server) {
$this->server = $server;
$this->server->on('beforeMethod:*', [$this, 'beforeHandler'], 200);
}
diff --git a/apps/dav/lib/Connector/Sabre/CachingTree.php b/apps/dav/lib/Connector/Sabre/CachingTree.php
index eb1233d3540..81ffd47a977 100644
--- a/apps/dav/lib/Connector/Sabre/CachingTree.php
+++ b/apps/dav/lib/Connector/Sabre/CachingTree.php
@@ -28,17 +28,18 @@ use Sabre\DAV\Tree;
class CachingTree extends Tree {
/**
* Store a node in the cache
- *
- * @param Node $node
- * @param null|string $path
*/
- public function cacheNode(Node $node, $path = null) {
+ public function cacheNode(Node $node, ?string $path = null): void {
if (is_null($path)) {
$path = $node->getPath();
}
$this->cache[trim($path, '/')] = $node;
}
+ /**
+ * @param string $path
+ * @return void
+ */
public function markDirty($path) {
// We don't care enough about sub-paths
// flushing the entire cache
diff --git a/apps/dav/lib/Connector/Sabre/ChecksumList.php b/apps/dav/lib/Connector/Sabre/ChecksumList.php
index 74cdc98ef4f..344e6a4ab3c 100644
--- a/apps/dav/lib/Connector/Sabre/ChecksumList.php
+++ b/apps/dav/lib/Connector/Sabre/ChecksumList.php
@@ -35,12 +35,9 @@ class ChecksumList implements XmlSerializable {
public const NS_OWNCLOUD = 'http://owncloud.org/ns';
/** @var string[] of TYPE:CHECKSUM */
- private $checksums;
+ private array $checksums;
- /**
- * @param string $checksum
- */
- public function __construct($checksum) {
+ public function __construct(string $checksum) {
$this->checksums = explode(',', $checksum);
}
diff --git a/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php b/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php
index 3247259357f..c023d918c42 100644
--- a/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php
+++ b/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php
@@ -26,14 +26,12 @@ namespace OCA\DAV\Connector\Sabre;
use Sabre\DAV\ServerPlugin;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
+use Sabre\DAV\Server;
class ChecksumUpdatePlugin extends ServerPlugin {
- /**
- * @var \Sabre\DAV\Server
- */
- protected $server;
+ protected Server $server;
- public function initialize(\Sabre\DAV\Server $server) {
+ public function initialize(Server $server) {
$this->server = $server;
$server->on('method:PATCH', [$this, 'httpPatch']);
}
@@ -42,6 +40,7 @@ class ChecksumUpdatePlugin extends ServerPlugin {
return 'checksumupdate';
}
+ /** @return string[] */
public function getHTTPMethods($path): array {
$tree = $this->server->tree;
@@ -55,6 +54,7 @@ class ChecksumUpdatePlugin extends ServerPlugin {
return [];
}
+ /** @return string[] */
public function getFeatures(): array {
return ['nextcloud-checksum-update'];
}
diff --git a/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php b/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php
index 82980553fa8..f9a087daeb0 100644
--- a/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php
@@ -29,22 +29,17 @@ use OCP\Comments\ICommentsManager;
use OCP\IUserSession;
use Sabre\DAV\PropFind;
use Sabre\DAV\ServerPlugin;
+use Sabre\DAV\Server;
class CommentPropertiesPlugin extends ServerPlugin {
public const PROPERTY_NAME_HREF = '{http://owncloud.org/ns}comments-href';
public const PROPERTY_NAME_COUNT = '{http://owncloud.org/ns}comments-count';
public const PROPERTY_NAME_UNREAD = '{http://owncloud.org/ns}comments-unread';
- /** @var \Sabre\DAV\Server */
- protected $server;
-
- /** @var ICommentsManager */
- private $commentsManager;
-
- /** @var IUserSession */
- private $userSession;
-
- private $cachedUnreadCount = [];
+ protected Server $server;
+ private ICommentsManager $commentsManager;
+ private IUserSession $userSession;
+ private array $cachedUnreadCount = [];
public function __construct(ICommentsManager $commentsManager, IUserSession $userSession) {
$this->commentsManager = $commentsManager;
@@ -67,7 +62,7 @@ class CommentPropertiesPlugin extends ServerPlugin {
$this->server->on('propFind', [$this, 'handleGetProperties']);
}
- private function cacheDirectory(Directory $directory) {
+ private function cacheDirectory(Directory $directory): void {
$children = $directory->getChildren();
$ids = [];
@@ -109,14 +104,14 @@ class CommentPropertiesPlugin extends ServerPlugin {
}
// need prefetch ?
- if ($node instanceof \OCA\DAV\Connector\Sabre\Directory
+ if ($node instanceof Directory
&& $propFind->getDepth() !== 0
&& !is_null($propFind->getStatus(self::PROPERTY_NAME_UNREAD))
) {
$this->cacheDirectory($node);
}
- $propFind->handle(self::PROPERTY_NAME_COUNT, function () use ($node) {
+ $propFind->handle(self::PROPERTY_NAME_COUNT, function () use ($node): int {
return $this->commentsManager->getNumberOfCommentsForObject('files', (string)$node->getId());
});
@@ -124,19 +119,15 @@ class CommentPropertiesPlugin extends ServerPlugin {
return $this->getCommentsLink($node);
});
- $propFind->handle(self::PROPERTY_NAME_UNREAD, function () use ($node) {
- if (isset($this->cachedUnreadCount[$node->getId()])) {
- return $this->cachedUnreadCount[$node->getId()];
- }
- return $this->getUnreadCount($node);
+ $propFind->handle(self::PROPERTY_NAME_UNREAD, function () use ($node): ?bool {
+ return $this->cachedUnreadCount[$node->getId()] ?? $this->getUnreadCount($node);
});
}
/**
- * returns a reference to the comments node
+ * Returns a reference to the comments node
*
- * @param Node $node
- * @return mixed|string
+ * @return array|string|null
*/
public function getCommentsLink(Node $node) {
$href = $this->server->getBaseUri();
@@ -151,13 +142,10 @@ class CommentPropertiesPlugin extends ServerPlugin {
}
/**
- * returns the number of unread comments for the currently logged in user
+ * Returns the number of unread comments for the currently logged in user
* on the given file or directory node
- *
- * @param Node $node
- * @return Int|null
*/
- public function getUnreadCount(Node $node) {
+ public function getUnreadCount(Node $node): ?int {
$user = $this->userSession->getUser();
if (is_null($user)) {
return null;
diff --git a/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php b/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php
index 029e631f4d9..5dd0dc6f231 100644
--- a/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/CopyEtagHeaderPlugin.php
@@ -27,6 +27,7 @@ namespace OCA\DAV\Connector\Sabre;
use Sabre\DAV\Exception\NotFound;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
+use Sabre\DAV\Server;
/**
* Copies the "Etag" header to "OC-Etag" after any request.
@@ -34,9 +35,8 @@ use Sabre\HTTP\ResponseInterface;
* or mangle Etag headers.
*/
class CopyEtagHeaderPlugin extends \Sabre\DAV\ServerPlugin {
+ private Server $server;
- /** @var \Sabre\DAV\Server */
- private $server;
/**
* This initializes the plugin.
*
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index ed98b5050f8..5280511d5be 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -54,40 +54,27 @@ use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Exception\ServiceUnavailable;
use Sabre\DAV\IFile;
use Sabre\DAV\INode;
+use OCP\Share\IManager as IShareManager;
class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget, \Sabre\DAV\ICopyTarget {
/**
* Cached directory content
- *
* @var \OCP\Files\FileInfo[]
*/
- private $dirContent;
+ private ?array $dirContent = null;
- /**
- * Cached quota info
- *
- * @var array
- */
- private $quotaInfo;
-
- /**
- * @var ObjectTree|null
- */
- private $tree;
+ /** Cached quota info */
+ private ?array $quotaInfo = null;
+ private ?ObjectTree $tree = null;
/** @var array<string, array<int, FileMetadata>> */
private array $metadata = [];
/**
* Sets up the node, expects a full path name
- *
- * @param \OC\Files\View $view
- * @param \OCP\Files\FileInfo $info
- * @param ObjectTree|null $tree
- * @param \OCP\Share\IManager $shareManager
*/
- public function __construct(View $view, FileInfo $info, $tree = null, $shareManager = null) {
+ public function __construct(View $view, FileInfo $info, ?ObjectTree $tree = null, IShareManager $shareManager = null) {
parent::__construct($view, $info, $shareManager);
$this->tree = $tree;
}
diff --git a/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php b/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php
index 3a8469e99b4..bc6c6f5c25f 100644
--- a/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php
+++ b/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php
@@ -28,6 +28,7 @@ namespace OCA\DAV\Connector\Sabre;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
+use Sabre\DAV\Server;
/**
* Class DummyGetResponsePlugin is a plugin used to not show a "Not implemented"
@@ -43,8 +44,7 @@ use Sabre\HTTP\ResponseInterface;
* @package OCA\DAV\Connector\Sabre
*/
class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin {
- /** @var \Sabre\DAV\Server */
- protected $server;
+ protected Server $server;
/**
* @param \Sabre\DAV\Server $server
diff --git a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php
index e89ce3a8037..c803358ede1 100644
--- a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php
@@ -83,16 +83,13 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
RequestedRangeNotSatisfiable::class => true,
];
- /** @var string */
- private $appName;
-
+ private string $appName;
private LoggerInterface $logger;
/**
* @param string $loggerAppName app name to use when logging
- * @param LoggerInterface $logger
*/
- public function __construct($loggerAppName, LoggerInterface $logger) {
+ public function __construct(string $loggerAppName, LoggerInterface $logger) {
$this->appName = $loggerAppName;
$this->logger = $logger;
}
@@ -114,9 +111,8 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
/**
* Log exception
- *
*/
- public function logException(\Throwable $ex) {
+ public function logException(\Throwable $ex): void {
$exceptionClass = get_class($ex);
if (isset($this->nonFatalExceptions[$exceptionClass]) ||
(
@@ -128,11 +124,12 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
'app' => $this->appName,
'exception' => $ex,
]);
- } else {
- $this->logger->critical($ex->getMessage(), [
- 'app' => $this->appName,
- 'exception' => $ex,
- ]);
+ return;
}
+
+ $this->logger->critical($ex->getMessage(), [
+ 'app' => $this->appName,
+ 'exception' => $ex,
+ ]);
}
}
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
index 9c4f912610b..9474ed91f85 100644
--- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
@@ -49,6 +49,7 @@ use Sabre\DAV\IFile;
use Sabre\DAV\PropFind;
use Sabre\DAV\PropPatch;
use Sabre\DAV\ServerPlugin;
+use Sabre\DAV\Server;
use Sabre\DAV\Tree;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
@@ -84,66 +85,28 @@ class FilesPlugin extends ServerPlugin {
public const SUBFILE_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-file-count';
public const FILE_METADATA_SIZE = '{http://nextcloud.org/ns}file-metadata-size';
- /**
- * Reference to main server object
- *
- * @var \Sabre\DAV\Server
- */
- private $server;
-
- /**
- * @var Tree
- */
- private $tree;
-
- /**
- * @var IUserSession
- */
- private $userSession;
+ /** Reference to main server object */
+ private Server $server;
+ private Tree $tree;
+ private IUserSession $userSession;
/**
* Whether this is public webdav.
* If true, some returned information will be stripped off.
- *
- * @var bool
- */
- private $isPublic;
-
- /**
- * @var bool
*/
- private $downloadAttachment;
+ private bool $isPublic;
+ private bool $downloadAttachment;
+ private IConfig $config;
+ private IRequest $request;
+ private IPreview $previewManager;
- /**
- * @var IConfig
- */
- private $config;
-
- /**
- * @var IRequest
- */
- private $request;
-
- /**
- * @var IPreview
- */
- private $previewManager;
-
- /**
- * @param Tree $tree
- * @param IConfig $config
- * @param IRequest $request
- * @param IPreview $previewManager
- * @param bool $isPublic
- * @param bool $downloadAttachment
- */
public function __construct(Tree $tree,
IConfig $config,
IRequest $request,
IPreview $previewManager,
IUserSession $userSession,
- $isPublic = false,
- $downloadAttachment = true) {
+ bool $isPublic = false,
+ bool $downloadAttachment = true) {
$this->tree = $tree;
$this->config = $config;
$this->request = $request;
@@ -161,10 +124,9 @@ class FilesPlugin extends ServerPlugin {
*
* This method should set up the required event subscriptions.
*
- * @param \Sabre\DAV\Server $server
* @return void
*/
- public function initialize(\Sabre\DAV\Server $server) {
+ public function initialize(Server $server) {
$server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
$server->xml->namespaceMap[self::NS_NEXTCLOUD] = 'nc';
$server->protectedProperties[] = self::FILEID_PROPERTYNAME;
@@ -347,7 +309,7 @@ class FilesPlugin extends ServerPlugin {
);
});
- $propFind->handle(self::OCM_SHARE_PERMISSIONS_PROPERTYNAME, function () use ($node, $httpRequest) {
+ $propFind->handle(self::OCM_SHARE_PERMISSIONS_PROPERTYNAME, function () use ($node, $httpRequest): ?string {
$user = $this->userSession->getUser();
if ($user === null) {
return null;
@@ -359,11 +321,11 @@ class FilesPlugin extends ServerPlugin {
return json_encode($ocmPermissions);
});
- $propFind->handle(self::GETETAG_PROPERTYNAME, function () use ($node) {
+ $propFind->handle(self::GETETAG_PROPERTYNAME, function () use ($node): string {
return $node->getETag();
});
- $propFind->handle(self::OWNER_ID_PROPERTYNAME, function () use ($node) {
+ $propFind->handle(self::OWNER_ID_PROPERTYNAME, function () use ($node): ?string {
$owner = $node->getOwner();
if (!$owner) {
return null;
@@ -371,7 +333,7 @@ class FilesPlugin extends ServerPlugin {
return $owner->getUID();
}
});
- $propFind->handle(self::OWNER_DISPLAY_NAME_PROPERTYNAME, function () use ($node) {
+ $propFind->handle(self::OWNER_DISPLAY_NAME_PROPERTYNAME, function () use ($node): ?string {
$owner = $node->getOwner();
if (!$owner) {
return null;
@@ -383,14 +345,14 @@ 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) {
+ $propFind->handle(self::SIZE_PROPERTYNAME, function () use ($node): int {
return $node->getSize();
});
$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) {
return $node->getFileInfo()->getMountPoint()->getMountType();
});
- $propFind->handle(self::SHARE_NOTE, function () use ($node, $httpRequest) {
+ $propFind->handle(self::SHARE_NOTE, function () use ($node, $httpRequest): ?string {
$user = $this->userSession->getUser();
if ($user === null) {
return null;
@@ -569,10 +531,7 @@ class FilesPlugin extends ServerPlugin {
if (empty($etag)) {
return false;
}
- if ($node->setEtag($etag) !== -1) {
- return true;
- }
- return false;
+ return $node->setEtag($etag) !== -1;
});
$propPatch->handle(self::CREATIONDATE_PROPERTYNAME, function ($time) use ($node) {
if (empty($time)) {
diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php
index 635645ed992..8f1f710ca5e 100644
--- a/apps/dav/lib/Connector/Sabre/ServerFactory.php
+++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php
@@ -48,25 +48,16 @@ use Sabre\DAV\Auth\Plugin;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class ServerFactory {
- /** @var IConfig */
- private $config;
+ private IConfig $config;
private LoggerInterface $logger;
- /** @var IDBConnection */
- private $databaseConnection;
- /** @var IUserSession */
- private $userSession;
- /** @var IMountManager */
- private $mountManager;
- /** @var ITagManager */
- private $tagManager;
- /** @var IRequest */
- private $request;
- /** @var IPreview */
- private $previewManager;
- /** @var EventDispatcherInterface */
- private $eventDispatcher;
- /** @var IL10N */
- private $l10n;
+ private IDBConnection $databaseConnection;
+ private IUserSession $userSession;
+ private IMountManager $mountManager;
+ private ITagManager $tagManager;
+ private IRequest $request;
+ private IPreview $previewManager;
+ private EventDispatcherInterface $eventDispatcher;
+ private IL10N $l10n;
public function __construct(
IConfig $config,
@@ -93,16 +84,12 @@ class ServerFactory {
}
/**
- * @param string $baseUri
- * @param string $requestUri
- * @param Plugin $authPlugin
* @param callable $viewCallBack callback that should return the view for the dav endpoint
- * @return Server
*/
- public function createServer($baseUri,
- $requestUri,
+ public function createServer(string $baseUri,
+ string $requestUri,
Plugin $authPlugin,
- callable $viewCallBack) {
+ callable $viewCallBack): Server {
// Fire up server
$objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
$server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
diff --git a/apps/dav/lib/Connector/Sabre/SharesPlugin.php b/apps/dav/lib/Connector/Sabre/SharesPlugin.php
index 57c91e05a8c..9fa6775c3b5 100644
--- a/apps/dav/lib/Connector/Sabre/SharesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/SharesPlugin.php
@@ -30,10 +30,14 @@ namespace OCA\DAV\Connector\Sabre;
use OCA\DAV\Connector\Sabre\Node as DavNode;
use OCP\Files\Folder;
+use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IUserSession;
use OCP\Share\IShare;
+use OCP\Share\IManager;
use Sabre\DAV\PropFind;
+use Sabre\DAV\Tree;
+use Sabre\DAV\Server;
/**
* Sabre Plugin to provide share-related properties
@@ -50,36 +54,20 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin {
* @var \Sabre\DAV\Server
*/
private $server;
-
- /** @var \OCP\Share\IManager */
- private $shareManager;
-
- /** @var \Sabre\DAV\Tree */
- private $tree;
-
- /** @var string */
- private $userId;
-
- /** @var \OCP\Files\Folder */
- private $userFolder;
-
+ private IManager $shareManager;
+ private Tree $tree;
+ private string $userId;
+ private Folder $userFolder;
/** @var IShare[][] */
- private $cachedShares = [];
-
+ private array $cachedShares = [];
/** @var string[] */
- private $cachedFolders = [];
+ private array $cachedFolders = [];
- /**
- * @param \Sabre\DAV\Tree $tree tree
- * @param IUserSession $userSession user session
- * @param \OCP\Files\Folder $userFolder user home folder
- * @param \OCP\Share\IManager $shareManager share manager
- */
public function __construct(
- \Sabre\DAV\Tree $tree,
+ Tree $tree,
IUserSession $userSession,
- \OCP\Files\Folder $userFolder,
- \OCP\Share\IManager $shareManager
+ Folder $userFolder,
+ IManager $shareManager
) {
$this->tree = $tree;
$this->shareManager = $shareManager;
@@ -95,9 +83,9 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin {
*
* This method should set up the required event subscriptions.
*
- * @param \Sabre\DAV\Server $server
+ * @return void
*/
- public function initialize(\Sabre\DAV\Server $server) {
+ public function initialize(Server $server) {
$server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
$server->xml->elementMap[self::SHARETYPES_PROPERTYNAME] = ShareTypeList::class;
$server->protectedProperties[] = self::SHARETYPES_PROPERTYNAME;
@@ -108,10 +96,10 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin {
}
/**
- * @param \OCP\Files\Node $node
+ * @param Node $node
* @return IShare[]
*/
- private function getShare(\OCP\Files\Node $node): array {
+ private function getShare(Node $node): array {
$result = [];
$requestedShareTypes = [
IShare::TYPE_USER,
@@ -209,7 +197,7 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin {
}
}
- $propFind->handle(self::SHARETYPES_PROPERTYNAME, function () use ($sabreNode) {
+ $propFind->handle(self::SHARETYPES_PROPERTYNAME, function () use ($sabreNode): ShareTypeList {
$shares = $this->getShares($sabreNode);
$shareTypes = array_unique(array_map(function (IShare $share) {
@@ -219,7 +207,7 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin {
return new ShareTypeList($shareTypes);
});
- $propFind->handle(self::SHAREES_PROPERTYNAME, function () use ($sabreNode) {
+ $propFind->handle(self::SHAREES_PROPERTYNAME, function () use ($sabreNode): ShareeList {
$shares = $this->getShares($sabreNode);
return new ShareeList($shares);