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 | |
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')
27 files changed, 132 insertions, 304 deletions
diff --git a/apps/files/lib/Activity/FavoriteProvider.php b/apps/files/lib/Activity/FavoriteProvider.php index dd24eaedd2c..84c509f493f 100644 --- a/apps/files/lib/Activity/FavoriteProvider.php +++ b/apps/files/lib/Activity/FavoriteProvider.php @@ -18,32 +18,21 @@ class FavoriteProvider implements IProvider { public const SUBJECT_ADDED = 'added_favorite'; public const SUBJECT_REMOVED = 'removed_favorite'; - /** @var IFactory */ - protected $languageFactory; - /** @var IL10N */ protected $l; - /** @var IURLGenerator */ - protected $url; - - /** @var IManager */ - protected $activityManager; - - /** @var IEventMerger */ - protected $eventMerger; - /** * @param IFactory $languageFactory * @param IURLGenerator $url * @param IManager $activityManager * @param IEventMerger $eventMerger */ - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IEventMerger $eventMerger) { - $this->languageFactory = $languageFactory; - $this->url = $url; - $this->activityManager = $activityManager; - $this->eventMerger = $eventMerger; + public function __construct( + protected IFactory $languageFactory, + protected IURLGenerator $url, + protected IManager $activityManager, + protected IEventMerger $eventMerger, + ) { } /** diff --git a/apps/files/lib/Activity/Filter/Favorites.php b/apps/files/lib/Activity/Filter/Favorites.php index 1e63f6d9aee..6683f0bc44e 100644 --- a/apps/files/lib/Activity/Filter/Favorites.php +++ b/apps/files/lib/Activity/Filter/Favorites.php @@ -15,21 +15,6 @@ use OCP\IURLGenerator; class Favorites implements IFilter { - /** @var IL10N */ - protected $l; - - /** @var IURLGenerator */ - protected $url; - - /** @var IManager */ - protected $activityManager; - - /** @var Helper */ - protected $helper; - - /** @var IDBConnection */ - protected $db; - /** * @param IL10N $l * @param IURLGenerator $url @@ -37,12 +22,13 @@ class Favorites implements IFilter { * @param Helper $helper * @param IDBConnection $db */ - public function __construct(IL10N $l, IURLGenerator $url, IManager $activityManager, Helper $helper, IDBConnection $db) { - $this->l = $l; - $this->url = $url; - $this->activityManager = $activityManager; - $this->helper = $helper; - $this->db = $db; + public function __construct( + protected IL10N $l, + protected IURLGenerator $url, + protected IManager $activityManager, + protected Helper $helper, + protected IDBConnection $db, + ) { } /** diff --git a/apps/files/lib/Activity/Filter/FileChanges.php b/apps/files/lib/Activity/Filter/FileChanges.php index e3d04a7b91a..215510147d6 100644 --- a/apps/files/lib/Activity/Filter/FileChanges.php +++ b/apps/files/lib/Activity/Filter/FileChanges.php @@ -11,19 +11,14 @@ use OCP\IURLGenerator; class FileChanges implements IFilter { - /** @var IL10N */ - protected $l; - - /** @var IURLGenerator */ - protected $url; - /** * @param IL10N $l * @param IURLGenerator $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/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php index cb5eb5af1b0..6788a5cbd0d 100644 --- a/apps/files/lib/Activity/Provider.php +++ b/apps/files/lib/Activity/Provider.php @@ -23,56 +23,26 @@ use OCP\IUserManager; use OCP\L10N\IFactory; class Provider implements IProvider { - /** @var IFactory */ - protected $languageFactory; - /** @var IL10N */ protected $l; /** @var IL10N */ protected $activityLang; - /** @var IURLGenerator */ - protected $url; - - /** @var IManager */ - protected $activityManager; - - /** @var IUserManager */ - protected $userManager; - - /** @var IRootFolder */ - protected $rootFolder; - - /** @var IEventMerger */ - protected $eventMerger; - - /** @var ICloudIdManager */ - protected $cloudIdManager; - - /** @var IContactsManager */ - protected $contactsManager; - /** @var string[] cached displayNames - key is the cloud id and value the displayname */ protected $displayNames = []; protected $fileIsEncrypted = false; - public function __construct(IFactory $languageFactory, - IURLGenerator $url, - IManager $activityManager, - IUserManager $userManager, - IRootFolder $rootFolder, - ICloudIdManager $cloudIdManager, - IContactsManager $contactsManager, - IEventMerger $eventMerger) { - $this->languageFactory = $languageFactory; - $this->url = $url; - $this->activityManager = $activityManager; - $this->userManager = $userManager; - $this->rootFolder = $rootFolder; - $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 IRootFolder $rootFolder, + protected ICloudIdManager $cloudIdManager, + protected IContactsManager $contactsManager, + protected IEventMerger $eventMerger, + ) { } /** diff --git a/apps/files/lib/Activity/Settings/FileActivitySettings.php b/apps/files/lib/Activity/Settings/FileActivitySettings.php index 8b6f8043af7..0ca7100832f 100644 --- a/apps/files/lib/Activity/Settings/FileActivitySettings.php +++ b/apps/files/lib/Activity/Settings/FileActivitySettings.php @@ -12,14 +12,12 @@ use OCP\Activity\ActivitySettings; use OCP\IL10N; abstract class FileActivitySettings 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/lib/BackgroundJob/CleanupDirectEditingTokens.php b/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php index b2bbe4477da..a1032b2787d 100644 --- a/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php +++ b/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php @@ -13,13 +13,12 @@ use OCP\BackgroundJob\TimedJob; use OCP\DirectEditing\IManager; class CleanupDirectEditingTokens extends TimedJob { - private IManager $manager; - - public function __construct(ITimeFactory $time, - IManager $manager) { + public function __construct( + ITimeFactory $time, + private IManager $manager, + ) { parent::__construct($time); $this->setInterval(15 * 60); - $this->manager = $manager; } /** diff --git a/apps/files/lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php b/apps/files/lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php index 3a7aaa199d1..8a20b6dfb0c 100644 --- a/apps/files/lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php +++ b/apps/files/lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php @@ -17,14 +17,11 @@ use OCP\BackgroundJob\TimedJob; * Delete all expired "Open local editor" token */ class DeleteExpiredOpenLocalEditor extends TimedJob { - protected OpenLocalEditorMapper $mapper; - public function __construct( ITimeFactory $time, - OpenLocalEditorMapper $mapper, + protected OpenLocalEditorMapper $mapper, ) { parent::__construct($time); - $this->mapper = $mapper; // Run every 12h $this->interval = 12 * 3600; diff --git a/apps/files/lib/BackgroundJob/ScanFiles.php b/apps/files/lib/BackgroundJob/ScanFiles.php index 1d72ed6cde4..3a39382d0b4 100644 --- a/apps/files/lib/BackgroundJob/ScanFiles.php +++ b/apps/files/lib/BackgroundJob/ScanFiles.php @@ -24,29 +24,19 @@ use Psr\Log\LoggerInterface; * @package OCA\Files\BackgroundJob */ class ScanFiles extends TimedJob { - private IConfig $config; - private IEventDispatcher $dispatcher; - private LoggerInterface $logger; - private IDBConnection $connection; - /** Amount of users that should get scanned per execution */ public const USERS_PER_SESSION = 500; public function __construct( - IConfig $config, - IEventDispatcher $dispatcher, - LoggerInterface $logger, - IDBConnection $connection, + private IConfig $config, + private IEventDispatcher $dispatcher, + private LoggerInterface $logger, + private IDBConnection $connection, ITimeFactory $time, ) { parent::__construct($time); // Run once per 10 minutes $this->setInterval(60 * 10); - - $this->config = $config; - $this->dispatcher = $dispatcher; - $this->logger = $logger; - $this->connection = $connection; } protected function runScanner(string $user): void { diff --git a/apps/files/lib/Collaboration/Resources/ResourceProvider.php b/apps/files/lib/Collaboration/Resources/ResourceProvider.php index 0ac54afad7d..73883bc4c6a 100644 --- a/apps/files/lib/Collaboration/Resources/ResourceProvider.php +++ b/apps/files/lib/Collaboration/Resources/ResourceProvider.php @@ -20,22 +20,14 @@ use OCP\IUser; class ResourceProvider implements IProvider { public const RESOURCE_TYPE = 'file'; - /** @var IRootFolder */ - protected $rootFolder; - /** @var IPreview */ - private $preview; - /** @var IURLGenerator */ - private $urlGenerator; - /** @var array */ protected $nodes = []; - public function __construct(IRootFolder $rootFolder, - IPreview $preview, - IURLGenerator $urlGenerator) { - $this->rootFolder = $rootFolder; - $this->preview = $preview; - $this->urlGenerator = $urlGenerator; + public function __construct( + protected IRootFolder $rootFolder, + private IPreview $preview, + private IURLGenerator $urlGenerator, + ) { } private function getNode(IResource $resource): ?Node { diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php index 4c52297003f..02f0977cba9 100644 --- a/apps/files/lib/Command/ScanAppData.php +++ b/apps/files/lib/Command/ScanAppData.php @@ -12,6 +12,7 @@ use OC\DB\ConnectionAdapter; use OC\Files\Utils\Scanner; use OC\ForbiddenException; use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; @@ -49,7 +50,7 @@ class ScanAppData extends Base { protected function scanFiles(OutputInterface $output, string $folder): int { try { - /** @var \OCP\Files\Folder $appData */ + /** @var Folder $appData */ $appData = $this->getAppDataFolder(); } catch (NotFoundException $e) { $output->writeln('<error>NoAppData folder found</error>'); diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 118a4fcb9e2..5ba325f1bf8 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -38,6 +38,7 @@ use OCP\IPreview; use OCP\IRequest; use OCP\IUser; use OCP\IUserSession; +use OCP\PreConditionNotMetException; use OCP\Share\IManager; use OCP\Share\IShare; use Psr\Log\LoggerInterface; @@ -384,7 +385,7 @@ class ApiController extends Controller { * * @param bool $value * @return Response - * @throws \OCP\PreConditionNotMetException + * @throws PreConditionNotMetException */ #[NoAdminRequired] public function showHiddenFiles(bool $value): Response { @@ -397,7 +398,7 @@ class ApiController extends Controller { * * @param bool $value * @return Response - * @throws \OCP\PreConditionNotMetException + * @throws PreConditionNotMetException */ #[NoAdminRequired] public function cropImagePreviews(bool $value): Response { @@ -410,7 +411,7 @@ class ApiController extends Controller { * * @param bool $show * @return Response - * @throws \OCP\PreConditionNotMetException + * @throws PreConditionNotMetException */ #[NoAdminRequired] public function showGridView(bool $show): Response { diff --git a/apps/files/lib/Controller/OpenLocalEditorController.php b/apps/files/lib/Controller/OpenLocalEditorController.php index 1982569e7d2..dae321ae437 100644 --- a/apps/files/lib/Controller/OpenLocalEditorController.php +++ b/apps/files/lib/Controller/OpenLocalEditorController.php @@ -29,28 +29,16 @@ class OpenLocalEditorController extends OCSController { public const TOKEN_DURATION = 600; // 10 Minutes public const TOKEN_RETRIES = 50; - protected ITimeFactory $timeFactory; - protected OpenLocalEditorMapper $mapper; - protected ISecureRandom $secureRandom; - protected LoggerInterface $logger; - protected ?string $userId; - public function __construct( string $appName, IRequest $request, - ITimeFactory $timeFactory, - OpenLocalEditorMapper $mapper, - ISecureRandom $secureRandom, - LoggerInterface $logger, - ?string $userId, + protected ITimeFactory $timeFactory, + protected OpenLocalEditorMapper $mapper, + protected ISecureRandom $secureRandom, + protected LoggerInterface $logger, + protected ?string $userId, ) { parent::__construct($appName, $request); - - $this->timeFactory = $timeFactory; - $this->mapper = $mapper; - $this->secureRandom = $secureRandom; - $this->logger = $logger; - $this->userId = $userId; } /** diff --git a/apps/files/lib/Controller/TemplateController.php b/apps/files/lib/Controller/TemplateController.php index f3272d70d68..551c9c54c4b 100644 --- a/apps/files/lib/Controller/TemplateController.php +++ b/apps/files/lib/Controller/TemplateController.php @@ -25,11 +25,12 @@ use OCP\IRequest; * @psalm-import-type FilesTemplateField from ResponseDefinitions */ class TemplateController extends OCSController { - protected $templateManager; - - public function __construct($appName, IRequest $request, ITemplateManager $templateManager) { + public function __construct( + $appName, + IRequest $request, + protected ITemplateManager $templateManager, + ) { parent::__construct($appName, $request); - $this->templateManager = $templateManager; } /** diff --git a/apps/files/lib/Controller/TransferOwnershipController.php b/apps/files/lib/Controller/TransferOwnershipController.php index 4ef6e392039..1420e57e987 100644 --- a/apps/files/lib/Controller/TransferOwnershipController.php +++ b/apps/files/lib/Controller/TransferOwnershipController.php @@ -26,39 +26,18 @@ use OCP\Notification\IManager as NotificationManager; class TransferOwnershipController extends OCSController { - /** @var string */ - private $userId; - /** @var NotificationManager */ - private $notificationManager; - /** @var ITimeFactory */ - private $timeFactory; - /** @var IJobList */ - private $jobList; - /** @var TransferOwnershipMapper */ - private $mapper; - /** @var IUserManager */ - private $userManager; - /** @var IRootFolder */ - private $rootFolder; - - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - string $userId, - NotificationManager $notificationManager, - ITimeFactory $timeFactory, - IJobList $jobList, - TransferOwnershipMapper $mapper, - IUserManager $userManager, - IRootFolder $rootFolder) { + private string $userId, + private NotificationManager $notificationManager, + private ITimeFactory $timeFactory, + private IJobList $jobList, + private TransferOwnershipMapper $mapper, + private IUserManager $userManager, + private IRootFolder $rootFolder, + ) { parent::__construct($appName, $request); - - $this->userId = $userId; - $this->notificationManager = $notificationManager; - $this->timeFactory = $timeFactory; - $this->jobList = $jobList; - $this->mapper = $mapper; - $this->userManager = $userManager; - $this->rootFolder = $rootFolder; } diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index b6aeb079add..4dd9f4141e2 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -68,7 +68,7 @@ class ViewController extends Controller { * FIXME: Replace with non static code * * @return array - * @throws \OCP\Files\NotFoundException + * @throws NotFoundException */ protected function getStorageInfo(string $dir = '/') { $rootInfo = Filesystem::getFileInfo('/', false); diff --git a/apps/files/lib/DirectEditingCapabilities.php b/apps/files/lib/DirectEditingCapabilities.php index 91c1971cec9..5bceef9305f 100644 --- a/apps/files/lib/DirectEditingCapabilities.php +++ b/apps/files/lib/DirectEditingCapabilities.php @@ -13,12 +13,10 @@ use OCP\Capabilities\IInitialStateExcludedCapability; use OCP\IURLGenerator; class DirectEditingCapabilities implements ICapability, IInitialStateExcludedCapability { - protected DirectEditingService $directEditingService; - protected IURLGenerator $urlGenerator; - - public function __construct(DirectEditingService $directEditingService, IURLGenerator $urlGenerator) { - $this->directEditingService = $directEditingService; - $this->urlGenerator = $urlGenerator; + public function __construct( + protected DirectEditingService $directEditingService, + protected IURLGenerator $urlGenerator, + ) { } /** diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index 4ddab45d441..ce33bbb80a6 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -9,6 +9,7 @@ namespace OCA\Files; use OC\Files\Filesystem; use OCP\Files\FileInfo; +use OCP\Files\NotFoundException; use OCP\ITagManager; use OCP\Util; @@ -19,7 +20,7 @@ class Helper { /** * @param string $dir * @return array - * @throws \OCP\Files\NotFoundException + * @throws NotFoundException */ public static function buildFileStorageStatistics($dir) { // information about storage capacities @@ -47,7 +48,7 @@ class Helper { /** * Determine icon for a given file * - * @param \OCP\Files\FileInfo $file file info + * @param FileInfo $file file info * @return string icon URL */ public static function determineIcon($file) { @@ -70,8 +71,8 @@ class Helper { * Comparator function to sort files alphabetically and have * the directories appear first * - * @param \OCP\Files\FileInfo $a file - * @param \OCP\Files\FileInfo $b file + * @param FileInfo $a file + * @param FileInfo $b file * @return int -1 if $a must come before $b, 1 otherwise */ public static function compareFileNames(FileInfo $a, FileInfo $b) { @@ -89,8 +90,8 @@ class Helper { /** * Comparator function to sort files by date * - * @param \OCP\Files\FileInfo $a file - * @param \OCP\Files\FileInfo $b file + * @param FileInfo $a file + * @param FileInfo $b file * @return int -1 if $a must come before $b, 1 otherwise */ public static function compareTimestamp(FileInfo $a, FileInfo $b) { @@ -102,8 +103,8 @@ class Helper { /** * Comparator function to sort files by size * - * @param \OCP\Files\FileInfo $a file - * @param \OCP\Files\FileInfo $b file + * @param FileInfo $a file + * @param FileInfo $b file * @return int -1 if $a must come before $b, 1 otherwise */ public static function compareSize(FileInfo $a, FileInfo $b) { @@ -115,7 +116,7 @@ class Helper { /** * Formats the file info to be returned as JSON to the client. * - * @param \OCP\Files\FileInfo $i + * @param FileInfo $i * @return array formatted file info */ public static function formatFileInfo(FileInfo $i) { @@ -160,7 +161,7 @@ class Helper { /** * Format file info for JSON - * @param \OCP\Files\FileInfo[] $fileInfos file infos + * @param FileInfo[] $fileInfos file infos * @return array */ public static function formatFileInfos($fileInfos) { @@ -180,7 +181,7 @@ class Helper { * @param string $sortAttribute attribute to sort on * @param bool $sortDescending true for descending sort, false otherwise * @param string $mimetypeFilter limit returned content to this mimetype or mimepart - * @return \OCP\Files\FileInfo[] files + * @return FileInfo[] files */ public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false, $mimetypeFilter = '') { $content = Filesystem::getDirectoryContent($dir, $mimetypeFilter); @@ -231,10 +232,10 @@ class Helper { /** * Sort the given file info array * - * @param \OCP\Files\FileInfo[] $files files to sort + * @param FileInfo[] $files files to sort * @param string $sortAttribute attribute to sort on * @param bool $sortDescending true for descending sort, false otherwise - * @return \OCP\Files\FileInfo[] sorted files + * @return FileInfo[] sorted files */ public static function sortFiles($files, $sortAttribute = 'name', $sortDescending = false) { $sortFunc = 'compareFileNames'; diff --git a/apps/files/lib/Notification/Notifier.php b/apps/files/lib/Notification/Notifier.php index 89ddbb9b6ec..6acc312c126 100644 --- a/apps/files/lib/Notification/Notifier.php +++ b/apps/files/lib/Notification/Notifier.php @@ -25,36 +25,15 @@ use OCP\Notification\INotifier; use OCP\Notification\UnknownNotificationException; class Notifier implements INotifier, IDismissableNotifier { - /** @var IFactory */ - protected $l10nFactory; - - /** @var IURLGenerator */ - protected $urlGenerator; - /** @var TransferOwnershipMapper */ - private $mapper; - /** @var IManager */ - private $notificationManager; - /** @var IUserManager */ - private $userManager; - /** @var ITimeFactory */ - private $timeFactory; - /** @var IJobList */ - private $jobList; - - public function __construct(IFactory $l10nFactory, - IURLGenerator $urlGenerator, - TransferOwnershipMapper $mapper, - IManager $notificationManager, - IUserManager $userManager, - IJobList $jobList, - ITimeFactory $timeFactory) { - $this->l10nFactory = $l10nFactory; - $this->urlGenerator = $urlGenerator; - $this->jobList = $jobList; - $this->mapper = $mapper; - $this->notificationManager = $notificationManager; - $this->userManager = $userManager; - $this->timeFactory = $timeFactory; + public function __construct( + protected IFactory $l10nFactory, + protected IURLGenerator $urlGenerator, + private TransferOwnershipMapper $mapper, + private IManager $notificationManager, + private IUserManager $userManager, + private IJobList $jobList, + private ITimeFactory $timeFactory, + ) { } public function getID(): string { diff --git a/apps/files/lib/Search/FilesSearchProvider.php b/apps/files/lib/Search/FilesSearchProvider.php index 4dfd9bc0d16..f71d58c6fae 100644 --- a/apps/files/lib/Search/FilesSearchProvider.php +++ b/apps/files/lib/Search/FilesSearchProvider.php @@ -35,29 +35,13 @@ use OCP\Search\SearchResultEntry; use OCP\Share\IShare; class FilesSearchProvider implements IFilteringProvider { - /** @var IL10N */ - private $l10n; - - /** @var IURLGenerator */ - private $urlGenerator; - - /** @var IMimeTypeDetector */ - private $mimeTypeDetector; - - /** @var IRootFolder */ - private $rootFolder; - public function __construct( - IL10N $l10n, - IURLGenerator $urlGenerator, - IMimeTypeDetector $mimeTypeDetector, - IRootFolder $rootFolder, + private IL10N $l10n, + private IURLGenerator $urlGenerator, + private IMimeTypeDetector $mimeTypeDetector, + private IRootFolder $rootFolder, private IPreview $previewManager, ) { - $this->l10n = $l10n; - $this->urlGenerator = $urlGenerator; - $this->mimeTypeDetector = $mimeTypeDetector; - $this->rootFolder = $rootFolder; } /** diff --git a/apps/files/lib/Service/DirectEditingService.php b/apps/files/lib/Service/DirectEditingService.php index c21742d25ea..243ddebdc67 100644 --- a/apps/files/lib/Service/DirectEditingService.php +++ b/apps/files/lib/Service/DirectEditingService.php @@ -14,14 +14,10 @@ use OCP\EventDispatcher\IEventDispatcher; class DirectEditingService { - /** @var IManager */ - private $directEditingManager; - /** @var IEventDispatcher */ - private $eventDispatcher; - - public function __construct(IEventDispatcher $eventDispatcher, IManager $directEditingManager) { - $this->directEditingManager = $directEditingManager; - $this->eventDispatcher = $eventDispatcher; + public function __construct( + private IEventDispatcher $eventDispatcher, + private IManager $directEditingManager, + ) { } public function getDirectEditingETag(): string { diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index b5ae26d8b1f..1c48a1eafc4 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -10,9 +10,9 @@ declare(strict_types=1); namespace OCA\Files\Service; use Closure; -use OC\Encryption\Manager as EncryptionManager; use OC\Files\Filesystem; use OC\Files\View; +use OC\User\NoUserException; use OCA\Encryption\Util; use OCA\Files\Exception\TransferOwnershipException; use OCP\Encryption\IManager as IEncryptionManager; @@ -41,10 +41,8 @@ use function rtrim; class OwnershipTransferService { - private IEncryptionManager|EncryptionManager $encryptionManager; - public function __construct( - IEncryptionManager $encryptionManager, + private IEncryptionManager $encryptionManager, private IShareManager $shareManager, private IMountManager $mountManager, private IUserMountCache $userMountCache, @@ -52,7 +50,6 @@ class OwnershipTransferService { private IFactory $l10nFactory, private IRootFolder $rootFolder, ) { - $this->encryptionManager = $encryptionManager; } /** @@ -63,7 +60,7 @@ class OwnershipTransferService { * @param OutputInterface|null $output * @param bool $move * @throws TransferOwnershipException - * @throws \OC\User\NoUserException + * @throws NoUserException */ public function transfer( IUser $sourceUser, diff --git a/apps/files/lib/Service/TagService.php b/apps/files/lib/Service/TagService.php index 4bb43145e4a..450cd79505d 100644 --- a/apps/files/lib/Service/TagService.php +++ b/apps/files/lib/Service/TagService.php @@ -13,6 +13,7 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Events\NodeAddedToFavorite; use OCP\Files\Events\NodeRemovedFromFavorite; use OCP\Files\Folder; +use OCP\Files\NotFoundException; use OCP\ITags; use OCP\IUser; use OCP\IUserSession; @@ -22,29 +23,13 @@ use OCP\IUserSession; */ class TagService { - /** @var IUserSession */ - private $userSession; - /** @var IManager */ - private $activityManager; - /** @var ITags|null */ - private $tagger; - /** @var Folder|null */ - private $homeFolder; - /** @var IEventDispatcher */ - private $dispatcher; - public function __construct( - IUserSession $userSession, - IManager $activityManager, - ?ITags $tagger, - ?Folder $homeFolder, - IEventDispatcher $dispatcher, + private IUserSession $userSession, + private IManager $activityManager, + private ?ITags $tagger, + private ?Folder $homeFolder, + private IEventDispatcher $dispatcher, ) { - $this->userSession = $userSession; - $this->activityManager = $activityManager; - $this->tagger = $tagger; - $this->homeFolder = $homeFolder; - $this->dispatcher = $dispatcher; } /** @@ -55,7 +40,7 @@ class TagService { * @param string $path path * @param array $tags array of tags * @return array list of tags - * @throws \OCP\Files\NotFoundException if the file does not exist + * @throws NotFoundException if the file does not exist */ public function updateFileTags($path, $tags) { if ($this->tagger === null) { diff --git a/apps/files/lib/Service/UserConfig.php b/apps/files/lib/Service/UserConfig.php index c2339965793..0abcfb2a6ad 100644 --- a/apps/files/lib/Service/UserConfig.php +++ b/apps/files/lib/Service/UserConfig.php @@ -49,12 +49,12 @@ class UserConfig { 'allowed' => [true, false], ], ]; - - protected IConfig $config; protected ?IUser $user = null; - public function __construct(IConfig $config, IUserSession $userSession) { - $this->config = $config; + public function __construct( + protected IConfig $config, + IUserSession $userSession, + ) { $this->user = $userSession->getUser(); } diff --git a/apps/files/lib/Service/ViewConfig.php b/apps/files/lib/Service/ViewConfig.php index f28bf9cd3c9..348ce6596e5 100644 --- a/apps/files/lib/Service/ViewConfig.php +++ b/apps/files/lib/Service/ViewConfig.php @@ -33,12 +33,12 @@ class ViewConfig { 'allowed' => [true, false], ], ]; - - protected IConfig $config; protected ?IUser $user = null; - public function __construct(IConfig $config, IUserSession $userSession) { - $this->config = $config; + public function __construct( + protected IConfig $config, + IUserSession $userSession, + ) { $this->user = $userSession->getUser(); } diff --git a/apps/files/tests/BackgroundJob/ScanFilesTest.php b/apps/files/tests/BackgroundJob/ScanFilesTest.php index 0fb5163143f..c535ddb808c 100644 --- a/apps/files/tests/BackgroundJob/ScanFilesTest.php +++ b/apps/files/tests/BackgroundJob/ScanFilesTest.php @@ -12,6 +12,7 @@ use OC\Files\Storage\Temporary; use OCA\Files\BackgroundJob\ScanFiles; use OCP\AppFramework\Utility\ITimeFactory; use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\Config\IUserMountCache; use OCP\IConfig; use OCP\IUser; use Psr\Log\LoggerInterface; @@ -31,7 +32,7 @@ class ScanFilesTest extends TestCase { /** @var ScanFiles */ private $scanFiles; - /** @var \OCP\Files\Config\IUserMountCache */ + /** @var IUserMountCache */ private $mountCache; protected function setUp(): void { diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php index e7f8b962a45..2b1ba34f98e 100644 --- a/apps/files/tests/Controller/ApiControllerTest.php +++ b/apps/files/tests/Controller/ApiControllerTest.php @@ -38,7 +38,7 @@ use Test\TestCase; class ApiControllerTest extends TestCase { /** @var string */ private $appName = 'files'; - /** @var \OCP\IUser */ + /** @var IUser */ private $user; /** @var IRequest */ private $request; @@ -50,7 +50,7 @@ class ApiControllerTest extends TestCase { private $apiController; /** @var \OCP\Share\IManager */ private $shareManager; - /** @var \OCP\IConfig */ + /** @var IConfig */ private $config; /** @var Folder|\PHPUnit\Framework\MockObject\MockObject */ private $userFolder; diff --git a/apps/files/tests/Service/TagServiceTest.php b/apps/files/tests/Service/TagServiceTest.php index 0e3ac66ef38..50c8d586587 100644 --- a/apps/files/tests/Service/TagServiceTest.php +++ b/apps/files/tests/Service/TagServiceTest.php @@ -10,6 +10,7 @@ namespace OCA\Files\Tests\Service; use OCA\Files\Service\TagService; use OCP\Activity\IManager; use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\Folder; use OCP\Files\NotFoundException; use OCP\ITags; use OCP\IUser; @@ -36,7 +37,7 @@ class TagServiceTest extends \Test\TestCase { private $activityManager; /** - * @var \OCP\Files\Folder + * @var Folder */ private $root; @@ -49,7 +50,7 @@ class TagServiceTest extends \Test\TestCase { private $tagService; /** - * @var \OCP\ITags + * @var ITags */ private $tagger; @@ -62,7 +63,7 @@ class TagServiceTest extends \Test\TestCase { \OC_Util::setupFS($this->user); $user = $this->createMock(IUser::class); /** - * @var \OCP\IUserSession + * @var IUserSession */ $this->userSession = $this->createMock(IUserSession::class); $this->userSession->expects($this->any()) |