diff options
author | provokateurin <kate@provokateurin.de> | 2024-10-18 12:04:22 +0200 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2024-10-21 12:37:59 +0200 |
commit | 381077028adf388a7081cf42026570c6be47b198 (patch) | |
tree | c0f8e9b6caea80d6b55d6fdcc9188ba57197fa0f /apps/files_sharing | |
parent | 4d8d11d2f79da348644e0902e78a2f000498cd52 (diff) | |
download | nextcloud-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/files_sharing')
61 files changed, 340 insertions, 618 deletions
diff --git a/apps/files_sharing/lib/Activity/Filter.php b/apps/files_sharing/lib/Activity/Filter.php index 84e59598229..7dc2a46e70f 100644 --- a/apps/files_sharing/lib/Activity/Filter.php +++ b/apps/files_sharing/lib/Activity/Filter.php @@ -13,15 +13,10 @@ class Filter implements IFilter { public const TYPE_REMOTE_SHARE = 'remote_share'; public const TYPE_SHARED = 'shared'; - /** @var IL10N */ - protected $l; - - /** @var IURLGenerator */ - protected $url; - - public function __construct(IL10N $l, IURLGenerator $url) { - $this->l = $l; - $this->url = $url; + public function __construct( + protected IL10N $l, + protected IURLGenerator $url, + ) { } /** diff --git a/apps/files_sharing/lib/Activity/Providers/Base.php b/apps/files_sharing/lib/Activity/Providers/Base.php index 9df990258c8..464cb336042 100644 --- a/apps/files_sharing/lib/Activity/Providers/Base.php +++ b/apps/files_sharing/lib/Activity/Providers/Base.php @@ -18,47 +18,21 @@ use OCP\IUserManager; use OCP\L10N\IFactory; abstract class Base implements IProvider { - /** @var IFactory */ - protected $languageFactory; - /** @var IL10N */ protected $l; - /** @var IURLGenerator */ - protected $url; - - /** @var IManager */ - protected $activityManager; - - /** @var IUserManager */ - protected $userManager; - - /** @var IEventMerger */ - protected $eventMerger; - - /** @var IContactsManager */ - protected $contactsManager; - - /** @var ICloudIdManager */ - protected $cloudIdManager; - /** @var array */ protected $displayNames = []; - public function __construct(IFactory $languageFactory, - IURLGenerator $url, - IManager $activityManager, - IUserManager $userManager, - ICloudIdManager $cloudIdManager, - IContactsManager $contactsManager, - IEventMerger $eventMerger) { - $this->languageFactory = $languageFactory; - $this->url = $url; - $this->activityManager = $activityManager; - $this->userManager = $userManager; - $this->cloudIdManager = $cloudIdManager; - $this->contactsManager = $contactsManager; - $this->eventMerger = $eventMerger; + public function __construct( + protected IFactory $languageFactory, + protected IURLGenerator $url, + protected IManager $activityManager, + protected IUserManager $userManager, + protected ICloudIdManager $cloudIdManager, + protected IContactsManager $contactsManager, + protected IEventMerger $eventMerger, + ) { } /** diff --git a/apps/files_sharing/lib/Activity/Providers/Groups.php b/apps/files_sharing/lib/Activity/Providers/Groups.php index fffa74258c9..b64104739db 100644 --- a/apps/files_sharing/lib/Activity/Providers/Groups.php +++ b/apps/files_sharing/lib/Activity/Providers/Groups.php @@ -25,22 +25,20 @@ class Groups extends Base { public const SUBJECT_EXPIRED_GROUP = 'expired_group'; - /** @var IGroupManager */ - protected $groupManager; - /** @var string[] */ protected $groupDisplayNames = []; - public function __construct(IFactory $languageFactory, + public function __construct( + IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, ICloudIdManager $cloudIdManager, IContactsManager $contactsManager, IEventMerger $eventMerger, - IGroupManager $groupManager) { + protected IGroupManager $groupManager, + ) { parent::__construct($languageFactory, $url, $activityManager, $userManager, $cloudIdManager, $contactsManager, $eventMerger); - $this->groupManager = $groupManager; } /** diff --git a/apps/files_sharing/lib/Activity/Settings/ShareActivitySettings.php b/apps/files_sharing/lib/Activity/Settings/ShareActivitySettings.php index e8547324f24..4d8d8278433 100644 --- a/apps/files_sharing/lib/Activity/Settings/ShareActivitySettings.php +++ b/apps/files_sharing/lib/Activity/Settings/ShareActivitySettings.php @@ -12,14 +12,12 @@ use OCP\Activity\ActivitySettings; use OCP\IL10N; abstract class ShareActivitySettings extends ActivitySettings { - /** @var IL10N */ - protected $l; - /** * @param IL10N $l */ - public function __construct(IL10N $l) { - $this->l = $l; + public function __construct( + protected IL10N $l, + ) { } public function getGroupIdentifier() { diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index ac44ae7c6cc..372dde198a0 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -27,29 +27,22 @@ use OCP\Share\IShare; * don't use this class directly if you need to get metadata, use \OC\Files\Filesystem::getFileInfo instead */ class Cache extends CacheJail { - /** @var SharedStorage */ - private $storage; - private ICacheEntry $sourceRootInfo; private bool $rootUnchanged = true; private ?string $ownerDisplayName = null; private $numericId; private DisplayNameCache $displayNameCache; - private IShare $share; /** * @param SharedStorage $storage */ public function __construct( - $storage, - ICacheEntry $sourceRootInfo, + private $storage, + private ICacheEntry $sourceRootInfo, CacheDependencies $dependencies, - IShare $share, + private IShare $share, ) { - $this->storage = $storage; - $this->sourceRootInfo = $sourceRootInfo; - $this->numericId = $sourceRootInfo->getStorageId(); + $this->numericId = $this->sourceRootInfo->getStorageId(); $this->displayNameCache = $dependencies->getDisplayNameCache(); - $this->share = $share; parent::__construct( null, diff --git a/apps/files_sharing/lib/Capabilities.php b/apps/files_sharing/lib/Capabilities.php index 9afa077fac3..1f4219ed1a5 100644 --- a/apps/files_sharing/lib/Capabilities.php +++ b/apps/files_sharing/lib/Capabilities.php @@ -18,14 +18,10 @@ use OCP\Share\IManager; */ class Capabilities implements ICapability { - /** @var IConfig */ - private $config; - /** @var IManager */ - private $shareManager; - - public function __construct(IConfig $config, IManager $shareManager) { - $this->config = $config; - $this->shareManager = $shareManager; + public function __construct( + private IConfig $config, + private IManager $shareManager, + ) { } /** diff --git a/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php b/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php index f383424fd78..993dba64888 100644 --- a/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php +++ b/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php @@ -13,14 +13,11 @@ use OCP\Share\IManager; class ShareRecipientSorter implements ISorter { - private IManager $shareManager; - private IRootFolder $rootFolder; - private IUserSession $userSession; - - public function __construct(IManager $shareManager, IRootFolder $rootFolder, IUserSession $userSession) { - $this->shareManager = $shareManager; - $this->rootFolder = $rootFolder; - $this->userSession = $userSession; + public function __construct( + private IManager $shareManager, + private IRootFolder $rootFolder, + private IUserSession $userSession, + ) { } public function getId(): string { diff --git a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php index bb7f374de58..7e21768afee 100644 --- a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php +++ b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php @@ -20,19 +20,10 @@ use Symfony\Component\Console\Output\OutputInterface; */ class CleanupRemoteStorages extends Command { - /** - * @var IDBConnection - */ - protected $connection; - - /** - * @var ICloudIdManager - */ - private $cloudIdManager; - - public function __construct(IDBConnection $connection, ICloudIdManager $cloudIdManager) { - $this->connection = $connection; - $this->cloudIdManager = $cloudIdManager; + public function __construct( + protected IDBConnection $connection, + private ICloudIdManager $cloudIdManager, + ) { parent::__construct(); } diff --git a/apps/files_sharing/lib/Command/DeleteOrphanShares.php b/apps/files_sharing/lib/Command/DeleteOrphanShares.php index cd3ff5c08f8..a7e96387d60 100644 --- a/apps/files_sharing/lib/Command/DeleteOrphanShares.php +++ b/apps/files_sharing/lib/Command/DeleteOrphanShares.php @@ -17,11 +17,10 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; class DeleteOrphanShares extends Base { - private OrphanHelper $orphanHelper; - - public function __construct(OrphanHelper $orphanHelper) { + public function __construct( + private OrphanHelper $orphanHelper, + ) { parent::__construct(); - $this->orphanHelper = $orphanHelper; } protected function configure(): void { diff --git a/apps/files_sharing/lib/Command/ExiprationNotification.php b/apps/files_sharing/lib/Command/ExiprationNotification.php index f4f41dc7011..df5656a434e 100644 --- a/apps/files_sharing/lib/Command/ExiprationNotification.php +++ b/apps/files_sharing/lib/Command/ExiprationNotification.php @@ -18,25 +18,13 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class ExiprationNotification extends Command { - /** @var NotificationManager */ - private $notificationManager; - /** @var IDBConnection */ - private $connection; - /** @var ITimeFactory */ - private $time; - /** @var ShareManager */ - private $shareManager; - - public function __construct(ITimeFactory $time, - NotificationManager $notificationManager, - IDBConnection $connection, - ShareManager $shareManager) { + public function __construct( + private ITimeFactory $time, + private NotificationManager $notificationManager, + private IDBConnection $connection, + private ShareManager $shareManager, + ) { parent::__construct(); - - $this->notificationManager = $notificationManager; - $this->connection = $connection; - $this->time = $time; - $this->shareManager = $shareManager; } protected function configure() { diff --git a/apps/files_sharing/lib/Controller/AcceptController.php b/apps/files_sharing/lib/Controller/AcceptController.php index cdd10235a69..721ddec7d2b 100644 --- a/apps/files_sharing/lib/Controller/AcceptController.php +++ b/apps/files_sharing/lib/Controller/AcceptController.php @@ -25,21 +25,13 @@ use OCP\Share\IManager as ShareManager; #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)] class AcceptController extends Controller { - /** @var ShareManager */ - private $shareManager; - - /** @var IUserSession */ - private $userSession; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IRequest $request, ShareManager $shareManager, IUserSession $userSession, IURLGenerator $urlGenerator) { + public function __construct( + IRequest $request, + private ShareManager $shareManager, + private IUserSession $userSession, + private IURLGenerator $urlGenerator, + ) { parent::__construct(Application::APP_ID, $request); - - $this->shareManager = $shareManager; - $this->userSession = $userSession; - $this->urlGenerator = $urlGenerator; } #[NoAdminRequired] diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php index ce30cf373ec..9f80d285d4d 100644 --- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php +++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php @@ -34,45 +34,18 @@ use OCP\Share\IShare; */ class DeletedShareAPIController extends OCSController { - /** @var ShareManager */ - private $shareManager; - - /** @var string */ - private $userId; - - /** @var IUserManager */ - private $userManager; - - /** @var IGroupManager */ - private $groupManager; - - /** @var IRootFolder */ - private $rootFolder; - - /** @var IAppManager */ - private $appManager; - - /** @var IServerContainer */ - private $serverContainer; - - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - ShareManager $shareManager, - string $UserId, - IUserManager $userManager, - IGroupManager $groupManager, - IRootFolder $rootFolder, - IAppManager $appManager, - IServerContainer $serverContainer) { + private ShareManager $shareManager, + private string $userId, + private IUserManager $userManager, + private IGroupManager $groupManager, + private IRootFolder $rootFolder, + private IAppManager $appManager, + private IServerContainer $serverContainer, + ) { parent::__construct($appName, $request); - - $this->shareManager = $shareManager; - $this->userId = $UserId; - $this->userManager = $userManager; - $this->groupManager = $groupManager; - $this->rootFolder = $rootFolder; - $this->appManager = $appManager; - $this->serverContainer = $serverContainer; } /** diff --git a/apps/files_sharing/lib/Controller/PublicPreviewController.php b/apps/files_sharing/lib/Controller/PublicPreviewController.php index a2e244c7ba0..9678aa67888 100644 --- a/apps/files_sharing/lib/Controller/PublicPreviewController.php +++ b/apps/files_sharing/lib/Controller/PublicPreviewController.php @@ -23,24 +23,17 @@ use OCP\Share\IShare; class PublicPreviewController extends PublicShareController { - /** @var ShareManager */ - private $shareManager; - - /** @var IPreview */ - private $previewManager; - /** @var IShare */ private $share; - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - ShareManager $shareManger, + private ShareManager $shareManager, ISession $session, - IPreview $previewManager) { + private IPreview $previewManager, + ) { parent::__construct($appName, $request, $session); - - $this->shareManager = $shareManger; - $this->previewManager = $previewManager; } protected function getPasswordHash(): ?string { diff --git a/apps/files_sharing/lib/Controller/SettingsController.php b/apps/files_sharing/lib/Controller/SettingsController.php index df0ca4f8472..67d9193be78 100644 --- a/apps/files_sharing/lib/Controller/SettingsController.php +++ b/apps/files_sharing/lib/Controller/SettingsController.php @@ -17,19 +17,12 @@ use OCP\IRequest; class SettingsController extends Controller { - /** @var IConfig */ - private $config; - - /** @var string */ - private $userId; - - public function __construct(IRequest $request, - IConfig $config, - string $userId) { + public function __construct( + IRequest $request, + private IConfig $config, + private string $userId, + ) { parent::__construct(Application::APP_ID, $request); - - $this->config = $config; - $this->userId = $userId; } #[NoAdminRequired] diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 4cff9987242..2874d35caa5 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -68,7 +68,6 @@ use Psr\Log\LoggerInterface; class ShareAPIController extends OCSController { private ?Node $lockedNode = null; - private string $currentUser; /** * Share20OCS constructor. @@ -91,16 +90,15 @@ class ShareAPIController extends OCSController { private LoggerInterface $logger, private IProviderFactory $factory, private IMailer $mailer, - ?string $userId = null, + private ?string $userId = null, ) { parent::__construct($appName, $request); - $this->currentUser = $userId; } /** * Convert an IShare to an array for OCS output * - * @param \OCP\Share\IShare $share + * @param IShare $share * @param Node|null $recipientNode * @return Files_SharingShare * @throws NotFoundException In case the node can't be resolved. @@ -113,7 +111,7 @@ class ShareAPIController extends OCSController { $isOwnShare = false; if ($shareOwner !== null) { - $isOwnShare = $shareOwner->getUID() === $this->currentUser; + $isOwnShare = $shareOwner->getUID() === $this->userId; } $result = [ @@ -136,7 +134,7 @@ class ShareAPIController extends OCSController { 'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner(), ]; - $userFolder = $this->rootFolder->getUserFolder($this->currentUser); + $userFolder = $this->rootFolder->getUserFolder($this->userId); if ($recipientNode) { $node = $recipientNode; } else { @@ -161,7 +159,7 @@ class ShareAPIController extends OCSController { if ($isOwnShare) { $result['item_permissions'] = $node->getPermissions(); } - + // If we're on the recipient side, the node permissions // are bound to the share permissions. So we need to // adjust the permissions to the share permissions if necessary. @@ -517,7 +515,7 @@ class ShareAPIController extends OCSController { // mount point. Allowing it to be restored // from the deleted shares if ($this->canDeleteShareFromSelf($share)) { - $this->shareManager->deleteFromSelf($share, $this->currentUser); + $this->shareManager->deleteFromSelf($share, $this->userId); } else { if (!$this->canDeleteShare($share)) { throw new OCSForbiddenException($this->l->t('Could not delete share')); @@ -588,7 +586,7 @@ class ShareAPIController extends OCSController { throw new OCSNotFoundException($this->l->t('Please specify a file or folder path')); } - $userFolder = $this->rootFolder->getUserFolder($this->currentUser); + $userFolder = $this->rootFolder->getUserFolder($this->userId); try { /** @var \OC\Files\Node\Node $node */ $node = $userFolder->get($path); @@ -657,7 +655,7 @@ class ShareAPIController extends OCSController { } } - $share->setSharedBy($this->currentUser); + $share->setSharedBy($this->userId); $this->checkInheritedAttributes($share); // Handle mail send @@ -828,17 +826,17 @@ class ShareAPIController extends OCSController { * @return Files_SharingShare[] */ private function getSharedWithMe($node, bool $includeTags): array { - $userShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_USER, $node, -1, 0); - $groupShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_GROUP, $node, -1, 0); - $circleShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_CIRCLE, $node, -1, 0); - $roomShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_ROOM, $node, -1, 0); - $deckShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_DECK, $node, -1, 0); - $sciencemeshShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_SCIENCEMESH, $node, -1, 0); + $userShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_USER, $node, -1, 0); + $groupShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_GROUP, $node, -1, 0); + $circleShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_CIRCLE, $node, -1, 0); + $roomShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_ROOM, $node, -1, 0); + $deckShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_DECK, $node, -1, 0); + $sciencemeshShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_SCIENCEMESH, $node, -1, 0); $shares = array_merge($userShares, $groupShares, $circleShares, $roomShares, $deckShares, $sciencemeshShares); $filteredShares = array_filter($shares, function (IShare $share) { - return $share->getShareOwner() !== $this->currentUser; + return $share->getShareOwner() !== $this->userId; }); $formatted = []; @@ -860,7 +858,7 @@ class ShareAPIController extends OCSController { } /** - * @param \OCP\Files\Node $folder + * @param Node $folder * * @return Files_SharingShare[] * @throws OCSBadRequestException @@ -873,7 +871,7 @@ class ShareAPIController extends OCSController { $nodes = $folder->getDirectoryListing(); - /** @var \OCP\Share\IShare[] $shares */ + /** @var IShare[] $shares */ $shares = array_reduce($nodes, function ($carry, $node) { $carry = array_merge($carry, $this->getAllShares($node, true)); return $carry; @@ -886,7 +884,7 @@ class ShareAPIController extends OCSController { $resharingRight = false; $known = []; foreach ($shares as $share) { - if (in_array($share->getId(), $known) || $share->getSharedWith() === $this->currentUser) { + if (in_array($share->getId(), $known) || $share->getSharedWith() === $this->userId) { continue; } @@ -895,10 +893,10 @@ class ShareAPIController extends OCSController { $known[] = $share->getId(); $formatted[] = $format; - if ($share->getSharedBy() === $this->currentUser) { + if ($share->getSharedBy() === $this->userId) { $miniFormatted[] = $format; } - if (!$resharingRight && $this->shareProviderResharingRights($this->currentUser, $share, $folder)) { + if (!$resharingRight && $this->shareProviderResharingRights($this->userId, $share, $folder)) { $resharingRight = true; } } catch (\Exception $e) { @@ -937,7 +935,7 @@ class ShareAPIController extends OCSController { ): DataResponse { $node = null; if ($path !== '') { - $userFolder = $this->rootFolder->getUserFolder($this->currentUser); + $userFolder = $this->rootFolder->getUserFolder($this->userId); try { $node = $userFolder->get($path); $this->lock($node); @@ -951,7 +949,7 @@ class ShareAPIController extends OCSController { } $shares = $this->getFormattedShares( - $this->currentUser, + $this->userId, $node, ($shared_with_me === 'true'), ($reshares === 'true'), @@ -1007,7 +1005,7 @@ class ShareAPIController extends OCSController { } if (in_array($share->getId(), $known) - || ($share->getSharedWith() === $this->currentUser && $share->getShareType() === IShare::TYPE_USER)) { + || ($share->getSharedWith() === $this->userId && $share->getShareType() === IShare::TYPE_USER)) { continue; } @@ -1020,13 +1018,13 @@ class ShareAPIController extends OCSController { // let's also build a list of shares created // by the current user only, in case // there is no resharing rights - if ($share->getSharedBy() === $this->currentUser) { + if ($share->getSharedBy() === $this->userId) { $miniFormatted[] = $format; } // check if one of those share is shared with me // and if I have resharing rights on it - if (!$resharingRight && $this->shareProviderResharingRights($this->currentUser, $share, $node)) { + if (!$resharingRight && $this->shareProviderResharingRights($this->userId, $share, $node)) { $resharingRight = true; } } catch (InvalidPathException|NotFoundException $e) { @@ -1065,7 +1063,7 @@ class ShareAPIController extends OCSController { #[NoAdminRequired] public function getInheritedShares(string $path): DataResponse { // get Node from (string) path. - $userFolder = $this->rootFolder->getUserFolder($this->currentUser); + $userFolder = $this->rootFolder->getUserFolder($this->userId); try { $node = $userFolder->get($path); $this->lock($node); @@ -1111,7 +1109,7 @@ class ShareAPIController extends OCSController { } // The user that is requesting this list - $currentUserFolder = $this->rootFolder->getUserFolder($this->currentUser); + $currentUserFolder = $this->rootFolder->getUserFolder($this->userId); // for each nodes, retrieve shares. $shares = []; @@ -1240,7 +1238,7 @@ class ShareAPIController extends OCSController { * We only allow deletion */ - if ($share->getSharedBy() !== $this->currentUser) { + if ($share->getSharedBy() !== $this->userId) { throw new OCSForbiddenException($this->l->t('You are not allowed to edit link shares that you don\'t own')); } @@ -1381,7 +1379,7 @@ class ShareAPIController extends OCSController { ]; foreach ($shareTypes as $shareType) { - $shares = $this->shareManager->getSharedWith($this->currentUser, $shareType, null, -1, 0); + $shares = $this->shareManager->getSharedWith($this->userId, $shareType, null, -1, 0); foreach ($shares as $share) { if ($share->getStatus() === IShare::STATUS_PENDING || $share->getStatus() === IShare::STATUS_REJECTED) { @@ -1440,7 +1438,7 @@ class ShareAPIController extends OCSController { } try { - $this->shareManager->acceptShare($share, $this->currentUser); + $this->shareManager->acceptShare($share, $this->userId); } catch (GenericShareException $e) { $code = $e->getCode() === 0 ? 403 : $e->getCode(); throw new OCSException($e->getHint(), (int)$code); @@ -1454,7 +1452,7 @@ class ShareAPIController extends OCSController { /** * Does the user have read permission on the share * - * @param \OCP\Share\IShare $share the share to check + * @param IShare $share the share to check * @param boolean $checkGroups check groups as well? * @return boolean * @throws NotFoundException @@ -1468,29 +1466,29 @@ class ShareAPIController extends OCSController { } // Owner of the file and the sharer of the file can always get share - if ($share->getShareOwner() === $this->currentUser - || $share->getSharedBy() === $this->currentUser) { + if ($share->getShareOwner() === $this->userId + || $share->getSharedBy() === $this->userId) { return true; } // If the share is shared with you, you can access it! if ($share->getShareType() === IShare::TYPE_USER - && $share->getSharedWith() === $this->currentUser) { + && $share->getSharedWith() === $this->userId) { return true; } // Have reshare rights on the shared file/folder ? // Does the currentUser have access to the shared file? - $userFolder = $this->rootFolder->getUserFolder($this->currentUser); + $userFolder = $this->rootFolder->getUserFolder($this->userId); $file = $userFolder->getFirstNodeById($share->getNodeId()); - if ($file && $this->shareProviderResharingRights($this->currentUser, $share, $file)) { + if ($file && $this->shareProviderResharingRights($this->userId, $share, $file)) { return true; } // If in the recipient group, you can see the share if ($checkGroups && $share->getShareType() === IShare::TYPE_GROUP) { $sharedWith = $this->groupManager->get($share->getSharedWith()); - $user = $this->userManager->get($this->currentUser); + $user = $this->userManager->get($this->userId); if ($user !== null && $sharedWith !== null && $sharedWith->inGroup($user)) { return true; } @@ -1503,7 +1501,7 @@ class ShareAPIController extends OCSController { if ($share->getShareType() === IShare::TYPE_ROOM) { try { - return $this->getRoomShareHelper()->canAccessShare($share, $this->currentUser); + return $this->getRoomShareHelper()->canAccessShare($share, $this->userId); } catch (QueryException $e) { return false; } @@ -1511,7 +1509,7 @@ class ShareAPIController extends OCSController { if ($share->getShareType() === IShare::TYPE_DECK) { try { - return $this->getDeckShareHelper()->canAccessShare($share, $this->currentUser); + return $this->getDeckShareHelper()->canAccessShare($share, $this->userId); } catch (QueryException $e) { return false; } @@ -1519,7 +1517,7 @@ class ShareAPIController extends OCSController { if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) { try { - return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->currentUser); + return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->userId); } catch (QueryException $e) { return false; } @@ -1531,7 +1529,7 @@ class ShareAPIController extends OCSController { /** * Does the user have edit permission on the share * - * @param \OCP\Share\IShare $share the share to check + * @param IShare $share the share to check * @return boolean */ protected function canEditShare(IShare $share): bool { @@ -1542,8 +1540,8 @@ class ShareAPIController extends OCSController { // The owner of the file and the creator of the share // can always edit the share - if ($share->getShareOwner() === $this->currentUser || - $share->getSharedBy() === $this->currentUser + if ($share->getShareOwner() === $this->userId || + $share->getSharedBy() === $this->userId ) { return true; } @@ -1558,7 +1556,7 @@ class ShareAPIController extends OCSController { /** * Does the user have delete permission on the share * - * @param \OCP\Share\IShare $share the share to check + * @param IShare $share the share to check * @return boolean */ protected function canDeleteShare(IShare $share): bool { @@ -1570,15 +1568,15 @@ class ShareAPIController extends OCSController { // if the user is the recipient, i can unshare // the share with self if ($share->getShareType() === IShare::TYPE_USER && - $share->getSharedWith() === $this->currentUser + $share->getSharedWith() === $this->userId ) { return true; } // The owner of the file and the creator of the share // can always delete the share - if ($share->getShareOwner() === $this->currentUser || - $share->getSharedBy() === $this->currentUser + if ($share->getShareOwner() === $this->userId || + $share->getSharedBy() === $this->userId ) { return true; } @@ -1593,7 +1591,7 @@ class ShareAPIController extends OCSController { * completely delete the share but only the mount point. * It can then be restored from the deleted shares section. * - * @param \OCP\Share\IShare $share the share to check + * @param IShare $share the share to check * @return boolean * * @suppress PhanUndeclaredClassMethod @@ -1607,8 +1605,8 @@ class ShareAPIController extends OCSController { return false; } - if ($share->getShareOwner() === $this->currentUser || - $share->getSharedBy() === $this->currentUser + if ($share->getShareOwner() === $this->userId || + $share->getSharedBy() === $this->userId ) { // Delete the whole share, not just for self return false; @@ -1617,7 +1615,7 @@ class ShareAPIController extends OCSController { // If in the recipient group, you can delete the share from self if ($share->getShareType() === IShare::TYPE_GROUP) { $sharedWith = $this->groupManager->get($share->getSharedWith()); - $user = $this->userManager->get($this->currentUser); + $user = $this->userManager->get($this->userId); if ($user !== null && $sharedWith !== null && $sharedWith->inGroup($user)) { return true; } @@ -1625,7 +1623,7 @@ class ShareAPIController extends OCSController { if ($share->getShareType() === IShare::TYPE_ROOM) { try { - return $this->getRoomShareHelper()->canAccessShare($share, $this->currentUser); + return $this->getRoomShareHelper()->canAccessShare($share, $this->userId); } catch (QueryException $e) { return false; } @@ -1633,7 +1631,7 @@ class ShareAPIController extends OCSController { if ($share->getShareType() === IShare::TYPE_DECK) { try { - return $this->getDeckShareHelper()->canAccessShare($share, $this->currentUser); + return $this->getDeckShareHelper()->canAccessShare($share, $this->userId); } catch (QueryException $e) { return false; } @@ -1641,7 +1639,7 @@ class ShareAPIController extends OCSController { if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) { try { - return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->currentUser); + return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->userId); } catch (QueryException $e) { return false; } @@ -1677,7 +1675,7 @@ class ShareAPIController extends OCSController { * not support this we need to check all backends. * * @param string $id - * @return \OCP\Share\IShare + * @return IShare * @throws ShareNotFound */ private function getShareById(string $id): IShare { @@ -1685,7 +1683,7 @@ class ShareAPIController extends OCSController { // First check if it is an internal share. try { - $share = $this->shareManager->getShareById('ocinternal:' . $id, $this->currentUser); + $share = $this->shareManager->getShareById('ocinternal:' . $id, $this->userId); return $share; } catch (ShareNotFound $e) { // Do nothing, just try the other share type @@ -1694,7 +1692,7 @@ class ShareAPIController extends OCSController { try { if ($this->shareManager->shareProviderExists(IShare::TYPE_CIRCLE)) { - $share = $this->shareManager->getShareById('ocCircleShare:' . $id, $this->currentUser); + $share = $this->shareManager->getShareById('ocCircleShare:' . $id, $this->userId); return $share; } } catch (ShareNotFound $e) { @@ -1703,7 +1701,7 @@ class ShareAPIController extends OCSController { try { if ($this->shareManager->shareProviderExists(IShare::TYPE_EMAIL)) { - $share = $this->shareManager->getShareById('ocMailShare:' . $id, $this->currentUser); + $share = $this->shareManager->getShareById('ocMailShare:' . $id, $this->userId); return $share; } } catch (ShareNotFound $e) { @@ -1711,7 +1709,7 @@ class ShareAPIController extends OCSController { } try { - $share = $this->shareManager->getShareById('ocRoomShare:' . $id, $this->currentUser); + $share = $this->shareManager->getShareById('ocRoomShare:' . $id, $this->userId); return $share; } catch (ShareNotFound $e) { // Do nothing, just try the other share type @@ -1719,7 +1717,7 @@ class ShareAPIController extends OCSController { try { if ($this->shareManager->shareProviderExists(IShare::TYPE_DECK)) { - $share = $this->shareManager->getShareById('deck:' . $id, $this->currentUser); + $share = $this->shareManager->getShareById('deck:' . $id, $this->userId); return $share; } } catch (ShareNotFound $e) { @@ -1728,7 +1726,7 @@ class ShareAPIController extends OCSController { try { if ($this->shareManager->shareProviderExists(IShare::TYPE_SCIENCEMESH)) { - $share = $this->shareManager->getShareById('sciencemesh:' . $id, $this->currentUser); + $share = $this->shareManager->getShareById('sciencemesh:' . $id, $this->userId); return $share; } } catch (ShareNotFound $e) { @@ -1738,7 +1736,7 @@ class ShareAPIController extends OCSController { if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) { throw new ShareNotFound(); } - $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id, $this->currentUser); + $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id, $this->userId); return $share; } @@ -1746,7 +1744,7 @@ class ShareAPIController extends OCSController { /** * Lock a Node * - * @param \OCP\Files\Node $node + * @param Node $node * @throws LockedException */ private function lock(Node $node) { @@ -1848,14 +1846,14 @@ class ShareAPIController extends OCSController { if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { $federatedShares = $this->shareManager->getSharesBy( - $this->currentUser, IShare::TYPE_REMOTE, $node, $reShares, -1, 0 + $this->userId, IShare::TYPE_REMOTE, $node, $reShares, -1, 0 ); $shares = array_merge($shares, $federatedShares); } if ($this->shareManager->outgoingServer2ServerGroupSharesAllowed()) { $federatedShares = $this->shareManager->getSharesBy( - $this->currentUser, IShare::TYPE_REMOTE_GROUP, $node, $reShares, -1, 0 + $this->userId, IShare::TYPE_REMOTE_GROUP, $node, $reShares, -1, 0 ); $shares = array_merge($shares, $federatedShares); } @@ -1870,7 +1868,7 @@ class ShareAPIController extends OCSController { * @throws SharingRightsException */ private function confirmSharingRights(Node $node): void { - if (!$this->hasResharingRights($this->currentUser, $node)) { + if (!$this->hasResharingRights($this->userId, $node)) { throw new SharingRightsException($this->l->t('No sharing rights on this item')); } } @@ -1971,33 +1969,33 @@ class ShareAPIController extends OCSController { */ private function getAllShares(?Node $path = null, bool $reshares = false) { // Get all shares - $userShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_USER, $path, $reshares, -1, 0); - $groupShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_GROUP, $path, $reshares, -1, 0); - $linkShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_LINK, $path, $reshares, -1, 0); + $userShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_USER, $path, $reshares, -1, 0); + $groupShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_GROUP, $path, $reshares, -1, 0); + $linkShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_LINK, $path, $reshares, -1, 0); // EMAIL SHARES - $mailShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_EMAIL, $path, $reshares, -1, 0); + $mailShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_EMAIL, $path, $reshares, -1, 0); // TEAM SHARES - $circleShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_CIRCLE, $path, $reshares, -1, 0); + $circleShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_CIRCLE, $path, $reshares, -1, 0); // TALK SHARES - $roomShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_ROOM, $path, $reshares, -1, 0); + $roomShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_ROOM, $path, $reshares, -1, 0); // DECK SHARES - $deckShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_DECK, $path, $reshares, -1, 0); + $deckShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_DECK, $path, $reshares, -1, 0); // SCIENCEMESH SHARES - $sciencemeshShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_SCIENCEMESH, $path, $reshares, -1, 0); + $sciencemeshShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_SCIENCEMESH, $path, $reshares, -1, 0); // FEDERATION if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { - $federatedShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_REMOTE, $path, $reshares, -1, 0); + $federatedShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_REMOTE, $path, $reshares, -1, 0); } else { $federatedShares = []; } if ($this->shareManager->outgoingServer2ServerGroupSharesAllowed()) { - $federatedGroupShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_REMOTE_GROUP, $path, $reshares, -1, 0); + $federatedGroupShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_REMOTE_GROUP, $path, $reshares, -1, 0); } else { $federatedGroupShares = []; } @@ -2112,7 +2110,7 @@ class ShareAPIController extends OCSController { // the owner of the share, not only the file owner. if ($share->getShareType() === IShare::TYPE_EMAIL || $share->getShareType() === IShare::TYPE_LINK) { - if ($share->getSharedBy() !== $this->currentUser) { + if ($share->getSharedBy() !== $this->userId) { throw new OCSForbiddenException($this->l->t('You are not allowed to send mail notifications')); } } diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 5b2a2af4992..1c3c9534dde 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -20,6 +20,7 @@ use OCP\AppFramework\Http\Attribute\PublicPage; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\RedirectResponse; +use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\TemplateResponse; use OCP\Constants; use OCP\Defaults; @@ -29,6 +30,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\IL10N; use OCP\IPreview; @@ -207,12 +209,12 @@ class ShareController extends AuthPublicShareController { /** * throws hooks when a share is attempted to be accessed * - * @param \OCP\Share\IShare|string $share the Share instance if available, - * otherwise token + * @param IShare|string $share the Share instance if available, + * otherwise token * @param int $errorCode * @param string $errorMessage * - * @throws \OCP\HintException + * @throws HintException * @throws \OC\ServerNotAvailableException * * @deprecated use OCP\Files_Sharing\Event\ShareLinkAccessedEvent @@ -342,7 +344,7 @@ class ShareController extends AuthPublicShareController { * @param string $token * @param string|null $files * @param string $path - * @return void|\OCP\AppFramework\Http\Response + * @return void|Response * @throws NotFoundException * @deprecated 31.0.0 Users are encouraged to use the DAV endpoint */ @@ -368,7 +370,7 @@ class ShareController extends AuthPublicShareController { } // Directory share else { - /** @var \OCP\Files\Folder $node */ + /** @var Folder $node */ $node = $share->getNode(); // Try to get the path diff --git a/apps/files_sharing/lib/Controller/ShareInfoController.php b/apps/files_sharing/lib/Controller/ShareInfoController.php index df93b485e11..05816a986f7 100644 --- a/apps/files_sharing/lib/Controller/ShareInfoController.php +++ b/apps/files_sharing/lib/Controller/ShareInfoController.php @@ -26,9 +26,6 @@ use OCP\Share\IManager; */ class ShareInfoController extends ApiController { - /** @var IManager */ - private $shareManager; - /** * ShareInfoController constructor. * @@ -36,12 +33,12 @@ class ShareInfoController extends ApiController { * @param IRequest $request * @param IManager $shareManager */ - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - IManager $shareManager) { + private IManager $shareManager, + ) { parent::__construct($appName, $request); - - $this->shareManager = $shareManager; } /** diff --git a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php index 4ab95c2587b..63f057e3bf4 100644 --- a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php +++ b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php @@ -26,27 +26,20 @@ class DeleteOrphanedSharesJob extends TimedJob { private const CHUNK_SIZE = 1000; - private const INTERVAL = 24 * 60 * 60; // 1 day - - private IDBConnection $db; - - private LoggerInterface $logger; + private const INTERVAL = 24 * 60 * 60; /** * sets the correct interval for this timed job */ public function __construct( ITimeFactory $time, - IDBConnection $db, - LoggerInterface $logger, + private IDBConnection $db, + private LoggerInterface $logger, ) { parent::__construct($time); - $this->db = $db; - $this->setInterval(self::INTERVAL); // 1 day $this->setTimeSensitivity(self::TIME_INSENSITIVE); - $this->logger = $logger; } /** diff --git a/apps/files_sharing/lib/Event/BeforeTemplateRenderedEvent.php b/apps/files_sharing/lib/Event/BeforeTemplateRenderedEvent.php index 8261cdb87de..709d7bacd4a 100644 --- a/apps/files_sharing/lib/Event/BeforeTemplateRenderedEvent.php +++ b/apps/files_sharing/lib/Event/BeforeTemplateRenderedEvent.php @@ -23,19 +23,14 @@ class BeforeTemplateRenderedEvent extends Event { */ public const SCOPE_PUBLIC_SHARE_AUTH = 'publicShareAuth'; - /** @var IShare */ - private $share; - /** @var string|null */ - private $scope; - /** * @since 20.0.0 */ - public function __construct(IShare $share, ?string $scope = null) { + public function __construct( + private IShare $share, + private ?string $scope = null, + ) { parent::__construct(); - - $this->share = $share; - $this->scope = $scope; } /** diff --git a/apps/files_sharing/lib/Event/ShareLinkAccessedEvent.php b/apps/files_sharing/lib/Event/ShareLinkAccessedEvent.php index 60d8cf61571..d0cb0a1949d 100644 --- a/apps/files_sharing/lib/Event/ShareLinkAccessedEvent.php +++ b/apps/files_sharing/lib/Event/ShareLinkAccessedEvent.php @@ -13,24 +13,13 @@ use OCP\EventDispatcher\Event; use OCP\Share\IShare; class ShareLinkAccessedEvent extends Event { - /** @var IShare */ - private $share; - - /** @var string */ - private $step; - - /** @var int */ - private $errorCode; - - /** @var string */ - private $errorMessage; - - public function __construct(IShare $share, string $step = '', int $errorCode = 200, string $errorMessage = '') { + public function __construct( + private IShare $share, + private string $step = '', + private int $errorCode = 200, + private string $errorMessage = '', + ) { parent::__construct(); - $this->share = $share; - $this->step = $step; - $this->errorCode = $errorCode; - $this->errorMessage = $errorMessage; } public function getShare(): IShare { diff --git a/apps/files_sharing/lib/Event/ShareMountedEvent.php b/apps/files_sharing/lib/Event/ShareMountedEvent.php index 64bc7cc3f4b..0f56873cb2c 100644 --- a/apps/files_sharing/lib/Event/ShareMountedEvent.php +++ b/apps/files_sharing/lib/Event/ShareMountedEvent.php @@ -13,15 +13,13 @@ use OCP\EventDispatcher\Event; use OCP\Files\Mount\IMountPoint; class ShareMountedEvent extends Event { - /** @var SharedMount */ - private $mount; - /** @var IMountPoint[] */ private $additionalMounts = []; - public function __construct(SharedMount $mount) { + public function __construct( + private SharedMount $mount, + ) { parent::__construct(); - $this->mount = $mount; } public function getMount(): SharedMount { diff --git a/apps/files_sharing/lib/ExpireSharesJob.php b/apps/files_sharing/lib/ExpireSharesJob.php index 39002250924..8ea6fee8a5c 100644 --- a/apps/files_sharing/lib/ExpireSharesJob.php +++ b/apps/files_sharing/lib/ExpireSharesJob.php @@ -18,16 +18,11 @@ use OCP\Share\IShare; */ class ExpireSharesJob extends TimedJob { - /** @var IManager */ - private $shareManager; - - /** @var IDBConnection */ - private $db; - - public function __construct(ITimeFactory $time, IManager $shareManager, IDBConnection $db) { - $this->shareManager = $shareManager; - $this->db = $db; - + public function __construct( + ITimeFactory $time, + private IManager $shareManager, + private IDBConnection $db, + ) { parent::__construct($time); // Run once a day diff --git a/apps/files_sharing/lib/External/Cache.php b/apps/files_sharing/lib/External/Cache.php index deef16c0f1a..3bf6d09e681 100644 --- a/apps/files_sharing/lib/External/Cache.php +++ b/apps/files_sharing/lib/External/Cache.php @@ -9,23 +9,21 @@ namespace OCA\Files_Sharing\External; use OCP\Federation\ICloudId; class Cache extends \OC\Files\Cache\Cache { - /** @var ICloudId */ - private $cloudId; private $remote; private $remoteUser; - private $storage; /** * @param Storage $storage * @param ICloudId $cloudId */ - public function __construct($storage, ICloudId $cloudId) { - $this->cloudId = $cloudId; - $this->storage = $storage; - [, $remote] = explode('://', $cloudId->getRemote(), 2); + public function __construct( + private $storage, + private ICloudId $cloudId, + ) { + [, $remote] = explode('://', $this->cloudId->getRemote(), 2); $this->remote = $remote; - $this->remoteUser = $cloudId->getUser(); - parent::__construct($storage); + $this->remoteUser = $this->cloudId->getUser(); + parent::__construct($this->storage); } public function get($file) { diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index e9383b9abc7..e0d7f96cb90 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -36,71 +36,27 @@ class Manager { /** @var string|null */ private $uid; - /** @var IDBConnection */ - private $connection; - /** @var \OC\Files\Mount\Manager */ private $mountManager; - /** @var IStorageFactory */ - private $storageLoader; - - /** @var IClientService */ - private $clientService; - - /** @var IManager */ - private $notificationManager; - - /** @var IDiscoveryService */ - private $discoveryService; - - /** @var ICloudFederationProviderManager */ - private $cloudFederationProviderManager; - - /** @var ICloudFederationFactory */ - private $cloudFederationFactory; - - /** @var IGroupManager */ - private $groupManager; - - /** @var IUserManager */ - private $userManager; - - /** @var IEventDispatcher */ - private $eventDispatcher; - - /** @var LoggerInterface */ - private $logger; - public function __construct( - IDBConnection $connection, + private IDBConnection $connection, \OC\Files\Mount\Manager $mountManager, - IStorageFactory $storageLoader, - IClientService $clientService, - IManager $notificationManager, - IDiscoveryService $discoveryService, - ICloudFederationProviderManager $cloudFederationProviderManager, - ICloudFederationFactory $cloudFederationFactory, - IGroupManager $groupManager, - IUserManager $userManager, + private IStorageFactory $storageLoader, + private IClientService $clientService, + private IManager $notificationManager, + private IDiscoveryService $discoveryService, + private ICloudFederationProviderManager $cloudFederationProviderManager, + private ICloudFederationFactory $cloudFederationFactory, + private IGroupManager $groupManager, + private IUserManager $userManager, IUserSession $userSession, - IEventDispatcher $eventDispatcher, - LoggerInterface $logger, + private IEventDispatcher $eventDispatcher, + private LoggerInterface $logger, ) { $user = $userSession->getUser(); - $this->connection = $connection; $this->mountManager = $mountManager; - $this->storageLoader = $storageLoader; - $this->clientService = $clientService; $this->uid = $user ? $user->getUID() : null; - $this->notificationManager = $notificationManager; - $this->discoveryService = $discoveryService; - $this->cloudFederationProviderManager = $cloudFederationProviderManager; - $this->cloudFederationFactory = $cloudFederationFactory; - $this->groupManager = $groupManager; - $this->userManager = $userManager; - $this->eventDispatcher = $eventDispatcher; - $this->logger = $logger; } /** diff --git a/apps/files_sharing/lib/External/Mount.php b/apps/files_sharing/lib/External/Mount.php index 685e931e3bc..d7ab61e0364 100644 --- a/apps/files_sharing/lib/External/Mount.php +++ b/apps/files_sharing/lib/External/Mount.php @@ -8,25 +8,26 @@ namespace OCA\Files_Sharing\External; use OC\Files\Mount\MountPoint; use OC\Files\Mount\MoveableMount; +use OC\Files\Storage\Storage; use OCA\Files_Sharing\ISharedMountPoint; class Mount extends MountPoint implements MoveableMount, ISharedMountPoint { /** - * @var \OCA\Files_Sharing\External\Manager - */ - protected $manager; - - /** - * @param string|\OC\Files\Storage\Storage $storage + * @param string|Storage $storage * @param string $mountpoint * @param array $options * @param \OCA\Files_Sharing\External\Manager $manager * @param \OC\Files\Storage\StorageFactory $loader */ - public function __construct($storage, $mountpoint, $options, $manager, $loader = null) { + public function __construct( + $storage, + $mountpoint, + $options, + protected $manager, + $loader = null, + ) { parent::__construct($storage, $mountpoint, $options, $loader, null, null, MountProvider::class); - $this->manager = $manager; } /** diff --git a/apps/files_sharing/lib/External/MountProvider.php b/apps/files_sharing/lib/External/MountProvider.php index 2c639543a87..a29fdd2d544 100644 --- a/apps/files_sharing/lib/External/MountProvider.php +++ b/apps/files_sharing/lib/External/MountProvider.php @@ -17,29 +17,21 @@ class MountProvider implements IMountProvider { public const STORAGE = '\OCA\Files_Sharing\External\Storage'; /** - * @var \OCP\IDBConnection - */ - private $connection; - - /** * @var callable */ private $managerProvider; /** - * @var ICloudIdManager - */ - private $cloudIdManager; - - /** - * @param \OCP\IDBConnection $connection + * @param IDBConnection $connection * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself * @param ICloudIdManager $cloudIdManager */ - public function __construct(IDBConnection $connection, callable $managerProvider, ICloudIdManager $cloudIdManager) { - $this->connection = $connection; + public function __construct( + private IDBConnection $connection, + callable $managerProvider, + private ICloudIdManager $cloudIdManager, + ) { $this->managerProvider = $managerProvider; - $this->cloudIdManager = $cloudIdManager; } public function getMount(IUser $user, $data, IStorageFactory $storageFactory) { diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index 629e5c2c268..dbf7d2af6e5 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -188,8 +188,8 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, * Check whether this storage is permanently or temporarily * unavailable * - * @throws \OCP\Files\StorageNotAvailableException - * @throws \OCP\Files\StorageInvalidException + * @throws StorageNotAvailableException + * @throws StorageInvalidException */ public function checkStorageAvailability() { // see if we can find out why the share is unavailable diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php index 538e37fa88e..1e5c5c8abe5 100644 --- a/apps/files_sharing/lib/Helper.php +++ b/apps/files_sharing/lib/Helper.php @@ -43,7 +43,7 @@ class Helper { /** * get default share folder * - * @param \OC\Files\View|null $view + * @param View|null $view * @param string|null $userId * @return string */ diff --git a/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php b/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php index fc4dd4d798a..281c96ca5e7 100644 --- a/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php +++ b/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php @@ -19,15 +19,10 @@ use OCP\Share\IShare; /** @template-implements IEventListener<UserAddedEvent> */ class UserAddedToGroupListener implements IEventListener { - /** @var IManager */ - private $shareManager; - - /** @var IConfig */ - private $config; - - public function __construct(IManager $shareManager, IConfig $config) { - $this->shareManager = $shareManager; - $this->config = $config; + public function __construct( + private IManager $shareManager, + private IConfig $config, + ) { } public function handle(Event $event): void { diff --git a/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php b/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php index 7b9e00d9668..0ac447436bd 100644 --- a/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php +++ b/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php @@ -20,17 +20,11 @@ use OCP\Share\IShare; /** @template-implements IEventListener<ShareCreatedEvent> */ class UserShareAcceptanceListener implements IEventListener { - /** @var IConfig */ - private $config; - /** @var IManager */ - private $shareManager; - /** @var IGroupManager */ - private $groupManager; - - public function __construct(IConfig $config, IManager $shareManager, IGroupManager $groupManager) { - $this->config = $config; - $this->shareManager = $shareManager; - $this->groupManager = $groupManager; + public function __construct( + private IConfig $config, + private IManager $shareManager, + private IGroupManager $groupManager, + ) { } public function handle(Event $event): void { diff --git a/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php b/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php index 91b8b73579e..ad34a1d2ab9 100644 --- a/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php +++ b/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php @@ -14,15 +14,10 @@ use OCP\IL10N; use OCP\Share\IManager; class OCSShareAPIMiddleware extends Middleware { - /** @var IManager */ - private $shareManager; - /** @var IL10N */ - private $l; - - public function __construct(IManager $shareManager, - IL10N $l) { - $this->shareManager = $shareManager; - $this->l = $l; + public function __construct( + private IManager $shareManager, + private IL10N $l, + ) { } /** diff --git a/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php b/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php index 0be662fbe0d..1f29e855eb5 100644 --- a/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php +++ b/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php @@ -15,11 +15,9 @@ use OCP\AppFramework\Middleware; use OCP\Share\IManager; class ShareInfoMiddleware extends Middleware { - /** @var IManager */ - private $shareManager; - - public function __construct(IManager $shareManager) { - $this->shareManager = $shareManager; + public function __construct( + private IManager $shareManager, + ) { } /** diff --git a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php index 009692c5667..75ee8d3fb83 100644 --- a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php +++ b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php @@ -29,32 +29,14 @@ use OCP\Share\IManager; */ class SharingCheckMiddleware extends Middleware { - /** @var string */ - protected $appName; - /** @var IConfig */ - protected $config; - /** @var IAppManager */ - protected $appManager; - /** @var IControllerMethodReflector */ - protected $reflector; - /** @var IManager */ - protected $shareManager; - /** @var IRequest */ - protected $request; - - public function __construct(string $appName, - IConfig $config, - IAppManager $appManager, - IControllerMethodReflector $reflector, - IManager $shareManager, - IRequest $request, + public function __construct( + protected string $appName, + protected IConfig $config, + protected IAppManager $appManager, + protected IControllerMethodReflector $reflector, + protected IManager $shareManager, + protected IRequest $request, ) { - $this->appName = $appName; - $this->config = $config; - $this->appManager = $appManager; - $this->reflector = $reflector; - $this->shareManager = $shareManager; - $this->request = $request; } /** diff --git a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php index 90a088506fc..c9511eaa136 100644 --- a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php +++ b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php @@ -18,16 +18,10 @@ use OCP\Share\IShare; */ class OwncloudGuestShareType implements IRepairStep { - /** @var IDBConnection */ - private $connection; - - /** @var IConfig */ - private $config; - - - public function __construct(IDBConnection $connection, IConfig $config) { - $this->connection = $connection; - $this->config = $config; + public function __construct( + private IDBConnection $connection, + private IConfig $config, + ) { } /** diff --git a/apps/files_sharing/lib/Migration/SetPasswordColumn.php b/apps/files_sharing/lib/Migration/SetPasswordColumn.php index 0185bfad435..647e3bef8d3 100644 --- a/apps/files_sharing/lib/Migration/SetPasswordColumn.php +++ b/apps/files_sharing/lib/Migration/SetPasswordColumn.php @@ -18,16 +18,10 @@ use OCP\Share\IShare; */ class SetPasswordColumn implements IRepairStep { - /** @var IDBConnection */ - private $connection; - - /** @var IConfig */ - private $config; - - - public function __construct(IDBConnection $connection, IConfig $config) { - $this->connection = $connection; - $this->config = $config; + public function __construct( + private IDBConnection $connection, + private IConfig $config, + ) { } /** diff --git a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php index 21dbb64fef0..c9fe840d422 100644 --- a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php +++ b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php @@ -18,11 +18,9 @@ use OCP\Migration\SimpleMigrationStep; class Version11300Date20201120141438 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): ?ISchemaWrapper { diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index 06e3ed1e147..ad9498371d3 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -11,6 +11,7 @@ use OCA\Files_Sharing\Event\ShareMountedEvent; use OCP\Cache\CappedMemoryCache; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Config\IMountProvider; +use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage\IStorageFactory; use OCP\ICacheFactory; use OCP\IConfig; @@ -21,7 +22,7 @@ use Psr\Log\LoggerInterface; class MountProvider implements IMountProvider { /** - * @param \OCP\IConfig $config + * @param IConfig $config * @param IManager $shareManager * @param LoggerInterface $logger */ @@ -37,9 +38,9 @@ class MountProvider implements IMountProvider { /** * Get all mountpoints applicable for the user and check for shares where we need to update the etags * - * @param \OCP\IUser $user - * @param \OCP\Files\Storage\IStorageFactory $loader - * @return \OCP\Files\Mount\IMountPoint[] + * @param IUser $user + * @param IStorageFactory $loader + * @return IMountPoint[] */ public function getMountsForUser(IUser $user, IStorageFactory $loader) { $shares = $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_USER, null, -1); @@ -65,7 +66,7 @@ class MountProvider implements IMountProvider { $foldersExistCache = new CappedMemoryCache(); foreach ($superShares as $share) { try { - /** @var \OCP\Share\IShare $parentShare */ + /** @var IShare $parentShare */ $parentShare = $share[0]; if ($parentShare->getStatus() !== IShare::STATUS_ACCEPTED && @@ -124,9 +125,9 @@ class MountProvider implements IMountProvider { /** * Groups shares by path (nodeId) and target path * - * @param \OCP\Share\IShare[] $shares - * @return \OCP\Share\IShare[][] array of grouped shares, each element in the - * array is a group which itself is an array of shares + * @param IShare[] $shares + * @return IShare[][] array of grouped shares, each element in the + * array is a group which itself is an array of shares */ private function groupShares(array $shares) { $tmp = []; @@ -161,8 +162,8 @@ class MountProvider implements IMountProvider { * grouped shares. The most permissive permissions are used based on the permissions * of all shares within the group. * - * @param \OCP\Share\IShare[] $allShares - * @param \OCP\IUser $user user + * @param IShare[] $allShares + * @param IUser $user user * @return array Tuple of [superShare, groupedShares] */ private function buildSuperShares(array $allShares, IUser $user) { @@ -170,7 +171,7 @@ class MountProvider implements IMountProvider { $groupedShares = $this->groupShares($allShares); - /** @var \OCP\Share\IShare[] $shares */ + /** @var IShare[] $shares */ foreach ($groupedShares as $shares) { if (count($shares) === 0) { continue; diff --git a/apps/files_sharing/lib/Notification/Listener.php b/apps/files_sharing/lib/Notification/Listener.php index e925ca75fb8..c40ad6e8f7b 100644 --- a/apps/files_sharing/lib/Notification/Listener.php +++ b/apps/files_sharing/lib/Notification/Listener.php @@ -20,21 +20,11 @@ use Symfony\Component\EventDispatcher\GenericEvent; class Listener { - /** @var INotificationManager */ - protected $notificationManager; - /** @var IShareManager */ - protected $shareManager; - /** @var IGroupManager */ - protected $groupManager; - public function __construct( - INotificationManager $notificationManager, - IShareManager $shareManager, - IGroupManager $groupManager, + protected INotificationManager $notificationManager, + protected IShareManager $shareManager, + protected IGroupManager $groupManager, ) { - $this->notificationManager = $notificationManager; - $this->shareManager = $shareManager; - $this->groupManager = $groupManager; } public function shareNotification(ShareCreatedEvent $event): void { diff --git a/apps/files_sharing/lib/Notification/Notifier.php b/apps/files_sharing/lib/Notification/Notifier.php index 2609f99e691..43f61258395 100644 --- a/apps/files_sharing/lib/Notification/Notifier.php +++ b/apps/files_sharing/lib/Notification/Notifier.php @@ -28,31 +28,14 @@ class Notifier implements INotifier { public const INCOMING_USER_SHARE = 'incoming_user_share'; public const INCOMING_GROUP_SHARE = 'incoming_group_share'; - /** @var IFactory */ - protected $l10nFactory; - /** @var IManager */ - private $shareManager; - /** @var IRootFolder */ - private $rootFolder; - /** @var IGroupManager */ - protected $groupManager; - /** @var IUserManager */ - protected $userManager; - /** @var IURLGenerator */ - protected $url; - - public function __construct(IFactory $l10nFactory, - IManager $shareManager, - IRootFolder $rootFolder, - IGroupManager $groupManager, - IUserManager $userManager, - IURLGenerator $url) { - $this->l10nFactory = $l10nFactory; - $this->shareManager = $shareManager; - $this->rootFolder = $rootFolder; - $this->groupManager = $groupManager; - $this->userManager = $userManager; - $this->url = $url; + public function __construct( + protected IFactory $l10nFactory, + private IManager $shareManager, + private IRootFolder $rootFolder, + protected IGroupManager $groupManager, + protected IUserManager $userManager, + protected IURLGenerator $url, + ) { } /** diff --git a/apps/files_sharing/lib/OrphanHelper.php b/apps/files_sharing/lib/OrphanHelper.php index c5ad93a354f..220de619c87 100644 --- a/apps/files_sharing/lib/OrphanHelper.php +++ b/apps/files_sharing/lib/OrphanHelper.php @@ -14,15 +14,10 @@ use OCP\Files\IRootFolder; use OCP\IDBConnection; class OrphanHelper { - private IDBConnection $connection; - private IRootFolder $rootFolder; - public function __construct( - IDBConnection $connection, - IRootFolder $rootFolder, + private IDBConnection $connection, + private IRootFolder $rootFolder, ) { - $this->connection = $connection; - $this->rootFolder = $rootFolder; } public function isShareValid(string $owner, int $fileId): bool { diff --git a/apps/files_sharing/lib/Scanner.php b/apps/files_sharing/lib/Scanner.php index ec0959088ce..d346d34cb03 100644 --- a/apps/files_sharing/lib/Scanner.php +++ b/apps/files_sharing/lib/Scanner.php @@ -8,6 +8,7 @@ namespace OCA\Files_Sharing; use OC\Files\ObjectStore\ObjectStoreScanner; +use OC\Files\Storage\Storage; /** * Scanner for SharedStorage @@ -43,7 +44,7 @@ class Scanner extends \OC\Files\Cache\Scanner { return $this->sourceScanner; } if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { - /** @var \OC\Files\Storage\Storage $storage */ + /** @var Storage $storage */ [$storage] = $this->storage->resolvePath(''); $this->sourceScanner = $storage->getScanner(); return $this->sourceScanner; diff --git a/apps/files_sharing/lib/Settings/Personal.php b/apps/files_sharing/lib/Settings/Personal.php index 4f7ca05d3ad..e2146017dd5 100644 --- a/apps/files_sharing/lib/Settings/Personal.php +++ b/apps/files_sharing/lib/Settings/Personal.php @@ -16,17 +16,11 @@ use OCP\Settings\ISettings; class Personal implements ISettings { - /** @var IConfig */ - private $config; - /** @var IInitialState */ - private $initialState; - /** @var string */ - private $userId; - - public function __construct(IConfig $config, IInitialState $initialState, string $userId) { - $this->config = $config; - $this->initialState = $initialState; - $this->userId = $userId; + public function __construct( + private IConfig $config, + private IInitialState $initialState, + private string $userId, + ) { } public function getForm(): TemplateResponse { diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index 6a5a55abed2..5f7e8f376f1 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -32,10 +32,10 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint */ protected $storage = null; - /** @var \OCP\Share\IShare */ + /** @var IShare */ private $superShare; - /** @var \OCP\Share\IShare[] */ + /** @var IShare[] */ private $groupedShares; public function __construct( @@ -60,7 +60,7 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint /** * check if the parent folder exists otherwise move the mount point up * - * @param \OCP\Share\IShare $share + * @param IShare $share * @param SharedMount[] $mountpoints * @param CappedMemoryCache<bool> $folderExistCache * @return string @@ -113,7 +113,7 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint * update fileTarget in the database if the mount point changed * * @param string $newPath - * @param \OCP\Share\IShare $share + * @param IShare $share * @return bool */ private function updateFileTarget($newPath, &$share) { @@ -220,14 +220,14 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint } /** - * @return \OCP\Share\IShare + * @return IShare */ public function getShare() { return $this->superShare; } /** - * @return \OCP\Share\IShare[] + * @return IShare[] */ public function getGroupedShares(): array { return $this->groupedShares; diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 630eae0634e..335b18d1cd8 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -17,6 +17,7 @@ use OC\Files\Storage\Storage; use OC\Files\Storage\Wrapper\Jail; use OC\Files\Storage\Wrapper\PermissionsMask; use OC\Files\Storage\Wrapper\Wrapper; +use OC\Files\View; use OC\Share\Share; use OC\User\NoUserException; use OCA\Files_External\Config\ConfigAdapter; @@ -44,14 +45,14 @@ use Psr\Log\LoggerInterface; * Convert target path to source path and pass the function call to the correct storage provider */ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage, IDisableEncryptionStorage { - /** @var \OCP\Share\IShare */ + /** @var IShare */ private $superShare; - /** @var \OCP\Share\IShare[] */ + /** @var IShare[] */ private $groupedShares; /** - * @var \OC\Files\View + * @var View */ private $ownerView; diff --git a/apps/files_sharing/lib/ViewOnly.php b/apps/files_sharing/lib/ViewOnly.php index 2a837b627af..9cd18f968f6 100644 --- a/apps/files_sharing/lib/ViewOnly.php +++ b/apps/files_sharing/lib/ViewOnly.php @@ -17,11 +17,9 @@ use OCP\Files\NotFoundException; */ class ViewOnly { - /** @var Folder */ - private $userFolder; - - public function __construct(Folder $userFolder) { - $this->userFolder = $userFolder; + public function __construct( + private Folder $userFolder, + ) { } /** diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index d549d441df4..ec76186c566 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -18,6 +18,7 @@ use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\Constants; +use OCP\Files\Folder; use OCP\IConfig; use OCP\IDateTimeZone; use OCP\IL10N; @@ -42,7 +43,7 @@ class ApiTest extends TestCase { private static $tempStorage; - /** @var \OCP\Files\Folder */ + /** @var Folder */ private $userFolder; /** @var string */ diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php index 1d622e6a14a..6813accd9be 100644 --- a/apps/files_sharing/tests/CacheTest.php +++ b/apps/files_sharing/tests/CacheTest.php @@ -6,7 +6,9 @@ */ namespace OCA\Files_Sharing\Tests; +use OC\Files\Cache\Cache; use OC\Files\Filesystem; +use OC\Files\Storage\Storage; use OC\Files\Storage\Temporary; use OC\Files\Storage\Wrapper\Jail; use OC\Files\View; @@ -22,20 +24,20 @@ use OCP\Share\IShare; class CacheTest extends TestCase { /** - * @var \OC\Files\View + * @var View */ public $user2View; - /** @var \OC\Files\Cache\Cache */ + /** @var Cache */ protected $ownerCache; - /** @var \OC\Files\Cache\Cache */ + /** @var Cache */ protected $sharedCache; - /** @var \OC\Files\Storage\Storage */ + /** @var Storage */ protected $ownerStorage; - /** @var \OC\Files\Storage\Storage */ + /** @var Storage */ protected $sharedStorage; /** @var \OCP\Share\IManager */ diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php index 05b412a60b6..81e2de72ec1 100644 --- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php +++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php @@ -9,6 +9,7 @@ namespace OCA\Files_Sharing\Tests\Command; use OCA\Files_Sharing\Command\CleanupRemoteStorages; use OCP\Federation\ICloudId; use OCP\Federation\ICloudIdManager; +use OCP\IDBConnection; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; @@ -28,7 +29,7 @@ class CleanupRemoteStoragesTest extends TestCase { private $command; /** - * @var \OCP\IDBConnection + * @var IDBConnection */ private $connection; diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 7ae010b026f..aeba8cb9aea 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -1570,7 +1570,7 @@ class ShareAPIControllerTest extends TestCase { * @dataProvider dataCanAccessRoomShare * * @param bool $expects - * @param \OCP\Share\IShare $share + * @param IShare $share * @param bool helperAvailable * @param bool canAccessShareByHelper */ @@ -4701,7 +4701,7 @@ class ShareAPIControllerTest extends TestCase { * @dataProvider dataFormatShare * * @param array $expects - * @param \OCP\Share\IShare $share + * @param IShare $share * @param array $users * @param $exception */ @@ -4920,7 +4920,7 @@ class ShareAPIControllerTest extends TestCase { * @dataProvider dataFormatRoomShare * * @param array $expects - * @param \OCP\Share\IShare $share + * @param IShare $share * @param bool $helperAvailable * @param array $formatShareByHelper */ diff --git a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php index a35642b0793..ad3caa2d3f8 100644 --- a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php +++ b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php @@ -9,6 +9,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Files\Filesystem; use OCA\Files_Sharing\DeleteOrphanedSharesJob; use OCP\Constants; +use OCP\IDBConnection; use OCP\Server; use OCP\Share\IShare; @@ -31,7 +32,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase { private $job; /** - * @var \OCP\IDBConnection + * @var IDBConnection */ private $connection; diff --git a/apps/files_sharing/tests/EtagPropagationTest.php b/apps/files_sharing/tests/EtagPropagationTest.php index 2b6d45561ba..cca19e7afd9 100644 --- a/apps/files_sharing/tests/EtagPropagationTest.php +++ b/apps/files_sharing/tests/EtagPropagationTest.php @@ -437,7 +437,7 @@ class EtagPropagationTest extends PropagationTestCase { $node = $userFolder->get('/sub1/sub2/folder'); $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node); - /** @var \OCP\Share\IShare[] $shares */ + /** @var IShare[] $shares */ $shares = array_filter($shares, function (IShare $share) { return $share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2; }); diff --git a/apps/files_sharing/tests/ExpireSharesJobTest.php b/apps/files_sharing/tests/ExpireSharesJobTest.php index c3b81591ebc..b0f78d12eed 100644 --- a/apps/files_sharing/tests/ExpireSharesJobTest.php +++ b/apps/files_sharing/tests/ExpireSharesJobTest.php @@ -9,6 +9,7 @@ namespace OCA\Files_Sharing\Tests; use OCA\Files_Sharing\ExpireSharesJob; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Constants; +use OCP\IDBConnection; use OCP\Share\IManager; use OCP\Share\IShare; @@ -24,7 +25,7 @@ class ExpireSharesJobTest extends \Test\TestCase { /** @var ExpireSharesJob */ private $job; - /** @var \OCP\IDBConnection */ + /** @var IDBConnection */ private $connection; /** @var string */ diff --git a/apps/files_sharing/tests/External/CacheTest.php b/apps/files_sharing/tests/External/CacheTest.php index 0f5c204f79e..5a862d8ddc0 100644 --- a/apps/files_sharing/tests/External/CacheTest.php +++ b/apps/files_sharing/tests/External/CacheTest.php @@ -7,6 +7,7 @@ namespace OCA\Files_Sharing\Tests\External; use OC\Federation\CloudIdManager; +use OC\Files\Storage\Storage; use OCA\Files_Sharing\External\Cache; use OCA\Files_Sharing\Tests\TestCase; use OCP\Contacts\IManager; @@ -29,7 +30,7 @@ class CacheTest extends TestCase { protected $contactsManager; /** - * @var \OC\Files\Storage\Storage + * @var Storage **/ private $storage; diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 282467c4e28..2bd0a1e14bf 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -73,7 +73,7 @@ class ManagerTest extends TestCase { private $uid; /** - * @var \OCP\IUser + * @var IUser */ private $user; private $testMountProvider; diff --git a/apps/files_sharing/tests/External/ScannerTest.php b/apps/files_sharing/tests/External/ScannerTest.php index 3966fe9f71f..6241174fb28 100644 --- a/apps/files_sharing/tests/External/ScannerTest.php +++ b/apps/files_sharing/tests/External/ScannerTest.php @@ -6,6 +6,7 @@ */ namespace OCA\Files_Sharing\Tests\External; +use OC\Files\Cache\Cache; use OCA\Files_Sharing\External\Scanner; use OCA\Files_Sharing\External\Storage; use Test\TestCase; @@ -17,7 +18,7 @@ class ScannerTest extends TestCase { protected Scanner $scanner; /** @var Storage|\PHPUnit\Framework\MockObject\MockObject */ protected $storage; - /** @var \OC\Files\Cache\Cache|\PHPUnit\Framework\MockObject\MockObject */ + /** @var Cache|\PHPUnit\Framework\MockObject\MockObject */ protected $cache; protected function setUp(): void { diff --git a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php index e15914f6ba1..9e46232aa39 100644 --- a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php +++ b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php @@ -9,6 +9,7 @@ namespace OCA\Files_Sharing\Tests\Migration; use OCA\Files_Sharing\Migration\SetPasswordColumn; use OCA\Files_Sharing\Tests\TestCase; use OCP\IConfig; +use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Share\IShare; @@ -19,7 +20,7 @@ use OCP\Share\IShare; */ class SetPasswordColumnTest extends TestCase { - /** @var \OCP\IDBConnection */ + /** @var IDBConnection */ private $connection; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ diff --git a/apps/files_sharing/tests/PropagationTestCase.php b/apps/files_sharing/tests/PropagationTestCase.php index 78ff394bb80..04852e53e21 100644 --- a/apps/files_sharing/tests/PropagationTestCase.php +++ b/apps/files_sharing/tests/PropagationTestCase.php @@ -6,11 +6,12 @@ */ namespace OCA\Files_Sharing\Tests; +use OC\Files\View; use OCA\Files_Sharing\Helper; abstract class PropagationTestCase extends TestCase { /** - * @var \OC\Files\View + * @var View */ protected $rootView; protected $fileIds = []; // [$user=>[$path=>$id]] diff --git a/apps/files_sharing/tests/ShareTest.php b/apps/files_sharing/tests/ShareTest.php index 2a3800dec19..b79235676e2 100644 --- a/apps/files_sharing/tests/ShareTest.php +++ b/apps/files_sharing/tests/ShareTest.php @@ -6,6 +6,7 @@ */ namespace OCA\Files_Sharing\Tests; +use OC\Files\FileInfo; use OC\Files\Filesystem; use OCA\Files_Sharing\Helper; use OCP\Constants; @@ -100,7 +101,7 @@ class ShareTest extends TestCase { } /** - * @param \OC\Files\FileInfo[] $content + * @param FileInfo[] $content * @param string[] $expected */ public function verifyDirContent($content, $expected) { diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php index 2aa4f38c0da..a91931501b4 100644 --- a/apps/files_sharing/tests/SharedStorageTest.php +++ b/apps/files_sharing/tests/SharedStorageTest.php @@ -9,6 +9,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Files\Cache\FailedCache; use OC\Files\Filesystem; use OC\Files\Storage\FailedStorage; +use OC\Files\Storage\Storage; use OC\Files\Storage\Temporary; use OC\Files\View; use OCA\Files_Sharing\SharedStorage; @@ -88,7 +89,7 @@ class SharedStorageTest extends TestCase { $this->assertFalse($user2View->is_dir($this->folder)); // delete the local folder - /** @var \OC\Files\Storage\Storage $storage */ + /** @var Storage $storage */ [$storage, $internalPath] = Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/localfolder'); $storage->rmdir($internalPath); diff --git a/apps/files_sharing/tests/TestCase.php b/apps/files_sharing/tests/TestCase.php index 473b7cb7227..d12a6bf0ec2 100644 --- a/apps/files_sharing/tests/TestCase.php +++ b/apps/files_sharing/tests/TestCase.php @@ -15,6 +15,7 @@ use OCA\Files_Sharing\AppInfo\Application; use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider; use OCA\Files_Sharing\MountProvider; use OCP\Files\Config\IMountProviderCollection; +use OCP\Files\IRootFolder; use OCP\Share\IShare; use Test\Traits\MountProviderTrait; @@ -38,11 +39,11 @@ abstract class TestCase extends \Test\TestCase { public $filename; public $data; /** - * @var \OC\Files\View + * @var View */ public $view; /** - * @var \OC\Files\View + * @var View */ public $view2; public $folder; @@ -50,7 +51,7 @@ abstract class TestCase extends \Test\TestCase { /** @var \OCP\Share\IManager */ protected $shareManager; - /** @var \OCP\Files\IRootFolder */ + /** @var IRootFolder */ protected $rootFolder; public static function setUpBeforeClass(): void { @@ -218,7 +219,7 @@ abstract class TestCase extends \Test\TestCase { * @param string $initiator * @param string $recipient * @param int $permissions - * @return \OCP\Share\IShare + * @return IShare */ protected function share($type, $path, $initiator, $recipient, $permissions) { $userFolder = $this->rootFolder->getUserFolder($initiator); diff --git a/apps/files_sharing/tests/WatcherTest.php b/apps/files_sharing/tests/WatcherTest.php index cddba7db735..2d1568e6a31 100644 --- a/apps/files_sharing/tests/WatcherTest.php +++ b/apps/files_sharing/tests/WatcherTest.php @@ -6,6 +6,8 @@ */ namespace OCA\Files_Sharing\Tests; +use OC\Files\Cache\Cache; +use OC\Files\Storage\Storage; use OC\Files\View; use OCP\Constants; use OCP\Share\IShare; @@ -17,19 +19,19 @@ use OCP\Share\IShare; */ class WatcherTest extends TestCase { - /** @var \OC\Files\Storage\Storage */ + /** @var Storage */ private $ownerStorage; - /** @var \OC\Files\Cache\Cache */ + /** @var Cache */ private $ownerCache; - /** @var \OC\Files\Storage\Storage */ + /** @var Storage */ private $sharedStorage; - /** @var \OC\Files\Cache\Cache */ + /** @var Cache */ private $sharedCache; - /** @var \OCP\Share\IShare */ + /** @var IShare */ private $_share; protected function setUp(): void { |