aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-10-18 12:04:22 +0200
committerprovokateurin <kate@provokateurin.de>2024-10-21 12:37:59 +0200
commit381077028adf388a7081cf42026570c6be47b198 (patch)
treec0f8e9b6caea80d6b55d6fdcc9188ba57197fa0f /apps/federatedfilesharing
parent4d8d11d2f79da348644e0902e78a2f000498cd52 (diff)
downloadnextcloud-server-381077028adf388a7081cf42026570c6be47b198.tar.gz
nextcloud-server-381077028adf388a7081cf42026570c6be47b198.zip
refactor(apps): Use constructor property promotion when possible
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'apps/federatedfilesharing')
-rw-r--r--apps/federatedfilesharing/lib/AddressHandler.php20
-rw-r--r--apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php8
-rw-r--r--apps/federatedfilesharing/lib/Controller/RequestHandlerController.php73
-rw-r--r--apps/federatedfilesharing/lib/Events/FederatedShareAddedEvent.php8
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php11
-rw-r--r--apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php8
-rw-r--r--apps/federatedfilesharing/lib/Notifications.php5
-rw-r--r--apps/federatedfilesharing/lib/Notifier.php19
-rw-r--r--apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php3
-rw-r--r--apps/federatedfilesharing/lib/Settings/Admin.php21
-rw-r--r--apps/federatedfilesharing/lib/Settings/Personal.php21
-rw-r--r--apps/federatedfilesharing/lib/Settings/PersonalSection.php12
-rw-r--r--apps/federatedfilesharing/lib/TokenHandler.php8
13 files changed, 63 insertions, 154 deletions
diff --git a/apps/federatedfilesharing/lib/AddressHandler.php b/apps/federatedfilesharing/lib/AddressHandler.php
index a2986618729..d21516c698c 100644
--- a/apps/federatedfilesharing/lib/AddressHandler.php
+++ b/apps/federatedfilesharing/lib/AddressHandler.php
@@ -20,30 +20,18 @@ use OCP\Util;
*/
class AddressHandler {
- /** @var IL10N */
- private $l;
-
- /** @var IURLGenerator */
- private $urlGenerator;
-
- /** @var ICloudIdManager */
- private $cloudIdManager;
-
/**
* AddressHandler constructor.
*
* @param IURLGenerator $urlGenerator
- * @param IL10N $il10n
+ * @param IL10N $l
* @param ICloudIdManager $cloudIdManager
*/
public function __construct(
- IURLGenerator $urlGenerator,
- IL10N $il10n,
- ICloudIdManager $cloudIdManager,
+ private IURLGenerator $urlGenerator,
+ private IL10N $l,
+ private ICloudIdManager $cloudIdManager,
) {
- $this->l = $il10n;
- $this->urlGenerator = $urlGenerator;
- $this->cloudIdManager = $cloudIdManager;
}
/**
diff --git a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
index f72209642ba..9d66cd71812 100644
--- a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
+++ b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
@@ -22,7 +22,6 @@ use OCP\BackgroundJob\Job;
*/
class RetryJob extends Job {
private bool $retainJob = true;
- private Notifications $notifications;
/** @var int max number of attempts to send the request */
private int $maxTry = 20;
@@ -30,10 +29,11 @@ class RetryJob extends Job {
/** @var int how much time should be between two tries (10 minutes) */
private int $interval = 600;
- public function __construct(Notifications $notifications,
- ITimeFactory $time) {
+ public function __construct(
+ private Notifications $notifications,
+ ITimeFactory $time,
+ ) {
parent::__construct($time);
- $this->notifications = $notifications;
}
/**
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
index d19414f3c11..222c6490b83 100644
--- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
+++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
@@ -26,6 +26,7 @@ use OCP\Federation\Exceptions\ProviderDoesNotExistsException;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudIdManager;
+use OCP\HintException;
use OCP\IDBConnection;
use OCP\IRequest;
use OCP\IUserManager;
@@ -38,69 +39,25 @@ use Psr\Log\LoggerInterface;
#[OpenAPI(scope: OpenAPI::SCOPE_FEDERATION)]
class RequestHandlerController extends OCSController {
- /** @var FederatedShareProvider */
- private $federatedShareProvider;
-
- /** @var IDBConnection */
- private $connection;
-
- /** @var Share\IManager */
- private $shareManager;
-
- /** @var Notifications */
- private $notifications;
-
- /** @var AddressHandler */
- private $addressHandler;
-
- /** @var IUserManager */
- private $userManager;
-
/** @var string */
private $shareTable = 'share';
- /** @var ICloudIdManager */
- private $cloudIdManager;
-
- /** @var LoggerInterface */
- private $logger;
-
- /** @var ICloudFederationFactory */
- private $cloudFederationFactory;
-
- /** @var ICloudFederationProviderManager */
- private $cloudFederationProviderManager;
-
- /** @var IEventDispatcher */
- private $eventDispatcher;
-
- public function __construct(string $appName,
+ public function __construct(
+ string $appName,
IRequest $request,
- FederatedShareProvider $federatedShareProvider,
- IDBConnection $connection,
- Share\IManager $shareManager,
- Notifications $notifications,
- AddressHandler $addressHandler,
- IUserManager $userManager,
- ICloudIdManager $cloudIdManager,
- LoggerInterface $logger,
- ICloudFederationFactory $cloudFederationFactory,
- ICloudFederationProviderManager $cloudFederationProviderManager,
- IEventDispatcher $eventDispatcher,
+ private FederatedShareProvider $federatedShareProvider,
+ private IDBConnection $connection,
+ private Share\IManager $shareManager,
+ private Notifications $notifications,
+ private AddressHandler $addressHandler,
+ private IUserManager $userManager,
+ private ICloudIdManager $cloudIdManager,
+ private LoggerInterface $logger,
+ private ICloudFederationFactory $cloudFederationFactory,
+ private ICloudFederationProviderManager $cloudFederationProviderManager,
+ private IEventDispatcher $eventDispatcher,
) {
parent::__construct($appName, $request);
-
- $this->federatedShareProvider = $federatedShareProvider;
- $this->connection = $connection;
- $this->shareManager = $shareManager;
- $this->notifications = $notifications;
- $this->addressHandler = $addressHandler;
- $this->userManager = $userManager;
- $this->cloudIdManager = $cloudIdManager;
- $this->logger = $logger;
- $this->cloudFederationFactory = $cloudFederationFactory;
- $this->cloudFederationProviderManager = $cloudFederationProviderManager;
- $this->eventDispatcher = $eventDispatcher;
}
/**
@@ -232,7 +189,7 @@ class RequestHandlerController extends OCSController {
* @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}>
* @throws OCSException
* @throws ShareNotFound
- * @throws \OCP\HintException
+ * @throws HintException
*
* 200: Share accepted successfully
*/
diff --git a/apps/federatedfilesharing/lib/Events/FederatedShareAddedEvent.php b/apps/federatedfilesharing/lib/Events/FederatedShareAddedEvent.php
index 7654262a57a..2a79f434b8c 100644
--- a/apps/federatedfilesharing/lib/Events/FederatedShareAddedEvent.php
+++ b/apps/federatedfilesharing/lib/Events/FederatedShareAddedEvent.php
@@ -17,14 +17,12 @@ use OCP\EventDispatcher\Event;
*/
class FederatedShareAddedEvent extends Event {
- /** @var string */
- private $remote;
-
/**
* @since 20.0.0
*/
- public function __construct(string $remote) {
- $this->remote = $remote;
+ public function __construct(
+ private string $remote,
+ ) {
}
/**
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index c115c613338..11e78f5cb97 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -17,6 +17,7 @@ use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
+use OCP\HintException;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
@@ -349,7 +350,7 @@ class FederatedShareProvider implements IShareProvider {
*
* @param IShare $share
* @throws ShareNotFound
- * @throws \OCP\HintException
+ * @throws HintException
*/
protected function sendPermissionUpdate(IShare $share) {
$remoteId = $this->getRemoteId($share);
@@ -458,7 +459,7 @@ class FederatedShareProvider implements IShareProvider {
*
* @param IShare $share
* @throws ShareNotFound
- * @throws \OCP\HintException
+ * @throws HintException
*/
public function delete(IShare $share) {
[, $remote] = $this->addressHandler->splitUserRemote($share->getSharedWith());
@@ -485,7 +486,7 @@ class FederatedShareProvider implements IShareProvider {
* @param IShare $share
* @param bool $isOwner the user can either be the owner or the user who re-sahred it
* @throws ShareNotFound
- * @throws \OCP\HintException
+ * @throws HintException
*/
protected function revokeShare($share, $isOwner) {
if ($this->userManager->userExists($share->getShareOwner()) && $this->userManager->userExists($share->getSharedBy())) {
@@ -680,7 +681,7 @@ class FederatedShareProvider implements IShareProvider {
/**
* Get shares for a given path
*
- * @param \OCP\Files\Node $path
+ * @param Node $path
* @return IShare[]
*/
public function getSharesByPath(Node $path) {
@@ -850,7 +851,7 @@ class FederatedShareProvider implements IShareProvider {
*
* @param string $userId
* @param int $id
- * @return \OCP\Files\Node
+ * @return Node
* @throws InvalidShare
*/
private function getNode($userId, $id) {
diff --git a/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php b/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php
index 78517e3a297..e78c93ec1a5 100644
--- a/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php
+++ b/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php
@@ -18,11 +18,9 @@ use OCP\Migration\SimpleMigrationStep;
class Version1011Date20201120125158 extends SimpleMigrationStep {
- /** @var IDBConnection */
- private $connection;
-
- public function __construct(IDBConnection $connection) {
- $this->connection = $connection;
+ public function __construct(
+ private IDBConnection $connection,
+ ) {
}
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php
index e107065d0c1..3c971773587 100644
--- a/apps/federatedfilesharing/lib/Notifications.php
+++ b/apps/federatedfilesharing/lib/Notifications.php
@@ -13,6 +13,7 @@ use OCP\BackgroundJob\IJobList;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
+use OCP\HintException;
use OCP\Http\Client\IClientService;
use OCP\OCS\IDiscoveryService;
use Psr\Log\LoggerInterface;
@@ -45,7 +46,7 @@ class Notifications {
* @param string $sharedByFederatedId
* @param int $shareType (can be a remote user or group share)
* @return bool
- * @throws \OCP\HintException
+ * @throws HintException
* @throws \OC\ServerNotAvailableException
*/
public function sendRemoteShare($token, $shareWith, $name, $remoteId, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) {
@@ -104,7 +105,7 @@ class Notifications {
* @param int $permission
* @param string $filename
* @return array|false
- * @throws \OCP\HintException
+ * @throws HintException
* @throws \OC\ServerNotAvailableException
*/
public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename) {
diff --git a/apps/federatedfilesharing/lib/Notifier.php b/apps/federatedfilesharing/lib/Notifier.php
index 4c4380d0875..10b57c578a2 100644
--- a/apps/federatedfilesharing/lib/Notifier.php
+++ b/apps/federatedfilesharing/lib/Notifier.php
@@ -18,16 +18,8 @@ use OCP\Notification\INotifier;
use OCP\Notification\UnknownNotificationException;
class Notifier implements INotifier {
- /** @var IFactory */
- protected $factory;
- /** @var IManager */
- protected $contactsManager;
- /** @var IURLGenerator */
- protected $url;
/** @var array */
protected $federatedContacts;
- /** @var ICloudIdManager */
- protected $cloudIdManager;
/**
* @param IFactory $factory
@@ -35,11 +27,12 @@ class Notifier implements INotifier {
* @param IURLGenerator $url
* @param ICloudIdManager $cloudIdManager
*/
- public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) {
- $this->factory = $factory;
- $this->contactsManager = $contactsManager;
- $this->url = $url;
- $this->cloudIdManager = $cloudIdManager;
+ public function __construct(
+ protected IFactory $factory,
+ protected IManager $contactsManager,
+ protected IURLGenerator $url,
+ protected ICloudIdManager $cloudIdManager,
+ ) {
}
/**
diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
index f78112e2ce6..7e07703f430 100644
--- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
+++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
@@ -14,6 +14,7 @@ use OCA\Files_Sharing\External\Manager;
use OCA\GlobalSiteSelector\Service\SlaveService;
use OCP\Activity\IManager as IActivityManager;
use OCP\App\IAppManager;
+use OCP\AppFramework\QueryException;
use OCP\Constants;
use OCP\Federation\Exceptions\ActionNotSupportedException;
use OCP\Federation\Exceptions\AuthenticationFailedException;
@@ -79,7 +80,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @return string provider specific unique ID of the share
*
* @throws ProviderCouldNotAddShareException
- * @throws \OCP\AppFramework\QueryException
+ * @throws QueryException
* @throws HintException
* @since 14.0.0
*/
diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php
index a7bdc545413..1343513e65a 100644
--- a/apps/federatedfilesharing/lib/Settings/Admin.php
+++ b/apps/federatedfilesharing/lib/Settings/Admin.php
@@ -14,27 +14,16 @@ use OCP\IURLGenerator;
use OCP\Settings\IDelegatedSettings;
class Admin implements IDelegatedSettings {
- private FederatedShareProvider $fedShareProvider;
- private IConfig $gsConfig;
- private IL10N $l;
- private IURLGenerator $urlGenerator;
- private IInitialState $initialState;
-
/**
* Admin constructor.
*/
public function __construct(
- FederatedShareProvider $fedShareProvider,
- IConfig $globalScaleConfig,
- IL10N $l,
- IURLGenerator $urlGenerator,
- IInitialState $initialState,
+ private FederatedShareProvider $fedShareProvider,
+ private IConfig $gsConfig,
+ private IL10N $l,
+ private IURLGenerator $urlGenerator,
+ private IInitialState $initialState,
) {
- $this->fedShareProvider = $fedShareProvider;
- $this->gsConfig = $globalScaleConfig;
- $this->l = $l;
- $this->urlGenerator = $urlGenerator;
- $this->initialState = $initialState;
}
/**
diff --git a/apps/federatedfilesharing/lib/Settings/Personal.php b/apps/federatedfilesharing/lib/Settings/Personal.php
index 93ca36ab420..b71b064859e 100644
--- a/apps/federatedfilesharing/lib/Settings/Personal.php
+++ b/apps/federatedfilesharing/lib/Settings/Personal.php
@@ -17,24 +17,13 @@ use OCP\IUserSession;
use OCP\Settings\ISettings;
class Personal implements ISettings {
- private FederatedShareProvider $federatedShareProvider;
- private IUserSession $userSession;
- private Defaults $defaults;
- private IInitialState $initialState;
- private IURLGenerator $urlGenerator;
-
public function __construct(
- FederatedShareProvider $federatedShareProvider,
- IUserSession $userSession,
- Defaults $defaults,
- IInitialState $initialState,
- IURLGenerator $urlGenerator,
+ private FederatedShareProvider $federatedShareProvider,
+ private IUserSession $userSession,
+ private Defaults $defaults,
+ private IInitialState $initialState,
+ private IURLGenerator $urlGenerator,
) {
- $this->federatedShareProvider = $federatedShareProvider;
- $this->userSession = $userSession;
- $this->defaults = $defaults;
- $this->initialState = $initialState;
- $this->urlGenerator = $urlGenerator;
}
/**
diff --git a/apps/federatedfilesharing/lib/Settings/PersonalSection.php b/apps/federatedfilesharing/lib/Settings/PersonalSection.php
index 528c2b6c717..5ef1e180c31 100644
--- a/apps/federatedfilesharing/lib/Settings/PersonalSection.php
+++ b/apps/federatedfilesharing/lib/Settings/PersonalSection.php
@@ -10,14 +10,10 @@ use OCP\IURLGenerator;
use OCP\Settings\IIconSection;
class PersonalSection implements IIconSection {
- /** @var IURLGenerator */
- private $urlGenerator;
- /** @var IL10N */
- private $l;
-
- public function __construct(IURLGenerator $urlGenerator, IL10N $l) {
- $this->urlGenerator = $urlGenerator;
- $this->l = $l;
+ public function __construct(
+ private IURLGenerator $urlGenerator,
+ private IL10N $l,
+ ) {
}
/**
diff --git a/apps/federatedfilesharing/lib/TokenHandler.php b/apps/federatedfilesharing/lib/TokenHandler.php
index e0a6d2cbe8c..0151d12f5d9 100644
--- a/apps/federatedfilesharing/lib/TokenHandler.php
+++ b/apps/federatedfilesharing/lib/TokenHandler.php
@@ -17,16 +17,14 @@ use OCP\Security\ISecureRandom;
class TokenHandler {
public const TOKEN_LENGTH = 15;
- /** @var ISecureRandom */
- private $secureRandom;
-
/**
* TokenHandler constructor.
*
* @param ISecureRandom $secureRandom
*/
- public function __construct(ISecureRandom $secureRandom) {
- $this->secureRandom = $secureRandom;
+ public function __construct(
+ private ISecureRandom $secureRandom,
+ ) {
}
/**