diff options
590 files changed, 2827 insertions, 6646 deletions
diff --git a/apps/cloud_federation_api/lib/Config.php b/apps/cloud_federation_api/lib/Config.php index 9aefca746a1..cb3f4a2ae76 100644 --- a/apps/cloud_federation_api/lib/Config.php +++ b/apps/cloud_federation_api/lib/Config.php @@ -16,11 +16,9 @@ use OCP\Federation\ICloudFederationProviderManager; */ class Config { - /** @var ICloudFederationProviderManager */ - private $cloudFederationProviderManager; - - public function __construct(ICloudFederationProviderManager $cloudFederationProviderManager) { - $this->cloudFederationProviderManager = $cloudFederationProviderManager; + public function __construct( + private ICloudFederationProviderManager $cloudFederationProviderManager, + ) { } /** diff --git a/apps/comments/lib/Search/Result.php b/apps/comments/lib/Search/Result.php index f9bdc71f0a3..2f2c675c3c1 100644 --- a/apps/comments/lib/Search/Result.php +++ b/apps/comments/lib/Search/Result.php @@ -28,10 +28,6 @@ class Result extends BaseResult { /** * @deprecated 20.0.0 */ - public string $authorName; - /** - * @deprecated 20.0.0 - */ public $path; /** * @deprecated 20.0.0 @@ -45,7 +41,10 @@ class Result extends BaseResult { public function __construct( string $search, IComment $comment, - string $authorName, + /** + * @deprecated 20.0.0 + */ + public string $authorName, string $path, ) { parent::__construct( @@ -56,7 +55,6 @@ class Result extends BaseResult { $this->comment = $this->getRelevantMessagePart($comment->getMessage(), $search); $this->authorId = $comment->getActorId(); - $this->authorName = $authorName; $this->fileName = basename($path); $this->path = $this->getVisiblePath($path); } diff --git a/apps/dav/lib/AppInfo/PluginManager.php b/apps/dav/lib/AppInfo/PluginManager.php index 43fd16ebeb6..fc1cc18a09d 100644 --- a/apps/dav/lib/AppInfo/PluginManager.php +++ b/apps/dav/lib/AppInfo/PluginManager.php @@ -28,16 +28,6 @@ use function is_array; class PluginManager { /** - * @var ServerContainer - */ - private $container; - - /** - * @var IAppManager - */ - private $appManager; - - /** * App plugins * * @var ServerPlugin[] @@ -74,9 +64,10 @@ class PluginManager { * @param ServerContainer $container server container for resolving plugin classes * @param IAppManager $appManager app manager to loading apps and their info */ - public function __construct(ServerContainer $container, IAppManager $appManager) { - $this->container = $container; - $this->appManager = $appManager; + public function __construct( + private ServerContainer $container, + private IAppManager $appManager, + ) { } /** diff --git a/apps/dav/lib/Avatars/AvatarHome.php b/apps/dav/lib/Avatars/AvatarHome.php index 1f86941e592..c3b95db1f4f 100644 --- a/apps/dav/lib/Avatars/AvatarHome.php +++ b/apps/dav/lib/Avatars/AvatarHome.php @@ -16,20 +16,16 @@ use Sabre\Uri; class AvatarHome implements ICollection { - /** @var array */ - private $principalInfo; - /** @var IAvatarManager */ - private $avatarManager; - /** * AvatarHome constructor. * * @param array $principalInfo * @param IAvatarManager $avatarManager */ - public function __construct($principalInfo, IAvatarManager $avatarManager) { - $this->principalInfo = $principalInfo; - $this->avatarManager = $avatarManager; + public function __construct( + private $principalInfo, + private IAvatarManager $avatarManager, + ) { } public function createFile($name, $data = null) { diff --git a/apps/dav/lib/Avatars/AvatarNode.php b/apps/dav/lib/Avatars/AvatarNode.php index 3931ce3ff71..98ee67d3c78 100644 --- a/apps/dav/lib/Avatars/AvatarNode.php +++ b/apps/dav/lib/Avatars/AvatarNode.php @@ -11,10 +11,6 @@ use OCP\IAvatar; use Sabre\DAV\File; class AvatarNode extends File { - private $ext; - private $size; - private $avatar; - /** * AvatarNode constructor. * @@ -22,10 +18,11 @@ class AvatarNode extends File { * @param string $ext * @param IAvatar $avatar */ - public function __construct($size, $ext, $avatar) { - $this->size = $size; - $this->ext = $ext; - $this->avatar = $avatar; + public function __construct( + private $size, + private $ext, + private $avatar, + ) { } /** diff --git a/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php b/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php index abf12f7d587..1165367c33f 100644 --- a/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php +++ b/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php @@ -22,33 +22,20 @@ use Psr\Log\LoggerInterface; */ class BuildReminderIndexBackgroundJob extends QueuedJob { - /** @var IDBConnection */ - private $db; - - /** @var ReminderService */ - private $reminderService; - - private LoggerInterface $logger; - - /** @var IJobList */ - private $jobList; - /** @var ITimeFactory */ private $timeFactory; /** * BuildReminderIndexBackgroundJob constructor. */ - public function __construct(IDBConnection $db, - ReminderService $reminderService, - LoggerInterface $logger, - IJobList $jobList, - ITimeFactory $timeFactory) { + public function __construct( + private IDBConnection $db, + private ReminderService $reminderService, + private LoggerInterface $logger, + private IJobList $jobList, + ITimeFactory $timeFactory, + ) { parent::__construct($timeFactory); - $this->db = $db; - $this->reminderService = $reminderService; - $this->logger = $logger; - $this->jobList = $jobList; $this->timeFactory = $timeFactory; } diff --git a/apps/dav/lib/BackgroundJob/CalendarRetentionJob.php b/apps/dav/lib/BackgroundJob/CalendarRetentionJob.php index 2de9c6d00ee..c6edac4f228 100644 --- a/apps/dav/lib/BackgroundJob/CalendarRetentionJob.php +++ b/apps/dav/lib/BackgroundJob/CalendarRetentionJob.php @@ -13,13 +13,11 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\TimedJob; class CalendarRetentionJob extends TimedJob { - /** @var RetentionService */ - private $service; - - public function __construct(ITimeFactory $time, - RetentionService $service) { + public function __construct( + ITimeFactory $time, + private RetentionService $service, + ) { parent::__construct($time); - $this->service = $service; // Run four times a day $this->setInterval(6 * 60 * 60); diff --git a/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php b/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php index 8895159d6ad..49b6b1607ef 100644 --- a/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php +++ b/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php @@ -13,12 +13,11 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\TimedJob; class CleanupDirectLinksJob extends TimedJob { - /** @var DirectMapper */ - private $mapper; - - public function __construct(ITimeFactory $timeFactory, DirectMapper $mapper) { + public function __construct( + ITimeFactory $timeFactory, + private DirectMapper $mapper, + ) { parent::__construct($timeFactory); - $this->mapper = $mapper; // Run once a day at off-peak time $this->setInterval(24 * 60 * 60); diff --git a/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php b/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php index 6fe10c576bb..7b664d03181 100644 --- a/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php +++ b/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php @@ -14,12 +14,11 @@ use OCP\IDBConnection; class CleanupInvitationTokenJob extends TimedJob { - /** @var IDBConnection */ - private $db; - - public function __construct(IDBConnection $db, ITimeFactory $time) { + public function __construct( + private IDBConnection $db, + ITimeFactory $time, + ) { parent::__construct($time); - $this->db = $db; // Run once a day at off-peak time $this->setInterval(24 * 60 * 60); diff --git a/apps/dav/lib/BackgroundJob/EventReminderJob.php b/apps/dav/lib/BackgroundJob/EventReminderJob.php index 894b347de9f..0e21e06fc35 100644 --- a/apps/dav/lib/BackgroundJob/EventReminderJob.php +++ b/apps/dav/lib/BackgroundJob/EventReminderJob.php @@ -8,6 +8,7 @@ declare(strict_types=1); */ namespace OCA\DAV\BackgroundJob; +use OC\User\NoUserException; use OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException; use OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException; use OCA\DAV\CalDAV\Reminder\ReminderService; @@ -17,18 +18,12 @@ use OCP\IConfig; class EventReminderJob extends TimedJob { - /** @var ReminderService */ - private $reminderService; - - /** @var IConfig */ - private $config; - - public function __construct(ITimeFactory $time, - ReminderService $reminderService, - IConfig $config) { + public function __construct( + ITimeFactory $time, + private ReminderService $reminderService, + private IConfig $config, + ) { parent::__construct($time); - $this->reminderService = $reminderService; - $this->config = $config; // Run every 5 minutes $this->setInterval(5 * 60); @@ -38,7 +33,7 @@ class EventReminderJob extends TimedJob { /** * @throws ProviderNotAvailableException * @throws NotificationTypeDoesNotExistException - * @throws \OC\User\NoUserException + * @throws NoUserException */ public function run($argument):void { if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') { diff --git a/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php b/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php index 67e7d5bded3..6d94f4810ed 100644 --- a/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php +++ b/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php @@ -15,19 +15,12 @@ use OCP\IConfig; class GenerateBirthdayCalendarBackgroundJob extends QueuedJob { - /** @var BirthdayService */ - private $birthdayService; - - /** @var IConfig */ - private $config; - - public function __construct(ITimeFactory $time, - BirthdayService $birthdayService, - IConfig $config) { + public function __construct( + ITimeFactory $time, + private BirthdayService $birthdayService, + private IConfig $config, + ) { parent::__construct($time); - - $this->birthdayService = $birthdayService; - $this->config = $config; } public function run($argument) { diff --git a/apps/dav/lib/BackgroundJob/PruneOutdatedSyncTokensJob.php b/apps/dav/lib/BackgroundJob/PruneOutdatedSyncTokensJob.php index 15fe439beef..8746588acc7 100644 --- a/apps/dav/lib/BackgroundJob/PruneOutdatedSyncTokensJob.php +++ b/apps/dav/lib/BackgroundJob/PruneOutdatedSyncTokensJob.php @@ -18,17 +18,14 @@ use Psr\Log\LoggerInterface; class PruneOutdatedSyncTokensJob extends TimedJob { - private IConfig $config; - private LoggerInterface $logger; - private CardDavBackend $cardDavBackend; - private CalDavBackend $calDavBackend; - - public function __construct(ITimeFactory $timeFactory, CalDavBackend $calDavBackend, CardDavBackend $cardDavBackend, IConfig $config, LoggerInterface $logger) { + public function __construct( + ITimeFactory $timeFactory, + private CalDavBackend $calDavBackend, + private CardDavBackend $cardDavBackend, + private IConfig $config, + private LoggerInterface $logger, + ) { parent::__construct($timeFactory); - $this->calDavBackend = $calDavBackend; - $this->cardDavBackend = $cardDavBackend; - $this->config = $config; - $this->logger = $logger; $this->setInterval(60 * 60 * 24); // One day $this->setTimeSensitivity(self::TIME_INSENSITIVE); } diff --git a/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php b/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php index 24149fe2263..7ec5b7fba79 100644 --- a/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php +++ b/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php @@ -16,12 +16,6 @@ use OCP\IUserManager; class RegisterRegenerateBirthdayCalendars extends QueuedJob { - /** @var IUserManager */ - private $userManager; - - /** @var IJobList */ - private $jobList; - /** * RegisterRegenerateBirthdayCalendars constructor. * @@ -29,12 +23,12 @@ class RegisterRegenerateBirthdayCalendars extends QueuedJob { * @param IUserManager $userManager * @param IJobList $jobList */ - public function __construct(ITimeFactory $time, - IUserManager $userManager, - IJobList $jobList) { + public function __construct( + ITimeFactory $time, + private IUserManager $userManager, + private IJobList $jobList, + ) { parent::__construct($time); - $this->userManager = $userManager; - $this->jobList = $jobList; } /** diff --git a/apps/dav/lib/BackgroundJob/UploadCleanup.php b/apps/dav/lib/BackgroundJob/UploadCleanup.php index aa19dbb22ec..230cde61578 100644 --- a/apps/dav/lib/BackgroundJob/UploadCleanup.php +++ b/apps/dav/lib/BackgroundJob/UploadCleanup.php @@ -19,15 +19,13 @@ use OCP\Files\NotFoundException; use Psr\Log\LoggerInterface; class UploadCleanup extends TimedJob { - private IRootFolder $rootFolder; - private IJobList $jobList; - private LoggerInterface $logger; - - public function __construct(ITimeFactory $time, IRootFolder $rootFolder, IJobList $jobList, LoggerInterface $logger) { + public function __construct( + ITimeFactory $time, + private IRootFolder $rootFolder, + private IJobList $jobList, + private LoggerInterface $logger, + ) { parent::__construct($time); - $this->rootFolder = $rootFolder; - $this->jobList = $jobList; - $this->logger = $logger; // Run once a day $this->setInterval(60 * 60 * 24); diff --git a/apps/dav/lib/BulkUpload/BulkUploadPlugin.php b/apps/dav/lib/BulkUpload/BulkUploadPlugin.php index 381f6aa9e33..137bad34bf5 100644 --- a/apps/dav/lib/BulkUpload/BulkUploadPlugin.php +++ b/apps/dav/lib/BulkUpload/BulkUploadPlugin.php @@ -17,15 +17,10 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; class BulkUploadPlugin extends ServerPlugin { - private Folder $userFolder; - private LoggerInterface $logger; - public function __construct( - Folder $userFolder, - LoggerInterface $logger, + private Folder $userFolder, + private LoggerInterface $logger, ) { - $this->userFolder = $userFolder; - $this->logger = $logger; } /** diff --git a/apps/dav/lib/CalDAV/Activity/Backend.php b/apps/dav/lib/CalDAV/Activity/Backend.php index 56b481097cf..5ae71f4ecc6 100644 --- a/apps/dav/lib/CalDAV/Activity/Backend.php +++ b/apps/dav/lib/CalDAV/Activity/Backend.php @@ -25,27 +25,13 @@ use Sabre\VObject\Reader; */ class Backend { - /** @var IActivityManager */ - protected $activityManager; - - /** @var IGroupManager */ - protected $groupManager; - - /** @var IUserSession */ - protected $userSession; - - /** @var IAppManager */ - protected $appManager; - - /** @var IUserManager */ - protected $userManager; - - public function __construct(IActivityManager $activityManager, IGroupManager $groupManager, IUserSession $userSession, IAppManager $appManager, IUserManager $userManager) { - $this->activityManager = $activityManager; - $this->groupManager = $groupManager; - $this->userSession = $userSession; - $this->appManager = $appManager; - $this->userManager = $userManager; + public function __construct( + protected IActivityManager $activityManager, + protected IGroupManager $groupManager, + protected IUserSession $userSession, + protected IAppManager $appManager, + protected IUserManager $userManager, + ) { } /** diff --git a/apps/dav/lib/CalDAV/Activity/Filter/Calendar.php b/apps/dav/lib/CalDAV/Activity/Filter/Calendar.php index e5c25fd8ae6..7411202044d 100644 --- a/apps/dav/lib/CalDAV/Activity/Filter/Calendar.php +++ b/apps/dav/lib/CalDAV/Activity/Filter/Calendar.php @@ -11,15 +11,10 @@ use OCP\IURLGenerator; class Calendar implements IFilter { - /** @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/dav/lib/CalDAV/Activity/Filter/Todo.php b/apps/dav/lib/CalDAV/Activity/Filter/Todo.php index 6ca31f1688c..6bc7bd4b308 100644 --- a/apps/dav/lib/CalDAV/Activity/Filter/Todo.php +++ b/apps/dav/lib/CalDAV/Activity/Filter/Todo.php @@ -11,15 +11,10 @@ use OCP\IURLGenerator; class Todo implements IFilter { - /** @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/dav/lib/CalDAV/Activity/Provider/Base.php b/apps/dav/lib/CalDAV/Activity/Provider/Base.php index a063a31d015..43d80b4bb6a 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Base.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Base.php @@ -15,27 +15,19 @@ use OCP\IURLGenerator; use OCP\IUserManager; abstract class Base implements IProvider { - /** @var IUserManager */ - protected $userManager; - - /** @var IGroupManager */ - protected $groupManager; - /** @var string[] */ protected $groupDisplayNames = []; - /** @var IURLGenerator */ - protected $url; - /** * @param IUserManager $userManager * @param IGroupManager $groupManager - * @param IURLGenerator $urlGenerator + * @param IURLGenerator $url */ - public function __construct(IUserManager $userManager, IGroupManager $groupManager, IURLGenerator $urlGenerator) { - $this->userManager = $userManager; - $this->groupManager = $groupManager; - $this->url = $urlGenerator; + public function __construct( + protected IUserManager $userManager, + protected IGroupManager $groupManager, + protected IURLGenerator $url, + ) { } protected function setSubjects(IEvent $event, string $subject, array $parameters): void { diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php index 25d3260c7a6..898eb2b5cb6 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php @@ -28,18 +28,9 @@ class Calendar extends Base { public const SUBJECT_UNSHARE_USER = 'calendar_user_unshare'; public const SUBJECT_UNSHARE_GROUP = 'calendar_group_unshare'; - /** @var IFactory */ - protected $languageFactory; - /** @var IL10N */ protected $l; - /** @var IManager */ - protected $activityManager; - - /** @var IEventMerger */ - protected $eventMerger; - /** * @param IFactory $languageFactory * @param IURLGenerator $url @@ -48,11 +39,15 @@ class Calendar extends Base { * @param IGroupManager $groupManager * @param IEventMerger $eventMerger */ - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, IEventMerger $eventMerger) { + public function __construct( + protected IFactory $languageFactory, + IURLGenerator $url, + protected IManager $activityManager, + IUserManager $userManager, + IGroupManager $groupManager, + protected IEventMerger $eventMerger, + ) { parent::__construct($userManager, $groupManager, $url); - $this->languageFactory = $languageFactory; - $this->activityManager = $activityManager; - $this->eventMerger = $eventMerger; } /** diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Event.php b/apps/dav/lib/CalDAV/Activity/Provider/Event.php index 26bf69aecdd..d3cfd00b742 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Event.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Event.php @@ -25,21 +25,9 @@ class Event extends Base { public const SUBJECT_OBJECT_RESTORE = 'object_restore'; public const SUBJECT_OBJECT_DELETE = 'object_delete'; - /** @var IFactory */ - protected $languageFactory; - /** @var IL10N */ protected $l; - /** @var IManager */ - protected $activityManager; - - /** @var IEventMerger */ - protected $eventMerger; - - /** @var IAppManager */ - protected $appManager; - /** * @param IFactory $languageFactory * @param IURLGenerator $url @@ -49,12 +37,16 @@ class Event extends Base { * @param IEventMerger $eventMerger * @param IAppManager $appManager */ - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, IEventMerger $eventMerger, IAppManager $appManager) { + public function __construct( + protected IFactory $languageFactory, + IURLGenerator $url, + protected IManager $activityManager, + IUserManager $userManager, + IGroupManager $groupManager, + protected IEventMerger $eventMerger, + protected IAppManager $appManager, + ) { parent::__construct($userManager, $groupManager, $url); - $this->languageFactory = $languageFactory; - $this->activityManager = $activityManager; - $this->eventMerger = $eventMerger; - $this->appManager = $appManager; } /** diff --git a/apps/dav/lib/CalDAV/Activity/Setting/CalDAVSetting.php b/apps/dav/lib/CalDAV/Activity/Setting/CalDAVSetting.php index 67cc2abc9fd..7ab7f16dbbb 100644 --- a/apps/dav/lib/CalDAV/Activity/Setting/CalDAVSetting.php +++ b/apps/dav/lib/CalDAV/Activity/Setting/CalDAVSetting.php @@ -12,14 +12,12 @@ use OCP\Activity\ActivitySettings; use OCP\IL10N; abstract class CalDAVSetting 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/dav/lib/CalDAV/AppCalendar/AppCalendar.php b/apps/dav/lib/CalDAV/AppCalendar/AppCalendar.php index 2d9beff9ced..87d26324c32 100644 --- a/apps/dav/lib/CalDAV/AppCalendar/AppCalendar.php +++ b/apps/dav/lib/CalDAV/AppCalendar/AppCalendar.php @@ -24,12 +24,14 @@ use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Reader; class AppCalendar extends ExternalCalendar { - protected string $principal; protected ICalendar $calendar; - public function __construct(string $appId, ICalendar $calendar, string $principal) { + public function __construct( + string $appId, + ICalendar $calendar, + protected string $principal, + ) { parent::__construct($appId, $calendar->getUri()); - $this->principal = $principal; $this->calendar = $calendar; } diff --git a/apps/dav/lib/CalDAV/AppCalendar/AppCalendarPlugin.php b/apps/dav/lib/CalDAV/AppCalendar/AppCalendarPlugin.php index 3e058a9b6c1..72f2ed2c163 100644 --- a/apps/dav/lib/CalDAV/AppCalendar/AppCalendarPlugin.php +++ b/apps/dav/lib/CalDAV/AppCalendar/AppCalendarPlugin.php @@ -18,12 +18,10 @@ use Psr\Log\LoggerInterface; /* Plugin for wrapping application generated calendars registered in nextcloud core (OCP\Calendar\ICalendarProvider) */ class AppCalendarPlugin implements ICalendarProvider { - protected IManager $manager; - protected LoggerInterface $logger; - - public function __construct(IManager $manager, LoggerInterface $logger) { - $this->manager = $manager; - $this->logger = $logger; + public function __construct( + protected IManager $manager, + protected LoggerInterface $logger, + ) { } public function getAppID(): string { diff --git a/apps/dav/lib/CalDAV/AppCalendar/CalendarObject.php b/apps/dav/lib/CalDAV/AppCalendar/CalendarObject.php index ba3f7074faf..3c62a26df54 100644 --- a/apps/dav/lib/CalDAV/AppCalendar/CalendarObject.php +++ b/apps/dav/lib/CalDAV/AppCalendar/CalendarObject.php @@ -20,14 +20,11 @@ use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Property\ICalendar\DateTime; class CalendarObject implements ICalendarObject, IACL { - private VCalendar $vobject; - private AppCalendar $calendar; - private ICalendar|ICreateFromString $backend; - - public function __construct(AppCalendar $calendar, ICalendar $backend, VCalendar $vobject) { - $this->backend = $backend; - $this->calendar = $calendar; - $this->vobject = $vobject; + public function __construct( + private AppCalendar $calendar, + private ICalendar|ICreateFromString $backend, + private VCalendar $vobject, + ) { } public function getOwner() { diff --git a/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php b/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php index 933679436d4..b323673969b 100644 --- a/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php +++ b/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php @@ -24,23 +24,10 @@ class EnablePlugin extends ServerPlugin { public const NS_Nextcloud = 'http://nextcloud.com/ns'; /** - * @var IConfig - */ - protected $config; - - /** - * @var BirthdayService - */ - protected $birthdayService; - - /** * @var Server */ protected $server; - /** @var IUser */ - private $user; - /** * PublishPlugin constructor. * @@ -48,10 +35,11 @@ class EnablePlugin extends ServerPlugin { * @param BirthdayService $birthdayService * @param IUser $user */ - public function __construct(IConfig $config, BirthdayService $birthdayService, IUser $user) { - $this->config = $config; - $this->birthdayService = $birthdayService; - $this->user = $user; + public function __construct( + protected IConfig $config, + protected BirthdayService $birthdayService, + private IUser $user, + ) { } /** diff --git a/apps/dav/lib/CalDAV/BirthdayService.php b/apps/dav/lib/CalDAV/BirthdayService.php index 00b27219cbd..e1e46316d74 100644 --- a/apps/dav/lib/CalDAV/BirthdayService.php +++ b/apps/dav/lib/CalDAV/BirthdayService.php @@ -32,28 +32,17 @@ class BirthdayService { public const BIRTHDAY_CALENDAR_URI = 'contact_birthdays'; public const EXCLUDE_FROM_BIRTHDAY_CALENDAR_PROPERTY_NAME = 'X-NC-EXCLUDE-FROM-BIRTHDAY-CALENDAR'; - private GroupPrincipalBackend $principalBackend; - private CalDavBackend $calDavBackEnd; - private CardDavBackend $cardDavBackEnd; - private IConfig $config; - private IDBConnection $dbConnection; - private IL10N $l10n; - /** * BirthdayService constructor. */ - public function __construct(CalDavBackend $calDavBackEnd, - CardDavBackend $cardDavBackEnd, - GroupPrincipalBackend $principalBackend, - IConfig $config, - IDBConnection $dbConnection, - IL10N $l10n) { - $this->calDavBackEnd = $calDavBackEnd; - $this->cardDavBackEnd = $cardDavBackEnd; - $this->principalBackend = $principalBackend; - $this->config = $config; - $this->dbConnection = $dbConnection; - $this->l10n = $l10n; + public function __construct( + private CalDavBackend $calDavBackEnd, + private CardDavBackend $cardDavBackEnd, + private GroupPrincipalBackend $principalBackend, + private IConfig $config, + private IDBConnection $dbConnection, + private IL10N $l10n, + ) { } public function onCardChanged(int $addressBookId, diff --git a/apps/dav/lib/CalDAV/CachedSubscriptionImpl.php b/apps/dav/lib/CalDAV/CachedSubscriptionImpl.php index 1301fdb6000..00fa90f5d20 100644 --- a/apps/dav/lib/CalDAV/CachedSubscriptionImpl.php +++ b/apps/dav/lib/CalDAV/CachedSubscriptionImpl.php @@ -12,19 +12,12 @@ use OCP\Calendar\ICalendar; use OCP\Constants; class CachedSubscriptionImpl implements ICalendar { - private CalDavBackend $backend; - private CachedSubscription $calendar; - /** @var array<string, mixed> */ - private array $calendarInfo; - public function __construct( - CachedSubscription $calendar, - array $calendarInfo, - CalDavBackend $backend, + private CachedSubscription $calendar, + /** @var array<string, mixed> */ + private array $calendarInfo, + private CalDavBackend $backend, ) { - $this->calendar = $calendar; - $this->calendarInfo = $calendarInfo; - $this->backend = $backend; } /** diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php index d3e0b3b2226..6fd7d147131 100644 --- a/apps/dav/lib/CalDAV/Calendar.php +++ b/apps/dav/lib/CalDAV/Calendar.php @@ -31,12 +31,16 @@ use Sabre\DAV\PropPatch; * @property CalDavBackend $caldavBackend */ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable, IMoveTarget { - private IConfig $config; protected IL10N $l10n; private bool $useTrashbin = true; - private LoggerInterface $logger; - public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n, IConfig $config, LoggerInterface $logger) { + public function __construct( + BackendInterface $caldavBackend, + $calendarInfo, + IL10N $l10n, + private IConfig $config, + private LoggerInterface $logger, + ) { // Convert deletion date to ISO8601 string if (isset($calendarInfo[TrashbinPlugin::PROPERTY_DELETED_AT])) { $calendarInfo[TrashbinPlugin::PROPERTY_DELETED_AT] = (new DateTimeImmutable()) @@ -53,10 +57,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable $this->calendarInfo['{DAV:}displayname'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Personal'); } - - $this->config = $config; $this->l10n = $l10n; - $this->logger = $logger; } /** diff --git a/apps/dav/lib/CalDAV/CalendarHome.php b/apps/dav/lib/CalDAV/CalendarHome.php index 4ac00578969..c74c07bc4ab 100644 --- a/apps/dav/lib/CalDAV/CalendarHome.php +++ b/apps/dav/lib/CalDAV/CalendarHome.php @@ -11,6 +11,8 @@ use OCA\DAV\AppInfo\PluginManager; use OCA\DAV\CalDAV\Integration\ExternalCalendar; use OCA\DAV\CalDAV\Integration\ICalendarProvider; use OCA\DAV\CalDAV\Trashbin\TrashbinHome; +use OCP\IConfig; +use OCP\IL10N; use Psr\Log\LoggerInterface; use Sabre\CalDAV\Backend\BackendInterface; use Sabre\CalDAV\Backend\NotificationSupport; @@ -25,23 +27,20 @@ use Sabre\DAV\MkCol; class CalendarHome extends \Sabre\CalDAV\CalendarHome { - /** @var \OCP\IL10N */ + /** @var IL10N */ private $l10n; - /** @var \OCP\IConfig */ + /** @var IConfig */ private $config; /** @var PluginManager */ private $pluginManager; - - /** @var LoggerInterface */ - private $logger; private ?array $cachedChildren = null; public function __construct( BackendInterface $caldavBackend, array $principalInfo, - LoggerInterface $logger, + private LoggerInterface $logger, private bool $returnCachedSubscriptions, ) { parent::__construct($caldavBackend, $principalInfo); @@ -51,7 +50,6 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome { \OC::$server, \OC::$server->getAppManager() ); - $this->logger = $logger; } /** diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php index ea2ac0e9a62..85ca7f78ca4 100644 --- a/apps/dav/lib/CalDAV/CalendarImpl.php +++ b/apps/dav/lib/CalDAV/CalendarImpl.php @@ -25,17 +25,12 @@ use Sabre\VObject\Reader; use function Sabre\Uri\split as uriSplit; class CalendarImpl implements ICreateFromString, IHandleImipMessage { - private CalDavBackend $backend; - private Calendar $calendar; - /** @var array<string, mixed> */ - private array $calendarInfo; - - public function __construct(Calendar $calendar, - array $calendarInfo, - CalDavBackend $backend) { - $this->calendar = $calendar; - $this->calendarInfo = $calendarInfo; - $this->backend = $backend; + public function __construct( + private Calendar $calendar, + /** @var array<string, mixed> */ + private array $calendarInfo, + private CalDavBackend $backend, + ) { } /** diff --git a/apps/dav/lib/CalDAV/CalendarManager.php b/apps/dav/lib/CalDAV/CalendarManager.php index a415a830d2e..1baf53ee457 100644 --- a/apps/dav/lib/CalDAV/CalendarManager.php +++ b/apps/dav/lib/CalDAV/CalendarManager.php @@ -12,18 +12,6 @@ use Psr\Log\LoggerInterface; class CalendarManager { - /** @var CalDavBackend */ - private $backend; - - /** @var IL10N */ - private $l10n; - - /** @var IConfig */ - private $config; - - /** @var LoggerInterface */ - private $logger; - /** * CalendarManager constructor. * @@ -31,11 +19,12 @@ class CalendarManager { * @param IL10N $l10n * @param IConfig $config */ - public function __construct(CalDavBackend $backend, IL10N $l10n, IConfig $config, LoggerInterface $logger) { - $this->backend = $backend; - $this->l10n = $l10n; - $this->config = $config; - $this->logger = $logger; + public function __construct( + private CalDavBackend $backend, + private IL10N $l10n, + private IConfig $config, + private LoggerInterface $logger, + ) { } /** diff --git a/apps/dav/lib/CalDAV/CalendarObject.php b/apps/dav/lib/CalDAV/CalendarObject.php index 0dd9bee9ce4..90a1e97ec4d 100644 --- a/apps/dav/lib/CalDAV/CalendarObject.php +++ b/apps/dav/lib/CalDAV/CalendarObject.php @@ -13,9 +13,6 @@ use Sabre\VObject\Reader; class CalendarObject extends \Sabre\CalDAV\CalendarObject { - /** @var IL10N */ - protected $l10n; - /** * CalendarObject constructor. * @@ -24,16 +21,17 @@ class CalendarObject extends \Sabre\CalDAV\CalendarObject { * @param array $calendarInfo * @param array $objectData */ - public function __construct(CalDavBackend $caldavBackend, IL10N $l10n, + public function __construct( + CalDavBackend $caldavBackend, + protected IL10N $l10n, array $calendarInfo, - array $objectData) { + array $objectData, + ) { parent::__construct($caldavBackend, $calendarInfo, $objectData); if ($this->isShared()) { unset($this->objectData['size']); } - - $this->l10n = $l10n; } /** diff --git a/apps/dav/lib/CalDAV/CalendarProvider.php b/apps/dav/lib/CalDAV/CalendarProvider.php index 90605d4f76e..207713de750 100644 --- a/apps/dav/lib/CalDAV/CalendarProvider.php +++ b/apps/dav/lib/CalDAV/CalendarProvider.php @@ -15,23 +15,12 @@ use Psr\Log\LoggerInterface; class CalendarProvider implements ICalendarProvider { - /** @var CalDavBackend */ - private $calDavBackend; - - /** @var IL10N */ - private $l10n; - - /** @var IConfig */ - private $config; - - /** @var LoggerInterface */ - private $logger; - - public function __construct(CalDavBackend $calDavBackend, IL10N $l10n, IConfig $config, LoggerInterface $logger) { - $this->calDavBackend = $calDavBackend; - $this->l10n = $l10n; - $this->config = $config; - $this->logger = $logger; + public function __construct( + private CalDavBackend $calDavBackend, + private IL10N $l10n, + private IConfig $config, + private LoggerInterface $logger, + ) { } public function getCalendars(string $principalUri, array $calendarUris = []): array { diff --git a/apps/dav/lib/CalDAV/CalendarRoot.php b/apps/dav/lib/CalDAV/CalendarRoot.php index 9ab3a4dd43f..bfe5f84ce31 100644 --- a/apps/dav/lib/CalDAV/CalendarRoot.php +++ b/apps/dav/lib/CalDAV/CalendarRoot.php @@ -12,18 +12,15 @@ use Sabre\CalDAV\Backend; use Sabre\DAVACL\PrincipalBackend; class CalendarRoot extends \Sabre\CalDAV\CalendarRoot { - private LoggerInterface $logger; - private array $returnCachedSubscriptions = []; public function __construct( PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $caldavBackend, $principalPrefix, - LoggerInterface $logger, + private LoggerInterface $logger, ) { parent::__construct($principalBackend, $caldavBackend, $principalPrefix); - $this->logger = $logger; } public function getChildForPrincipal(array $principal) { diff --git a/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php b/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php index 2b4f8ed0223..3f71b1db24c 100644 --- a/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php +++ b/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php @@ -18,18 +18,16 @@ use Sabre\VObject\Property\ICalendar\Duration; * @package OCA\DAV\CalDAV\ICSExportPlugin */ class ICSExportPlugin extends \Sabre\CalDAV\ICSExportPlugin { - private IConfig $config; - private LoggerInterface $logger; - /** @var string */ private const DEFAULT_REFRESH_INTERVAL = 'PT4H'; /** * ICSExportPlugin constructor. */ - public function __construct(IConfig $config, LoggerInterface $logger) { - $this->config = $config; - $this->logger = $logger; + public function __construct( + private IConfig $config, + private LoggerInterface $logger, + ) { } /** diff --git a/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php b/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php index 882a11c34b2..6e755716397 100644 --- a/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php +++ b/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php @@ -32,21 +32,16 @@ abstract class ExternalCalendar implements CalDAV\ICalendar, DAV\IProperties { */ private const DELIMITER = '--'; - /** @var string */ - private $appId; - - /** @var string */ - private $calendarUri; - /** * ExternalCalendar constructor. * * @param string $appId * @param string $calendarUri */ - public function __construct(string $appId, string $calendarUri) { - $this->appId = $appId; - $this->calendarUri = $calendarUri; + public function __construct( + private string $appId, + private string $calendarUri, + ) { } /** diff --git a/apps/dav/lib/CalDAV/Outbox.php b/apps/dav/lib/CalDAV/Outbox.php index ffda73147a6..fc9dc87a574 100644 --- a/apps/dav/lib/CalDAV/Outbox.php +++ b/apps/dav/lib/CalDAV/Outbox.php @@ -15,9 +15,6 @@ use Sabre\CalDAV\Plugin as CalDAVPlugin; */ class Outbox extends \Sabre\CalDAV\Schedule\Outbox { - /** @var IConfig */ - private $config; - /** @var null|bool */ private $disableFreeBusy = null; @@ -27,9 +24,11 @@ class Outbox extends \Sabre\CalDAV\Schedule\Outbox { * @param IConfig $config * @param string $principalUri */ - public function __construct(IConfig $config, string $principalUri) { + public function __construct( + private IConfig $config, + string $principalUri, + ) { parent::__construct($principalUri); - $this->config = $config; } /** diff --git a/apps/dav/lib/CalDAV/PublicCalendarRoot.php b/apps/dav/lib/CalDAV/PublicCalendarRoot.php index e7008bfd82c..edfb9f8dccc 100644 --- a/apps/dav/lib/CalDAV/PublicCalendarRoot.php +++ b/apps/dav/lib/CalDAV/PublicCalendarRoot.php @@ -14,18 +14,6 @@ use Sabre\DAV\Collection; class PublicCalendarRoot extends Collection { - /** @var CalDavBackend */ - protected $caldavBackend; - - /** @var \OCP\IL10N */ - protected $l10n; - - /** @var \OCP\IConfig */ - protected $config; - - /** @var LoggerInterface */ - private $logger; - /** * PublicCalendarRoot constructor. * @@ -33,12 +21,12 @@ class PublicCalendarRoot extends Collection { * @param IL10N $l10n * @param IConfig $config */ - public function __construct(CalDavBackend $caldavBackend, IL10N $l10n, - IConfig $config, LoggerInterface $logger) { - $this->caldavBackend = $caldavBackend; - $this->l10n = $l10n; - $this->config = $config; - $this->logger = $logger; + public function __construct( + protected CalDavBackend $caldavBackend, + protected IL10N $l10n, + protected IConfig $config, + private LoggerInterface $logger, + ) { } /** diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php index 6f8746283d1..1916187af2b 100644 --- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php +++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php @@ -29,28 +29,21 @@ class PublishPlugin extends ServerPlugin { protected $server; /** - * Config instance to get instance secret. - * - * @var IConfig - */ - protected $config; - - /** - * URL Generator for absolute URLs. - * - * @var IURLGenerator - */ - protected $urlGenerator; - - /** * PublishPlugin constructor. * * @param IConfig $config * @param IURLGenerator $urlGenerator */ - public function __construct(IConfig $config, IURLGenerator $urlGenerator) { - $this->config = $config; - $this->urlGenerator = $urlGenerator; + public function __construct( + /** + * Config instance to get instance secret. + */ + protected IConfig $config, + /** + * URL Generator for absolute URLs. + */ + protected IURLGenerator $urlGenerator, + ) { } /** diff --git a/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php b/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php index d3543ce5bae..2fd55a12643 100644 --- a/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php +++ b/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php @@ -11,22 +11,13 @@ use Sabre\Xml\XmlSerializable; class Publisher implements XmlSerializable { /** - * @var string $publishUrl - */ - protected $publishUrl; - - /** - * @var boolean $isPublished - */ - protected $isPublished; - - /** * @param string $publishUrl * @param boolean $isPublished */ - public function __construct($publishUrl, $isPublished) { - $this->publishUrl = $publishUrl; - $this->isPublished = $isPublished; + public function __construct( + protected $publishUrl, + protected $isPublished, + ) { } /** diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php index 33e7ae9c09f..94edff98e52 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php @@ -29,31 +29,18 @@ abstract class AbstractProvider implements INotificationProvider { /** @var string */ public const NOTIFICATION_TYPE = ''; - protected LoggerInterface $logger; - - /** @var L10NFactory */ - protected $l10nFactory; - /** @var IL10N[] */ private $l10ns; /** @var string */ private $fallbackLanguage; - /** @var IURLGenerator */ - protected $urlGenerator; - - /** @var IConfig */ - protected $config; - - public function __construct(LoggerInterface $logger, - L10NFactory $l10nFactory, - IURLGenerator $urlGenerator, - IConfig $config) { - $this->logger = $logger; - $this->l10nFactory = $l10nFactory; - $this->urlGenerator = $urlGenerator; - $this->config = $config; + public function __construct( + protected LoggerInterface $logger, + protected L10NFactory $l10nFactory, + protected IURLGenerator $urlGenerator, + protected IConfig $config, + ) { } /** diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php index b33b9c61834..0fd39a9e459 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php @@ -33,15 +33,14 @@ class EmailProvider extends AbstractProvider { /** @var string */ public const NOTIFICATION_TYPE = 'EMAIL'; - private IMailer $mailer; - - public function __construct(IConfig $config, - IMailer $mailer, + public function __construct( + IConfig $config, + private IMailer $mailer, LoggerInterface $logger, L10NFactory $l10nFactory, - IURLGenerator $urlGenerator) { + IURLGenerator $urlGenerator, + ) { parent::__construct($logger, $l10nFactory, $urlGenerator, $config); - $this->mailer = $mailer; } /** diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php index d8abbc39631..a3f0cce547a 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php @@ -30,21 +30,15 @@ class PushProvider extends AbstractProvider { /** @var string */ public const NOTIFICATION_TYPE = 'DISPLAY'; - /** @var IManager */ - private $manager; - - /** @var ITimeFactory */ - private $timeFactory; - - public function __construct(IConfig $config, - IManager $manager, + public function __construct( + IConfig $config, + private IManager $manager, LoggerInterface $logger, L10NFactory $l10nFactory, IURLGenerator $urlGenerator, - ITimeFactory $timeFactory) { + private ITimeFactory $timeFactory, + ) { parent::__construct($logger, $l10nFactory, $urlGenerator, $config); - $this->manager = $manager; - $this->timeFactory = $timeFactory; } /** diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php b/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php index 21f4f5094d4..a5fad34e63e 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace OCA\DAV\CalDAV\Reminder; use OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException; +use OCP\AppFramework\QueryException; /** * Class NotificationProviderManager @@ -53,7 +54,7 @@ class NotificationProviderManager { * Registers a new provider * * @param string $providerClassName - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ public function registerProvider(string $providerClassName):void { $provider = \OC::$server->query($providerClassName); diff --git a/apps/dav/lib/CalDAV/Reminder/Notifier.php b/apps/dav/lib/CalDAV/Reminder/Notifier.php index f3c784ea21f..137fb509f56 100644 --- a/apps/dav/lib/CalDAV/Reminder/Notifier.php +++ b/apps/dav/lib/CalDAV/Reminder/Notifier.php @@ -26,31 +26,21 @@ use OCP\Notification\UnknownNotificationException; */ class Notifier implements INotifier { - /** @var IFactory */ - private $l10nFactory; - - /** @var IURLGenerator */ - private $urlGenerator; - /** @var IL10N */ private $l10n; - /** @var ITimeFactory */ - private $timeFactory; - /** * Notifier constructor. * - * @param IFactory $factory + * @param IFactory $l10nFactory * @param IURLGenerator $urlGenerator * @param ITimeFactory $timeFactory */ - public function __construct(IFactory $factory, - IURLGenerator $urlGenerator, - ITimeFactory $timeFactory) { - $this->l10nFactory = $factory; - $this->urlGenerator = $urlGenerator; - $this->timeFactory = $timeFactory; + public function __construct( + private IFactory $l10nFactory, + private IURLGenerator $urlGenerator, + private ITimeFactory $timeFactory, + ) { } /** diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index 293ce6a8788..e2d44535ce0 100644 --- a/apps/dav/lib/CalDAV/Reminder/ReminderService.php +++ b/apps/dav/lib/CalDAV/Reminder/ReminderService.php @@ -32,33 +32,6 @@ use function strcasecmp; class ReminderService { - /** @var Backend */ - private $backend; - - /** @var NotificationProviderManager */ - private $notificationProviderManager; - - /** @var IUserManager */ - private $userManager; - - /** @var IGroupManager */ - private $groupManager; - - /** @var CalDavBackend */ - private $caldavBackend; - - /** @var ITimeFactory */ - private $timeFactory; - - /** @var IConfig */ - private $config; - - /** @var LoggerInterface */ - private $logger; - - /** @var Principal */ - private $principalConnector; - public const REMINDER_TYPE_EMAIL = 'EMAIL'; public const REMINDER_TYPE_DISPLAY = 'DISPLAY'; public const REMINDER_TYPE_AUDIO = 'AUDIO'; @@ -74,24 +47,17 @@ class ReminderService { self::REMINDER_TYPE_AUDIO ]; - public function __construct(Backend $backend, - NotificationProviderManager $notificationProviderManager, - IUserManager $userManager, - IGroupManager $groupManager, - CalDavBackend $caldavBackend, - ITimeFactory $timeFactory, - IConfig $config, - LoggerInterface $logger, - Principal $principalConnector) { - $this->backend = $backend; - $this->notificationProviderManager = $notificationProviderManager; - $this->userManager = $userManager; - $this->groupManager = $groupManager; - $this->caldavBackend = $caldavBackend; - $this->timeFactory = $timeFactory; - $this->config = $config; - $this->logger = $logger; - $this->principalConnector = $principalConnector; + public function __construct( + private Backend $backend, + private NotificationProviderManager $notificationProviderManager, + private IUserManager $userManager, + private IGroupManager $groupManager, + private CalDavBackend $caldavBackend, + private ITimeFactory $timeFactory, + private IConfig $config, + private LoggerInterface $logger, + private Principal $principalConnector, + ) { } /** diff --git a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php index 83e2935a46e..e1bd2f5be29 100644 --- a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php +++ b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php @@ -25,17 +25,6 @@ use function array_values; abstract class AbstractPrincipalBackend implements BackendInterface { - /** @var IDBConnection */ - private $db; - - /** @var IUserSession */ - private $userSession; - - /** @var IGroupManager */ - private $groupManager; - - private LoggerInterface $logger; - /** @var ProxyMapper */ private $proxyMapper; @@ -51,27 +40,21 @@ abstract class AbstractPrincipalBackend implements BackendInterface { /** @var string */ private $dbForeignKeyName; - /** @var string */ - private $cuType; - - public function __construct(IDBConnection $dbConnection, - IUserSession $userSession, - IGroupManager $groupManager, - LoggerInterface $logger, + public function __construct( + private IDBConnection $db, + private IUserSession $userSession, + private IGroupManager $groupManager, + private LoggerInterface $logger, ProxyMapper $proxyMapper, string $principalPrefix, string $dbPrefix, - string $cuType) { - $this->db = $dbConnection; - $this->userSession = $userSession; - $this->groupManager = $groupManager; - $this->logger = $logger; + private string $cuType, + ) { $this->proxyMapper = $proxyMapper; $this->principalPrefix = $principalPrefix; $this->dbTableName = 'calendar_' . $dbPrefix . 's'; $this->dbMetaDataTableName = $this->dbTableName . '_md'; $this->dbForeignKeyName = $dbPrefix . '_id'; - $this->cuType = $cuType; } use PrincipalProxyTrait; diff --git a/apps/dav/lib/CalDAV/RetentionService.php b/apps/dav/lib/CalDAV/RetentionService.php index a41aa12bb66..399d1a46639 100644 --- a/apps/dav/lib/CalDAV/RetentionService.php +++ b/apps/dav/lib/CalDAV/RetentionService.php @@ -17,21 +17,11 @@ class RetentionService { public const RETENTION_CONFIG_KEY = 'calendarRetentionObligation'; private const DEFAULT_RETENTION_SECONDS = 30 * 24 * 60 * 60; - /** @var IConfig */ - private $config; - - /** @var ITimeFactory */ - private $time; - - /** @var CalDavBackend */ - private $calDavBackend; - - public function __construct(IConfig $config, - ITimeFactory $time, - CalDavBackend $calDavBackend) { - $this->config = $config; - $this->time = $time; - $this->calDavBackend = $calDavBackend; + public function __construct( + private IConfig $config, + private ITimeFactory $time, + private CalDavBackend $calDavBackend, + ) { } public function getDuration(): int { diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index beca5cff233..f88625b551b 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -45,41 +45,25 @@ use Sabre\VObject\Reader; * @license http://sabre.io/license/ Modified BSD License */ class IMipPlugin extends SabreIMipPlugin { - private IUserSession $userSession; - private IConfig $config; - private IMailer $mailer; - private LoggerInterface $logger; - private ITimeFactory $timeFactory; - private Defaults $defaults; private ?VCalendar $vCalendar = null; - private IMipService $imipService; public const MAX_DATE = '2038-01-01'; public const METHOD_REQUEST = 'request'; public const METHOD_REPLY = 'reply'; public const METHOD_CANCEL = 'cancel'; - public const IMIP_INDENT = 15; // Enough for the length of all body bullet items, in all languages - private EventComparisonService $eventComparisonService; - private IMailManager $mailManager; - - public function __construct(IConfig $config, - IMailer $mailer, - LoggerInterface $logger, - ITimeFactory $timeFactory, - Defaults $defaults, - IUserSession $userSession, - IMipService $imipService, - EventComparisonService $eventComparisonService, - IMailManager $mailManager) { + public const IMIP_INDENT = 15; + + public function __construct( + private IConfig $config, + private IMailer $mailer, + private LoggerInterface $logger, + private ITimeFactory $timeFactory, + private Defaults $defaults, + private IUserSession $userSession, + private IMipService $imipService, + private EventComparisonService $eventComparisonService, + private IMailManager $mailManager, + ) { parent::__construct(''); - $this->userSession = $userSession; - $this->config = $config; - $this->mailer = $mailer; - $this->logger = $logger; - $this->timeFactory = $timeFactory; - $this->defaults = $defaults; - $this->imipService = $imipService; - $this->eventComparisonService = $eventComparisonService; - $this->mailManager = $mailManager; } public function initialize(DAV\Server $server): void { diff --git a/apps/dav/lib/CalDAV/Schedule/Plugin.php b/apps/dav/lib/CalDAV/Schedule/Plugin.php index 11f0dfbe251..3e4f47461a3 100644 --- a/apps/dav/lib/CalDAV/Schedule/Plugin.php +++ b/apps/dav/lib/CalDAV/Schedule/Plugin.php @@ -40,11 +40,6 @@ use function Sabre\Uri\split; class Plugin extends \Sabre\CalDAV\Schedule\Plugin { - /** - * @var IConfig - */ - private $config; - /** @var ITip\Message[] */ private $schedulingResponses = []; @@ -53,16 +48,15 @@ class Plugin extends \Sabre\CalDAV\Schedule\Plugin { public const CALENDAR_USER_TYPE = '{' . self::NS_CALDAV . '}calendar-user-type'; public const SCHEDULE_DEFAULT_CALENDAR_URL = '{' . Plugin::NS_CALDAV . '}schedule-default-calendar-URL'; - private LoggerInterface $logger; - private DefaultCalendarValidator $defaultCalendarValidator; /** * @param IConfig $config */ - public function __construct(IConfig $config, LoggerInterface $logger, DefaultCalendarValidator $defaultCalendarValidator) { - $this->config = $config; - $this->logger = $logger; - $this->defaultCalendarValidator = $defaultCalendarValidator; + public function __construct( + private IConfig $config, + private LoggerInterface $logger, + private DefaultCalendarValidator $defaultCalendarValidator, + ) { } /** diff --git a/apps/dav/lib/CalDAV/Security/RateLimitingPlugin.php b/apps/dav/lib/CalDAV/Security/RateLimitingPlugin.php index 236b5c6d99d..311157994e2 100644 --- a/apps/dav/lib/CalDAV/Security/RateLimitingPlugin.php +++ b/apps/dav/lib/CalDAV/Security/RateLimitingPlugin.php @@ -25,24 +25,16 @@ use function explode; class RateLimitingPlugin extends ServerPlugin { private Limiter $limiter; - private IUserManager $userManager; - private CalDavBackend $calDavBackend; - private IAppConfig $config; - private LoggerInterface $logger; - private ?string $userId; - public function __construct(Limiter $limiter, - IUserManager $userManager, - CalDavBackend $calDavBackend, - LoggerInterface $logger, - IAppConfig $config, - ?string $userId) { + public function __construct( + Limiter $limiter, + private IUserManager $userManager, + private CalDavBackend $calDavBackend, + private LoggerInterface $logger, + private IAppConfig $config, + private ?string $userId, + ) { $this->limiter = $limiter; - $this->userManager = $userManager; - $this->calDavBackend = $calDavBackend; - $this->config = $config; - $this->logger = $logger; - $this->userId = $userId; } public function initialize(DAV\Server $server): void { diff --git a/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php b/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php index 06f4a153bf9..d8c429f2056 100644 --- a/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php +++ b/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php @@ -18,26 +18,13 @@ use Sabre\DAVACL\IACL; class DeletedCalendarObject implements IACL, ICalendarObject, IRestorable { use ACLTrait; - /** @var string */ - private $name; - - /** @var mixed[] */ - private $objectData; - - /** @var string */ - private $principalUri; - - /** @var CalDavBackend */ - private $calDavBackend; - - public function __construct(string $name, - array $objectData, - string $principalUri, - CalDavBackend $calDavBackend) { - $this->name = $name; - $this->objectData = $objectData; - $this->calDavBackend = $calDavBackend; - $this->principalUri = $principalUri; + public function __construct( + private string $name, + /** @var mixed[] */ + private array $objectData, + private string $principalUri, + private CalDavBackend $calDavBackend, + ) { } public function delete() { diff --git a/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObjectsCollection.php b/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObjectsCollection.php index c9db04f7d32..f75e19689f1 100644 --- a/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObjectsCollection.php +++ b/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObjectsCollection.php @@ -25,16 +25,11 @@ class DeletedCalendarObjectsCollection implements ICalendarObjectContainer, IACL public const NAME = 'objects'; - /** @var CalDavBackend */ - protected $caldavBackend; - - /** @var mixed[] */ - private $principalInfo; - - public function __construct(CalDavBackend $caldavBackend, - array $principalInfo) { - $this->caldavBackend = $caldavBackend; - $this->principalInfo = $principalInfo; + public function __construct( + protected CalDavBackend $caldavBackend, + /** @var mixed[] */ + private array $principalInfo, + ) { } /** diff --git a/apps/dav/lib/CalDAV/Trashbin/Plugin.php b/apps/dav/lib/CalDAV/Trashbin/Plugin.php index f3c8342c475..6f58b1f3110 100644 --- a/apps/dav/lib/CalDAV/Trashbin/Plugin.php +++ b/apps/dav/lib/CalDAV/Trashbin/Plugin.php @@ -32,16 +32,14 @@ class Plugin extends ServerPlugin { /** @var bool */ private $disableTrashbin; - /** @var RetentionService */ - private $retentionService; - /** @var Server */ private $server; - public function __construct(IRequest $request, - RetentionService $retentionService) { + public function __construct( + IRequest $request, + private RetentionService $retentionService, + ) { $this->disableTrashbin = $request->getHeader('X-NC-CalDAV-No-Trashbin') === '1'; - $this->retentionService = $retentionService; } public function initialize(Server $server): void { diff --git a/apps/dav/lib/CalDAV/Trashbin/TrashbinHome.php b/apps/dav/lib/CalDAV/Trashbin/TrashbinHome.php index a1958bb2794..1c76bd2295d 100644 --- a/apps/dav/lib/CalDAV/Trashbin/TrashbinHome.php +++ b/apps/dav/lib/CalDAV/Trashbin/TrashbinHome.php @@ -26,16 +26,10 @@ class TrashbinHome implements IACL, ICollection, IProperties { public const NAME = 'trashbin'; - /** @var CalDavBackend */ - private $caldavBackend; - - /** @var array */ - private $principalInfo; - - public function __construct(CalDavBackend $caldavBackend, - array $principalInfo) { - $this->caldavBackend = $caldavBackend; - $this->principalInfo = $principalInfo; + public function __construct( + private CalDavBackend $caldavBackend, + private array $principalInfo, + ) { } public function getOwner(): string { diff --git a/apps/dav/lib/Capabilities.php b/apps/dav/lib/Capabilities.php index 1de64e16e41..b0f63f80f2d 100644 --- a/apps/dav/lib/Capabilities.php +++ b/apps/dav/lib/Capabilities.php @@ -9,10 +9,9 @@ use OCP\Capabilities\ICapability; use OCP\IConfig; class Capabilities implements ICapability { - private IConfig $config; - - public function __construct(IConfig $config) { - $this->config = $config; + public function __construct( + private IConfig $config, + ) { } /** diff --git a/apps/dav/lib/CardDAV/Activity/Backend.php b/apps/dav/lib/CardDAV/Activity/Backend.php index d2466e34f9d..b08414d3b02 100644 --- a/apps/dav/lib/CardDAV/Activity/Backend.php +++ b/apps/dav/lib/CardDAV/Activity/Backend.php @@ -22,31 +22,13 @@ use Sabre\VObject\Reader; class Backend { - /** @var IActivityManager */ - protected $activityManager; - - /** @var IGroupManager */ - protected $groupManager; - - /** @var IUserSession */ - protected $userSession; - - /** @var IAppManager */ - protected $appManager; - - /** @var IUserManager */ - protected $userManager; - - public function __construct(IActivityManager $activityManager, - IGroupManager $groupManager, - IUserSession $userSession, - IAppManager $appManager, - IUserManager $userManager) { - $this->activityManager = $activityManager; - $this->groupManager = $groupManager; - $this->userSession = $userSession; - $this->appManager = $appManager; - $this->userManager = $userManager; + public function __construct( + protected IActivityManager $activityManager, + protected IGroupManager $groupManager, + protected IUserSession $userSession, + protected IAppManager $appManager, + protected IUserManager $userManager, + ) { } /** diff --git a/apps/dav/lib/CardDAV/Activity/Filter.php b/apps/dav/lib/CardDAV/Activity/Filter.php index 2003189ab5c..8934c455def 100644 --- a/apps/dav/lib/CardDAV/Activity/Filter.php +++ b/apps/dav/lib/CardDAV/Activity/Filter.php @@ -11,15 +11,10 @@ use OCP\IURLGenerator; class Filter implements IFilter { - /** @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/dav/lib/CardDAV/Activity/Provider/Addressbook.php b/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php index 31f26554d67..cdb9769401f 100644 --- a/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php +++ b/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php @@ -27,25 +27,15 @@ class Addressbook extends Base { public const SUBJECT_UNSHARE_USER = 'addressbook_user_unshare'; public const SUBJECT_UNSHARE_GROUP = 'addressbook_group_unshare'; - /** @var IFactory */ - protected $languageFactory; - - /** @var IManager */ - protected $activityManager; - - /** @var IEventMerger */ - protected $eventMerger; - - public function __construct(IFactory $languageFactory, + public function __construct( + protected IFactory $languageFactory, IURLGenerator $url, - IManager $activityManager, + protected IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, - IEventMerger $eventMerger) { + protected IEventMerger $eventMerger, + ) { parent::__construct($userManager, $groupManager, $url); - $this->languageFactory = $languageFactory; - $this->activityManager = $activityManager; - $this->eventMerger = $eventMerger; } /** diff --git a/apps/dav/lib/CardDAV/Activity/Provider/Base.php b/apps/dav/lib/CardDAV/Activity/Provider/Base.php index 95b4d52b242..ee430668a32 100644 --- a/apps/dav/lib/CardDAV/Activity/Provider/Base.php +++ b/apps/dav/lib/CardDAV/Activity/Provider/Base.php @@ -18,27 +18,17 @@ use OCP\IURLGenerator; use OCP\IUserManager; abstract class Base implements IProvider { - /** @var IUserManager */ - protected $userManager; - /** @var string[] */ protected $userDisplayNames = []; - /** @var IGroupManager */ - protected $groupManager; - /** @var string[] */ protected $groupDisplayNames = []; - /** @var IURLGenerator */ - protected $url; - - public function __construct(IUserManager $userManager, - IGroupManager $groupManager, - IURLGenerator $urlGenerator) { - $this->userManager = $userManager; - $this->groupManager = $groupManager; - $this->url = $urlGenerator; + public function __construct( + protected IUserManager $userManager, + protected IGroupManager $groupManager, + protected IURLGenerator $url, + ) { } protected function setSubjects(IEvent $event, string $subject, array $parameters): void { diff --git a/apps/dav/lib/CardDAV/Activity/Provider/Card.php b/apps/dav/lib/CardDAV/Activity/Provider/Card.php index aa821f592d9..acf23c00531 100644 --- a/apps/dav/lib/CardDAV/Activity/Provider/Card.php +++ b/apps/dav/lib/CardDAV/Activity/Provider/Card.php @@ -24,30 +24,16 @@ class Card extends Base { public const SUBJECT_UPDATE = 'card_update'; public const SUBJECT_DELETE = 'card_delete'; - /** @var IFactory */ - protected $languageFactory; - - /** @var IManager */ - protected $activityManager; - - /** @var IEventMerger */ - protected $eventMerger; - - /** @var IAppManager */ - protected $appManager; - - public function __construct(IFactory $languageFactory, + public function __construct( + protected IFactory $languageFactory, IURLGenerator $url, - IManager $activityManager, + protected IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, - IEventMerger $eventMerger, - IAppManager $appManager) { + protected IEventMerger $eventMerger, + protected IAppManager $appManager, + ) { parent::__construct($userManager, $groupManager, $url); - $this->languageFactory = $languageFactory; - $this->activityManager = $activityManager; - $this->eventMerger = $eventMerger; - $this->appManager = $appManager; } /** diff --git a/apps/dav/lib/CardDAV/AddressBookImpl.php b/apps/dav/lib/CardDAV/AddressBookImpl.php index 5dfb22141e8..e37281e92eb 100644 --- a/apps/dav/lib/CardDAV/AddressBookImpl.php +++ b/apps/dav/lib/CardDAV/AddressBookImpl.php @@ -17,18 +17,6 @@ use Sabre\VObject\UUIDUtil; class AddressBookImpl implements IAddressBook { - /** @var CardDavBackend */ - private $backend; - - /** @var array */ - private $addressBookInfo; - - /** @var AddressBook */ - private $addressBook; - - /** @var IURLGenerator */ - private $urlGenerator; - /** * AddressBookImpl constructor. * @@ -38,14 +26,11 @@ class AddressBookImpl implements IAddressBook { * @param IUrlGenerator $urlGenerator */ public function __construct( - AddressBook $addressBook, - array $addressBookInfo, - CardDavBackend $backend, - IURLGenerator $urlGenerator) { - $this->addressBook = $addressBook; - $this->addressBookInfo = $addressBookInfo; - $this->backend = $backend; - $this->urlGenerator = $urlGenerator; + private AddressBook $addressBook, + private array $addressBookInfo, + private CardDavBackend $backend, + private IURLGenerator $urlGenerator, + ) { } /** diff --git a/apps/dav/lib/CardDAV/AddressBookRoot.php b/apps/dav/lib/CardDAV/AddressBookRoot.php index ec6fa6c9fe1..5679a03545e 100644 --- a/apps/dav/lib/CardDAV/AddressBookRoot.php +++ b/apps/dav/lib/CardDAV/AddressBookRoot.php @@ -13,26 +13,20 @@ use OCP\IUser; class AddressBookRoot extends \Sabre\CardDAV\AddressBookRoot { - /** @var PluginManager */ - private $pluginManager; - private ?IUser $user; - private ?IGroupManager $groupManager; - /** * @param \Sabre\DAVACL\PrincipalBackend\BackendInterface $principalBackend * @param \Sabre\CardDAV\Backend\BackendInterface $carddavBackend * @param string $principalPrefix */ - public function __construct(\Sabre\DAVACL\PrincipalBackend\BackendInterface $principalBackend, + public function __construct( + \Sabre\DAVACL\PrincipalBackend\BackendInterface $principalBackend, \Sabre\CardDAV\Backend\BackendInterface $carddavBackend, - PluginManager $pluginManager, - ?IUser $user, - ?IGroupManager $groupManager, - string $principalPrefix = 'principals') { + private PluginManager $pluginManager, + private ?IUser $user, + private ?IGroupManager $groupManager, + string $principalPrefix = 'principals', + ) { parent::__construct($principalBackend, $carddavBackend, $principalPrefix); - $this->pluginManager = $pluginManager; - $this->user = $user; - $this->groupManager = $groupManager; } /** diff --git a/apps/dav/lib/CardDAV/ContactsManager.php b/apps/dav/lib/CardDAV/ContactsManager.php index 899396ddc17..39e4e6aa117 100644 --- a/apps/dav/lib/CardDAV/ContactsManager.php +++ b/apps/dav/lib/CardDAV/ContactsManager.php @@ -12,21 +12,16 @@ use OCP\IL10N; use OCP\IURLGenerator; class ContactsManager { - /** @var CardDavBackend */ - private $backend; - - /** @var IL10N */ - private $l10n; - /** * ContactsManager constructor. * * @param CardDavBackend $backend * @param IL10N $l10n */ - public function __construct(CardDavBackend $backend, IL10N $l10n) { - $this->backend = $backend; - $this->l10n = $l10n; + public function __construct( + private CardDavBackend $backend, + private IL10N $l10n, + ) { } /** diff --git a/apps/dav/lib/CardDAV/Converter.php b/apps/dav/lib/CardDAV/Converter.php index a0a25716ed8..64c1cfa66d5 100644 --- a/apps/dav/lib/CardDAV/Converter.php +++ b/apps/dav/lib/CardDAV/Converter.php @@ -20,21 +20,12 @@ use Sabre\VObject\Property\Text; use Sabre\VObject\Property\VCard\Date; class Converter { - /** @var IURLGenerator */ - private $urlGenerator; - /** @var IAccountManager */ - private $accountManager; - private IUserManager $userManager; - public function __construct( - IAccountManager $accountManager, - IUserManager $userManager, - IURLGenerator $urlGenerator, + private IAccountManager $accountManager, + private IUserManager $userManager, + private IURLGenerator $urlGenerator, private LoggerInterface $logger, ) { - $this->accountManager = $accountManager; - $this->userManager = $userManager; - $this->urlGenerator = $urlGenerator; } public function createCardFromUser(IUser $user): ?VCard { diff --git a/apps/dav/lib/CardDAV/ImageExportPlugin.php b/apps/dav/lib/CardDAV/ImageExportPlugin.php index f8c2b6ee827..e9d390d0849 100644 --- a/apps/dav/lib/CardDAV/ImageExportPlugin.php +++ b/apps/dav/lib/CardDAV/ImageExportPlugin.php @@ -18,16 +18,15 @@ class ImageExportPlugin extends ServerPlugin { /** @var Server */ protected $server; - /** @var PhotoCache */ - private $cache; /** * ImageExportPlugin constructor. * * @param PhotoCache $cache */ - public function __construct(PhotoCache $cache) { - $this->cache = $cache; + public function __construct( + private PhotoCache $cache, + ) { } /** diff --git a/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php b/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php index 48e0b0d3036..372906a6ae8 100644 --- a/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php +++ b/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php @@ -32,12 +32,10 @@ abstract class ExternalAddressBook implements IAddressBook, DAV\IProperties { */ private const DELIMITER = '--'; - private string $appId; - private string $uri; - - public function __construct(string $appId, string $uri) { - $this->appId = $appId; - $this->uri = $uri; + public function __construct( + private string $appId, + private string $uri, + ) { } /** diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php index 0fb5592142e..7f9579a377f 100644 --- a/apps/dav/lib/CardDAV/PhotoCache.php +++ b/apps/dav/lib/CardDAV/PhotoCache.php @@ -28,15 +28,13 @@ class PhotoCache { 'image/vnd.microsoft.icon' => 'ico', ]; - protected IAppData $appData; - protected LoggerInterface $logger; - /** * PhotoCache constructor. */ - public function __construct(IAppData $appData, LoggerInterface $logger) { - $this->appData = $appData; - $this->logger = $logger; + public function __construct( + protected IAppData $appData, + protected LoggerInterface $logger, + ) { } /** diff --git a/apps/dav/lib/CardDAV/Security/CardDavRateLimitingPlugin.php b/apps/dav/lib/CardDAV/Security/CardDavRateLimitingPlugin.php index 256d8481ee3..3e18a1341b0 100644 --- a/apps/dav/lib/CardDAV/Security/CardDavRateLimitingPlugin.php +++ b/apps/dav/lib/CardDAV/Security/CardDavRateLimitingPlugin.php @@ -23,22 +23,19 @@ use function count; use function explode; class CardDavRateLimitingPlugin extends ServerPlugin { - private ?string $userId; - public function __construct( private Limiter $limiter, private IUserManager $userManager, private CardDavBackend $cardDavBackend, private LoggerInterface $logger, private IAppConfig $config, - ?string $userId, + private ?string $userId, ) { $this->limiter = $limiter; $this->userManager = $userManager; $this->cardDavBackend = $cardDavBackend; $this->config = $config; $this->logger = $logger; - $this->userId = $userId; } public function initialize(DAV\Server $server): void { diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php index a10c830ec79..4e8c4b1355e 100644 --- a/apps/dav/lib/CardDAV/SyncService.php +++ b/apps/dav/lib/CardDAV/SyncService.php @@ -26,32 +26,19 @@ use function is_null; class SyncService { use TTransactional; - - private CardDavBackend $backend; - private IUserManager $userManager; - private IDBConnection $dbConnection; - private LoggerInterface $logger; private ?array $localSystemAddressBook = null; - private Converter $converter; protected string $certPath; - private IClientService $clientService; - private IConfig $config; - - public function __construct(CardDavBackend $backend, - IUserManager $userManager, - IDBConnection $dbConnection, - LoggerInterface $logger, - Converter $converter, - IClientService $clientService, - IConfig $config) { - $this->backend = $backend; - $this->userManager = $userManager; - $this->logger = $logger; - $this->converter = $converter; + + public function __construct( + private CardDavBackend $backend, + private IUserManager $userManager, + private IDBConnection $dbConnection, + private LoggerInterface $logger, + private Converter $converter, + private IClientService $clientService, + private IConfig $config, + ) { $this->certPath = ''; - $this->dbConnection = $dbConnection; - $this->clientService = $clientService; - $this->config = $config; } /** diff --git a/apps/dav/lib/CardDAV/SystemAddressbook.php b/apps/dav/lib/CardDAV/SystemAddressbook.php index aff51ac5b9b..e0032044e70 100644 --- a/apps/dav/lib/CardDAV/SystemAddressbook.php +++ b/apps/dav/lib/CardDAV/SystemAddressbook.php @@ -30,27 +30,18 @@ use function in_array; class SystemAddressbook extends AddressBook { public const URI_SHARED = 'z-server-generated--system'; - /** @var IConfig */ - private $config; - private IUserSession $userSession; - private ?TrustedServers $trustedServers; - private ?IRequest $request; - private ?IGroupManager $groupManager; - public function __construct(BackendInterface $carddavBackend, + public function __construct( + BackendInterface $carddavBackend, array $addressBookInfo, IL10N $l10n, - IConfig $config, - IUserSession $userSession, - ?IRequest $request = null, - ?TrustedServers $trustedServers = null, - ?IGroupManager $groupManager = null) { + private IConfig $config, + private IUserSession $userSession, + private ?IRequest $request = null, + private ?TrustedServers $trustedServers = null, + private ?IGroupManager $groupManager = null, + ) { parent::__construct($carddavBackend, $addressBookInfo, $l10n); - $this->config = $config; - $this->userSession = $userSession; - $this->request = $request; - $this->trustedServers = $trustedServers; - $this->groupManager = $groupManager; $this->addressBookInfo['{DAV:}displayname'] = $l10n->t('Accounts'); $this->addressBookInfo['{' . Plugin::NS_CARDDAV . '}addressbook-description'] = $l10n->t('System address book which holds all accounts'); diff --git a/apps/dav/lib/CardDAV/UserAddressBooks.php b/apps/dav/lib/CardDAV/UserAddressBooks.php index aee26af4ed9..eaf393dec04 100644 --- a/apps/dav/lib/CardDAV/UserAddressBooks.php +++ b/apps/dav/lib/CardDAV/UserAddressBooks.php @@ -36,20 +36,14 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome { /** @var IConfig */ protected $config; - /** @var PluginManager */ - private $pluginManager; - private ?IUser $user; - private ?IGroupManager $groupManager; - - public function __construct(Backend\BackendInterface $carddavBackend, + public function __construct( + Backend\BackendInterface $carddavBackend, string $principalUri, - PluginManager $pluginManager, - ?IUser $user, - ?IGroupManager $groupManager) { + private PluginManager $pluginManager, + private ?IUser $user, + private ?IGroupManager $groupManager, + ) { parent::__construct($carddavBackend, $principalUri); - $this->pluginManager = $pluginManager; - $this->user = $user; - $this->groupManager = $groupManager; } /** diff --git a/apps/dav/lib/CardDAV/Xml/Groups.php b/apps/dav/lib/CardDAV/Xml/Groups.php index 6100bac1aea..568907813af 100644 --- a/apps/dav/lib/CardDAV/Xml/Groups.php +++ b/apps/dav/lib/CardDAV/Xml/Groups.php @@ -13,14 +13,12 @@ use Sabre\Xml\XmlSerializable; class Groups implements XmlSerializable { public const NS_OWNCLOUD = 'http://owncloud.org/ns'; - /** @var string[] of TYPE:CHECKSUM */ - private $groups; - /** * @param string $groups */ - public function __construct($groups) { - $this->groups = $groups; + public function __construct( + private $groups, + ) { } public function xmlSerialize(Writer $writer) { diff --git a/apps/dav/lib/Comments/CommentNode.php b/apps/dav/lib/Comments/CommentNode.php index d0f0d585888..5dbefa82d93 100644 --- a/apps/dav/lib/Comments/CommentNode.php +++ b/apps/dav/lib/Comments/CommentNode.php @@ -30,37 +30,19 @@ class CommentNode implements \Sabre\DAV\INode, \Sabre\DAV\IProperties { public const PROPERTY_NAME_MENTION_ID = '{http://owncloud.org/ns}mentionId'; public const PROPERTY_NAME_MENTION_DISPLAYNAME = '{http://owncloud.org/ns}mentionDisplayName'; - /** @var IComment */ - public $comment; - - /** @var ICommentsManager */ - protected $commentsManager; - - protected LoggerInterface $logger; - /** @var array list of properties with key being their name and value their setter */ protected $properties = []; - /** @var IUserManager */ - protected $userManager; - - /** @var IUserSession */ - protected $userSession; - /** * CommentNode constructor. */ public function __construct( - ICommentsManager $commentsManager, - IComment $comment, - IUserManager $userManager, - IUserSession $userSession, - LoggerInterface $logger, + protected ICommentsManager $commentsManager, + public IComment $comment, + protected IUserManager $userManager, + protected IUserSession $userSession, + protected LoggerInterface $logger, ) { - $this->commentsManager = $commentsManager; - $this->comment = $comment; - $this->logger = $logger; - $methods = get_class_methods($this->comment); $methods = array_filter($methods, function ($name) { return str_starts_with($name, 'get'); @@ -72,8 +54,6 @@ class CommentNode implements \Sabre\DAV\INode, \Sabre\DAV\IProperties { $name = '{' . self::NS_OWNCLOUD . '}' . lcfirst(substr($getter, 3)); $this->properties[$name] = $getter; } - $this->userManager = $userManager; - $this->userSession = $userSession; } /** diff --git a/apps/dav/lib/Comments/CommentsPlugin.php b/apps/dav/lib/Comments/CommentsPlugin.php index 6cae12d20ab..92ffae3f73e 100644 --- a/apps/dav/lib/Comments/CommentsPlugin.php +++ b/apps/dav/lib/Comments/CommentsPlugin.php @@ -35,24 +35,19 @@ class CommentsPlugin extends ServerPlugin { public const REPORT_PARAM_OFFSET = '{http://owncloud.org/ns}offset'; public const REPORT_PARAM_TIMESTAMP = '{http://owncloud.org/ns}datetime'; - /** @var ICommentsManager */ - protected $commentsManager; - /** @var \Sabre\DAV\Server $server */ private $server; - /** @var \OCP\IUserSession */ - protected $userSession; - /** * Comments plugin * * @param ICommentsManager $commentsManager * @param IUserSession $userSession */ - public function __construct(ICommentsManager $commentsManager, IUserSession $userSession) { - $this->commentsManager = $commentsManager; - $this->userSession = $userSession; + public function __construct( + protected ICommentsManager $commentsManager, + protected IUserSession $userSession, + ) { } /** diff --git a/apps/dav/lib/Comments/EntityCollection.php b/apps/dav/lib/Comments/EntityCollection.php index 3135449641c..33c58ee44d2 100644 --- a/apps/dav/lib/Comments/EntityCollection.php +++ b/apps/dav/lib/Comments/EntityCollection.php @@ -27,11 +27,6 @@ use Sabre\DAV\PropPatch; class EntityCollection extends RootCollection implements IProperties { public const PROPERTY_NAME_READ_MARKER = '{http://owncloud.org/ns}readMarker'; - /** @var string */ - protected $id; - - protected LoggerInterface $logger; - /** * @param string $id * @param string $name @@ -41,12 +36,12 @@ class EntityCollection extends RootCollection implements IProperties { * @param LoggerInterface $logger */ public function __construct( - $id, + protected $id, $name, ICommentsManager $commentsManager, IUserManager $userManager, IUserSession $userSession, - LoggerInterface $logger, + protected LoggerInterface $logger, ) { foreach (['id', 'name'] as $property) { $$property = trim($$property); @@ -54,10 +49,8 @@ class EntityCollection extends RootCollection implements IProperties { throw new \InvalidArgumentException('"' . $property . '" parameter must be non-empty string'); } } - $this->id = $id; $this->name = $name; $this->commentsManager = $commentsManager; - $this->logger = $logger; $this->userManager = $userManager; $this->userSession = $userSession; } diff --git a/apps/dav/lib/Comments/EntityTypeCollection.php b/apps/dav/lib/Comments/EntityTypeCollection.php index b326805542d..1c8533ca375 100644 --- a/apps/dav/lib/Comments/EntityTypeCollection.php +++ b/apps/dav/lib/Comments/EntityTypeCollection.php @@ -26,19 +26,13 @@ use Sabre\DAV\Exception\NotFound; * @package OCA\DAV\Comments */ class EntityTypeCollection extends RootCollection { - protected LoggerInterface $logger; - protected IUserManager $userManager; - - /** @var \Closure */ - protected $childExistsFunction; - public function __construct( string $name, ICommentsManager $commentsManager, - IUserManager $userManager, + protected IUserManager $userManager, IUserSession $userSession, - LoggerInterface $logger, - \Closure $childExistsFunction, + protected LoggerInterface $logger, + protected \Closure $childExistsFunction, ) { $name = trim($name); if (empty($name)) { @@ -46,10 +40,7 @@ class EntityTypeCollection extends RootCollection { } $this->name = $name; $this->commentsManager = $commentsManager; - $this->logger = $logger; - $this->userManager = $userManager; $this->userSession = $userSession; - $this->childExistsFunction = $childExistsFunction; } /** diff --git a/apps/dav/lib/Comments/RootCollection.php b/apps/dav/lib/Comments/RootCollection.php index a9aa88458b7..493d73ec531 100644 --- a/apps/dav/lib/Comments/RootCollection.php +++ b/apps/dav/lib/Comments/RootCollection.php @@ -21,24 +21,15 @@ use Sabre\DAV\ICollection; class RootCollection implements ICollection { /** @var EntityTypeCollection[]|null */ private ?array $entityTypeCollections = null; - protected ICommentsManager $commentsManager; protected string $name = 'comments'; - protected LoggerInterface $logger; - protected IUserManager $userManager; - protected IUserSession $userSession; - protected IEventDispatcher $dispatcher; public function __construct( - ICommentsManager $commentsManager, - IUserManager $userManager, - IUserSession $userSession, - IEventDispatcher $dispatcher, - LoggerInterface $logger) { - $this->commentsManager = $commentsManager; - $this->logger = $logger; - $this->userManager = $userManager; - $this->userSession = $userSession; - $this->dispatcher = $dispatcher; + protected ICommentsManager $commentsManager, + protected IUserManager $userManager, + protected IUserSession $userSession, + protected IEventDispatcher $dispatcher, + protected LoggerInterface $logger, + ) { } /** diff --git a/apps/dav/lib/Connector/LegacyPublicAuth.php b/apps/dav/lib/Connector/LegacyPublicAuth.php index 731654df31a..03d18853de0 100644 --- a/apps/dav/lib/Connector/LegacyPublicAuth.php +++ b/apps/dav/lib/Connector/LegacyPublicAuth.php @@ -26,20 +26,13 @@ class LegacyPublicAuth extends AbstractBasic { private const BRUTEFORCE_ACTION = 'legacy_public_webdav_auth'; private ?IShare $share = null; - private IManager $shareManager; - private ISession $session; - private IRequest $request; - private IThrottler $throttler; - - public function __construct(IRequest $request, - IManager $shareManager, - ISession $session, - IThrottler $throttler) { - $this->request = $request; - $this->shareManager = $shareManager; - $this->session = $session; - $this->throttler = $throttler; + public function __construct( + private IRequest $request, + private IManager $shareManager, + private ISession $session, + private IThrottler $throttler, + ) { // setup realm $defaults = new Defaults(); $this->realm = $defaults->getName() ?: 'Nextcloud'; diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php index 4c6ce557980..fa1c2e95fad 100644 --- a/apps/dav/lib/Connector/Sabre/Auth.php +++ b/apps/dav/lib/Connector/Sabre/Auth.php @@ -27,25 +27,20 @@ use Sabre\HTTP\ResponseInterface; class Auth extends AbstractBasic { public const DAV_AUTHENTICATED = 'AUTHENTICATED_TO_DAV_BACKEND'; - - private ISession $session; private Session $userSession; - private IRequest $request; private ?string $currentUser = null; private Manager $twoFactorManager; - private IThrottler $throttler; - public function __construct(ISession $session, + public function __construct( + private ISession $session, Session $userSession, - IRequest $request, + private IRequest $request, Manager $twoFactorManager, - IThrottler $throttler, - string $principalPrefix = 'principals/users/') { - $this->session = $session; + private IThrottler $throttler, + string $principalPrefix = 'principals/users/', + ) { $this->userSession = $userSession; $this->twoFactorManager = $twoFactorManager; - $this->request = $request; - $this->throttler = $throttler; $this->principalPrefix = $principalPrefix; // setup realm diff --git a/apps/dav/lib/Connector/Sabre/BearerAuth.php b/apps/dav/lib/Connector/Sabre/BearerAuth.php index d5840848cef..1b85a971553 100644 --- a/apps/dav/lib/Connector/Sabre/BearerAuth.php +++ b/apps/dav/lib/Connector/Sabre/BearerAuth.php @@ -14,20 +14,12 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; class BearerAuth extends AbstractBearer { - private IUserSession $userSession; - private ISession $session; - private IRequest $request; - private string $principalPrefix; - - public function __construct(IUserSession $userSession, - ISession $session, - IRequest $request, - $principalPrefix = 'principals/users/') { - $this->userSession = $userSession; - $this->session = $session; - $this->request = $request; - $this->principalPrefix = $principalPrefix; - + public function __construct( + private IUserSession $userSession, + private ISession $session, + private IRequest $request, + private string $principalPrefix = 'principals/users/', + ) { // setup realm $defaults = new Defaults(); $this->realm = $defaults->getName() ?: 'Nextcloud'; diff --git a/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php b/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php index 65e77cea285..e4b6c2636da 100644 --- a/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php @@ -20,13 +20,12 @@ class CommentPropertiesPlugin extends ServerPlugin { public const PROPERTY_NAME_UNREAD = '{http://owncloud.org/ns}comments-unread'; protected ?Server $server = null; - private ICommentsManager $commentsManager; - private IUserSession $userSession; private array $cachedUnreadCount = []; - public function __construct(ICommentsManager $commentsManager, IUserSession $userSession) { - $this->commentsManager = $commentsManager; - $this->userSession = $userSession; + public function __construct( + private ICommentsManager $commentsManager, + private IUserSession $userSession, + ) { } /** diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php index c520a6c5a84..a8b2438d4bc 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -39,20 +39,23 @@ use Sabre\DAV\INode; class Directory extends Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget, \Sabre\DAV\ICopyTarget { /** * Cached directory content - * @var \OCP\Files\FileInfo[] + * @var FileInfo[] */ private ?array $dirContent = null; /** Cached quota info */ private ?array $quotaInfo = null; - private ?CachingTree $tree = null; /** * Sets up the node, expects a full path name */ - public function __construct(View $view, FileInfo $info, ?CachingTree $tree = null, ?IShareManager $shareManager = null) { + public function __construct( + View $view, + FileInfo $info, + private ?CachingTree $tree = null, + ?IShareManager $shareManager = null, + ) { parent::__construct($view, $info, $shareManager); - $this->tree = $tree; } /** @@ -161,7 +164,7 @@ class Directory extends Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuot * Returns a specific child node, referenced by its name * * @param string $name - * @param \OCP\Files\FileInfo $info + * @param FileInfo $info * @return \Sabre\DAV\INode * @throws InvalidPath * @throws \Sabre\DAV\Exception\NotFound diff --git a/apps/dav/lib/Connector/Sabre/Exception/Forbidden.php b/apps/dav/lib/Connector/Sabre/Exception/Forbidden.php index 0dd346a2546..95d4b3ab514 100644 --- a/apps/dav/lib/Connector/Sabre/Exception/Forbidden.php +++ b/apps/dav/lib/Connector/Sabre/Exception/Forbidden.php @@ -11,18 +11,16 @@ class Forbidden extends \Sabre\DAV\Exception\Forbidden { public const NS_OWNCLOUD = 'http://owncloud.org/ns'; /** - * @var bool - */ - private $retry; - - /** * @param string $message * @param bool $retry * @param \Exception $previous */ - public function __construct($message, $retry = false, ?\Exception $previous = null) { + public function __construct( + $message, + private $retry = false, + ?\Exception $previous = null, + ) { parent::__construct($message, 0, $previous); - $this->retry = $retry; } /** diff --git a/apps/dav/lib/Connector/Sabre/Exception/InvalidPath.php b/apps/dav/lib/Connector/Sabre/Exception/InvalidPath.php index a9ec8ffef9a..dfc08aa8b88 100644 --- a/apps/dav/lib/Connector/Sabre/Exception/InvalidPath.php +++ b/apps/dav/lib/Connector/Sabre/Exception/InvalidPath.php @@ -13,18 +13,16 @@ class InvalidPath extends Exception { public const NS_OWNCLOUD = 'http://owncloud.org/ns'; /** - * @var bool - */ - private $retry; - - /** * @param string $message * @param bool $retry * @param \Exception|null $previous */ - public function __construct($message, $retry = false, ?\Exception $previous = null) { + public function __construct( + $message, + private $retry = false, + ?\Exception $previous = null, + ) { parent::__construct($message, 0, $previous); - $this->retry = $retry; } /** diff --git a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php index 2e8fcefe577..686386dbfef 100644 --- a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php +++ b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php @@ -67,15 +67,13 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin { ServerMaintenanceMode::class => true, ]; - private string $appName; - private LoggerInterface $logger; - /** - * @param string $loggerAppName app name to use when logging + * @param string $appName app name to use when logging */ - public function __construct(string $loggerAppName, LoggerInterface $logger) { - $this->appName = $loggerAppName; - $this->logger = $logger; + public function __construct( + private string $appName, + private LoggerInterface $logger, + ) { } /** diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 36ac0fcec72..cafb00fbe1e 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -53,8 +53,8 @@ class File extends Node implements IFile { /** * Sets up the node, expects a full path name * - * @param \OC\Files\View $view - * @param \OCP\Files\FileInfo $info + * @param View $view + * @param FileInfo $info * @param ?\OCP\Share\IManager $shareManager * @param ?IRequest $request * @param ?IL10N $l10n diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php index 49ceff9118d..c44dcc0d2da 100644 --- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php @@ -42,55 +42,8 @@ class FilesReportPlugin extends ServerPlugin { private $server; /** - * @var Tree - */ - private $tree; - - /** - * @var View - */ - private $fileView; - - /** - * @var ISystemTagManager - */ - private $tagManager; - - /** - * @var ISystemTagObjectMapper - */ - private $tagMapper; - - /** - * Manager for private tags - * - * @var ITagManager - */ - private $fileTagger; - - /** - * @var IUserSession - */ - private $userSession; - - /** - * @var IGroupManager - */ - private $groupManager; - - /** - * @var Folder - */ - private $userFolder; - - /** - * @var IAppManager - */ - private $appManager; - - /** * @param Tree $tree - * @param View $view + * @param View $fileView * @param ISystemTagManager $tagManager * @param ISystemTagObjectMapper $tagMapper * @param ITagManager $fileTagger manager for private tags @@ -99,25 +52,20 @@ class FilesReportPlugin extends ServerPlugin { * @param Folder $userFolder * @param IAppManager $appManager */ - public function __construct(Tree $tree, - View $view, - ISystemTagManager $tagManager, - ISystemTagObjectMapper $tagMapper, - ITagManager $fileTagger, - IUserSession $userSession, - IGroupManager $groupManager, - Folder $userFolder, - IAppManager $appManager, + public function __construct( + private Tree $tree, + private View $fileView, + private ISystemTagManager $tagManager, + private ISystemTagObjectMapper $tagMapper, + /** + * Manager for private tags + */ + private ITagManager $fileTagger, + private IUserSession $userSession, + private IGroupManager $groupManager, + private Folder $userFolder, + private IAppManager $appManager, ) { - $this->tree = $tree; - $this->fileView = $view; - $this->tagManager = $tagManager; - $this->tagMapper = $tagMapper; - $this->fileTagger = $fileTagger; - $this->userSession = $userSession; - $this->groupManager = $groupManager; - $this->userFolder = $userFolder; - $this->appManager = $appManager; } /** diff --git a/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php b/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php index 8d23a05a3ec..d5ab7f09dfa 100644 --- a/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php +++ b/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php @@ -16,10 +16,7 @@ use Sabre\DAV\ServerPlugin; class MaintenancePlugin extends ServerPlugin { - /** @var IConfig */ - private $config; - - /** @var \OCP\IL10N */ + /** @var IL10N */ private $l10n; /** @@ -32,8 +29,10 @@ class MaintenancePlugin extends ServerPlugin { /** * @param IConfig $config */ - public function __construct(IConfig $config, IL10N $l10n) { - $this->config = $config; + public function __construct( + private IConfig $config, + IL10N $l10n, + ) { $this->l10n = \OC::$server->getL10N('dav'); } diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index 93cf302ff89..4ee6283b0d2 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -25,11 +25,6 @@ use OCP\Share\IManager; abstract class Node implements \Sabre\DAV\INode { /** - * @var View - */ - protected $fileView; - - /** * The path to the current node * * @var string @@ -55,8 +50,11 @@ abstract class Node implements \Sabre\DAV\INode { /** * Sets up the node, expects a full path name */ - public function __construct(View $view, FileInfo $info, ?IManager $shareManager = null) { - $this->fileView = $view; + public function __construct( + protected View $fileView, + FileInfo $info, + ?IManager $shareManager = null, + ) { $this->path = $this->fileView->getRelativePath($info->getPath()); $this->info = $info; if ($shareManager) { diff --git a/apps/dav/lib/Connector/Sabre/ObjectTree.php b/apps/dav/lib/Connector/Sabre/ObjectTree.php index 6cdd5708743..bfbdfb33db0 100644 --- a/apps/dav/lib/Connector/Sabre/ObjectTree.php +++ b/apps/dav/lib/Connector/Sabre/ObjectTree.php @@ -9,6 +9,7 @@ namespace OCA\DAV\Connector\Sabre; use OC\Files\FileInfo; use OC\Files\Storage\FailedStorage; +use OC\Files\Storage\Storage; use OC\Files\View; use OCA\DAV\Connector\Sabre\Exception\FileLocked; use OCA\DAV\Connector\Sabre\Exception\Forbidden; @@ -23,12 +24,12 @@ use OCP\Lock\LockedException; class ObjectTree extends CachingTree { /** - * @var \OC\Files\View + * @var View */ protected $fileView; /** - * @var \OCP\Files\Mount\IMountManager + * @var IMountManager */ protected $mountManager; @@ -40,8 +41,8 @@ class ObjectTree extends CachingTree { /** * @param \Sabre\DAV\INode $rootNode - * @param \OC\Files\View $view - * @param \OCP\Files\Mount\IMountManager $mountManager + * @param View $view + * @param IMountManager $mountManager */ public function init(\Sabre\DAV\INode $rootNode, View $view, IMountManager $mountManager) { $this->rootNode = $rootNode; @@ -91,7 +92,7 @@ class ObjectTree extends CachingTree { $internalPath = $mount->getInternalPath($absPath); if ($storage && $storage->file_exists($internalPath)) { /** - * @var \OC\Files\Storage\Storage $storage + * @var Storage $storage */ // get data directly $data = $storage->getMetaData($internalPath); diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php index 0151bc9cf69..515ef807a25 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -9,6 +9,7 @@ namespace OCA\DAV\Connector\Sabre; use OC\KnownUser\KnownUserService; use OCA\Circles\Api\v1\Circles; use OCA\Circles\Exceptions\CircleNotFoundException; +use OCA\Circles\Model\Circle; use OCA\DAV\CalDAV\Proxy\ProxyMapper; use OCA\DAV\Traits\PrincipalProxyTrait; use OCP\Accounts\IAccountManager; @@ -31,24 +32,6 @@ use Sabre\DAVACL\PrincipalBackend\BackendInterface; class Principal implements BackendInterface { - /** @var IUserManager */ - private $userManager; - - /** @var IGroupManager */ - private $groupManager; - - /** @var IAccountManager */ - private $accountManager; - - /** @var IShareManager */ - private $shareManager; - - /** @var IUserSession */ - private $userSession; - - /** @var IAppManager */ - private $appManager; - /** @var string */ private $principalPrefix; @@ -64,34 +47,23 @@ class Principal implements BackendInterface { /** @var KnownUserService */ private $knownUserService; - /** @var IConfig */ - private $config; - /** @var IFactory */ - private $languageFactory; - - public function __construct(IUserManager $userManager, - IGroupManager $groupManager, - IAccountManager $accountManager, - IShareManager $shareManager, - IUserSession $userSession, - IAppManager $appManager, + public function __construct( + private IUserManager $userManager, + private IGroupManager $groupManager, + private IAccountManager $accountManager, + private IShareManager $shareManager, + private IUserSession $userSession, + private IAppManager $appManager, ProxyMapper $proxyMapper, KnownUserService $knownUserService, - IConfig $config, - IFactory $languageFactory, - string $principalPrefix = 'principals/users/') { - $this->userManager = $userManager; - $this->groupManager = $groupManager; - $this->accountManager = $accountManager; - $this->shareManager = $shareManager; - $this->userSession = $userSession; - $this->appManager = $appManager; + private IConfig $config, + private IFactory $languageFactory, + string $principalPrefix = 'principals/users/', + ) { $this->principalPrefix = trim($principalPrefix, '/'); $this->hasGroups = $this->hasCircles = ($principalPrefix === 'principals/users/'); $this->proxyMapper = $proxyMapper; $this->knownUserService = $knownUserService; - $this->config = $config; - $this->languageFactory = $languageFactory; } use PrincipalProxyTrait { @@ -556,7 +528,7 @@ class Principal implements BackendInterface { * @param string $principal * @return array * @throws Exception - * @throws \OCP\AppFramework\QueryException + * @throws QueryException * @suppress PhanUndeclaredClassMethod */ public function getCircleMembership($principal):array { @@ -574,7 +546,7 @@ class Principal implements BackendInterface { $circles = Circles::joinedCircles($name, true); $circles = array_map(function ($circle) { - /** @var \OCA\Circles\Model\Circle $circle */ + /** @var Circle $circle */ return 'principals/circles/' . urlencode($circle->getSingleId()); }, $circles); diff --git a/apps/dav/lib/Connector/Sabre/PublicAuth.php b/apps/dav/lib/Connector/Sabre/PublicAuth.php index 977b3bf304e..ea59d9efc8f 100644 --- a/apps/dav/lib/Connector/Sabre/PublicAuth.php +++ b/apps/dav/lib/Connector/Sabre/PublicAuth.php @@ -37,23 +37,14 @@ class PublicAuth extends AbstractBasic { public const DAV_AUTHENTICATED = 'public_link_authenticated'; private ?IShare $share = null; - private IManager $shareManager; - private ISession $session; - private IRequest $request; - private IThrottler $throttler; - private LoggerInterface $logger; - - public function __construct(IRequest $request, - IManager $shareManager, - ISession $session, - IThrottler $throttler, - LoggerInterface $logger) { - $this->request = $request; - $this->shareManager = $shareManager; - $this->session = $session; - $this->throttler = $throttler; - $this->logger = $logger; + public function __construct( + private IRequest $request, + private IManager $shareManager, + private ISession $session, + private IThrottler $throttler, + private LoggerInterface $logger, + ) { // setup realm $defaults = new Defaults(); $this->realm = $defaults->getName(); diff --git a/apps/dav/lib/Connector/Sabre/QuotaPlugin.php b/apps/dav/lib/Connector/Sabre/QuotaPlugin.php index deaa4cf672b..9790fc99837 100644 --- a/apps/dav/lib/Connector/Sabre/QuotaPlugin.php +++ b/apps/dav/lib/Connector/Sabre/QuotaPlugin.php @@ -8,6 +8,7 @@ */ namespace OCA\DAV\Connector\Sabre; +use OC\Files\View; use OCA\DAV\Upload\FutureFile; use OCA\DAV\Upload\UploadFolder; use OCP\Files\StorageNotAvailableException; @@ -23,9 +24,6 @@ use Sabre\DAV\INode; * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ class QuotaPlugin extends \Sabre\DAV\ServerPlugin { - /** @var \OC\Files\View */ - private $view; - /** * Reference to main server object * @@ -34,10 +32,11 @@ class QuotaPlugin extends \Sabre\DAV\ServerPlugin { private $server; /** - * @param \OC\Files\View $view + * @param View $view */ - public function __construct($view) { - $this->view = $view; + public function __construct( + private $view, + ) { } /** diff --git a/apps/dav/lib/Connector/Sabre/RequestIdHeaderPlugin.php b/apps/dav/lib/Connector/Sabre/RequestIdHeaderPlugin.php index f856fca51e1..5484bab9237 100644 --- a/apps/dav/lib/Connector/Sabre/RequestIdHeaderPlugin.php +++ b/apps/dav/lib/Connector/Sabre/RequestIdHeaderPlugin.php @@ -13,11 +13,9 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; class RequestIdHeaderPlugin extends \Sabre\DAV\ServerPlugin { - /** @var IRequest */ - private $request; - - public function __construct(IRequest $request) { - $this->request = $request; + public function __construct( + private IRequest $request, + ) { } public function initialize(\Sabre\DAV\Server $server) { diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php index 967bd0a74b8..3aabb828d9c 100644 --- a/apps/dav/lib/Connector/Sabre/ServerFactory.php +++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php @@ -7,6 +7,7 @@ */ namespace OCA\DAV\Connector\Sabre; +use OC\Files\View; use OCA\DAV\AppInfo\PluginManager; use OCA\DAV\CalDAV\DefaultCalendarValidator; use OCA\DAV\DAV\CustomPropertiesBackend; @@ -96,7 +97,7 @@ class ServerFactory { // ensure the skeleton is copied $userFolder = \OC::$server->getUserFolder(); - /** @var \OC\Files\View $view */ + /** @var View $view */ $view = $viewCallBack($server); if ($userFolder instanceof Folder && $userFolder->getPath() === $view->getRoot()) { $rootInfo = $userFolder; diff --git a/apps/dav/lib/Connector/Sabre/ShareTypeList.php b/apps/dav/lib/Connector/Sabre/ShareTypeList.php index abe56cd0301..0b66ed27576 100644 --- a/apps/dav/lib/Connector/Sabre/ShareTypeList.php +++ b/apps/dav/lib/Connector/Sabre/ShareTypeList.php @@ -20,17 +20,14 @@ class ShareTypeList implements Element { public const NS_OWNCLOUD = 'http://owncloud.org/ns'; /** - * Share types - * - * @var int[] - */ - private $shareTypes; - - /** * @param int[] $shareTypes */ - public function __construct($shareTypes) { - $this->shareTypes = $shareTypes; + public function __construct( + /** + * Share types + */ + private $shareTypes, + ) { } /** diff --git a/apps/dav/lib/Connector/Sabre/ShareeList.php b/apps/dav/lib/Connector/Sabre/ShareeList.php index b8f9f98d1c7..909c29fc24b 100644 --- a/apps/dav/lib/Connector/Sabre/ShareeList.php +++ b/apps/dav/lib/Connector/Sabre/ShareeList.php @@ -18,11 +18,10 @@ use Sabre\Xml\XmlSerializable; class ShareeList implements XmlSerializable { public const NS_NEXTCLOUD = 'http://nextcloud.org/ns'; - /** @var IShare[] */ - private $shares; - - public function __construct(array $shares) { - $this->shares = $shares; + public function __construct( + /** @var IShare[] */ + private array $shares, + ) { } /** diff --git a/apps/dav/lib/Connector/Sabre/TagList.php b/apps/dav/lib/Connector/Sabre/TagList.php index 5537acc452c..9a5cd0d51cf 100644 --- a/apps/dav/lib/Connector/Sabre/TagList.php +++ b/apps/dav/lib/Connector/Sabre/TagList.php @@ -20,17 +20,14 @@ class TagList implements Element { public const NS_OWNCLOUD = 'http://owncloud.org/ns'; /** - * tags - * - * @var array - */ - private $tags; - - /** * @param array $tags */ - public function __construct(array $tags) { - $this->tags = $tags; + public function __construct( + /** + * tags + */ + private array $tags, + ) { } /** diff --git a/apps/dav/lib/Connector/Sabre/TagsPlugin.php b/apps/dav/lib/Connector/Sabre/TagsPlugin.php index c048b79484a..7f05d4d3c03 100644 --- a/apps/dav/lib/Connector/Sabre/TagsPlugin.php +++ b/apps/dav/lib/Connector/Sabre/TagsPlugin.php @@ -28,6 +28,7 @@ namespace OCA\DAV\Connector\Sabre; * */ use OCP\ITagManager; +use OCP\ITags; use Sabre\DAV\PropFind; use Sabre\DAV\PropPatch; @@ -47,12 +48,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin { private $server; /** - * @var \OCP\ITagManager - */ - private $tagManager; - - /** - * @var \OCP\ITags + * @var ITags */ private $tagger; @@ -65,17 +61,13 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin { private $cachedTags; /** - * @var \Sabre\DAV\Tree - */ - private $tree; - - /** * @param \Sabre\DAV\Tree $tree tree - * @param \OCP\ITagManager $tagManager tag manager + * @param ITagManager $tagManager tag manager */ - public function __construct(\Sabre\DAV\Tree $tree, ITagManager $tagManager) { - $this->tree = $tree; - $this->tagManager = $tagManager; + public function __construct( + private \Sabre\DAV\Tree $tree, + private ITagManager $tagManager, + ) { $this->tagger = null; $this->cachedTags = []; } @@ -103,7 +95,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin { /** * Returns the tagger * - * @return \OCP\ITags tagger + * @return ITags tagger */ private function getTagger() { if (!$this->tagger) { diff --git a/apps/dav/lib/Controller/BirthdayCalendarController.php b/apps/dav/lib/Controller/BirthdayCalendarController.php index 9e18b5111a8..d3a9239dd22 100644 --- a/apps/dav/lib/Controller/BirthdayCalendarController.php +++ b/apps/dav/lib/Controller/BirthdayCalendarController.php @@ -22,31 +22,6 @@ use OCP\IUserManager; class BirthdayCalendarController extends Controller { /** - * @var IDBConnection - */ - protected $db; - - /** - * @var IConfig - */ - protected $config; - - /** - * @var IUserManager - */ - protected $userManager; - - /** - * @var CalDavBackend - */ - protected $caldavBackend; - - /** - * @var IJobList - */ - protected $jobList; - - /** * BirthdayCalendar constructor. * * @param string $appName @@ -55,19 +30,18 @@ class BirthdayCalendarController extends Controller { * @param IConfig $config * @param IJobList $jobList * @param IUserManager $userManager - * @param CalDavBackend $calDavBackend + * @param CalDavBackend $caldavBackend */ - public function __construct($appName, IRequest $request, - IDBConnection $db, IConfig $config, - IJobList $jobList, - IUserManager $userManager, - CalDavBackend $calDavBackend) { + public function __construct( + $appName, + IRequest $request, + protected IDBConnection $db, + protected IConfig $config, + protected IJobList $jobList, + protected IUserManager $userManager, + protected CalDavBackend $caldavBackend, + ) { parent::__construct($appName, $request); - $this->db = $db; - $this->config = $config; - $this->userManager = $userManager; - $this->jobList = $jobList; - $this->caldavBackend = $calDavBackend; } /** diff --git a/apps/dav/lib/Controller/DirectController.php b/apps/dav/lib/Controller/DirectController.php index 80e00e93ca7..ea209168123 100644 --- a/apps/dav/lib/Controller/DirectController.php +++ b/apps/dav/lib/Controller/DirectController.php @@ -28,45 +28,18 @@ use OCP\Security\ISecureRandom; class DirectController extends OCSController { - /** @var IRootFolder */ - private $rootFolder; - - /** @var string */ - private $userId; - - /** @var DirectMapper */ - private $mapper; - - /** @var ISecureRandom */ - private $random; - - /** @var ITimeFactory */ - private $timeFactory; - - /** @var IURLGenerator */ - private $urlGenerator; - - /** @var IEventDispatcher */ - private $eventDispatcher; - - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - IRootFolder $rootFolder, - string $userId, - DirectMapper $mapper, - ISecureRandom $random, - ITimeFactory $timeFactory, - IURLGenerator $urlGenerator, - IEventDispatcher $eventDispatcher) { + private IRootFolder $rootFolder, + private string $userId, + private DirectMapper $mapper, + private ISecureRandom $random, + private ITimeFactory $timeFactory, + private IURLGenerator $urlGenerator, + private IEventDispatcher $eventDispatcher, + ) { parent::__construct($appName, $request); - - $this->rootFolder = $rootFolder; - $this->userId = $userId; - $this->mapper = $mapper; - $this->random = $random; - $this->timeFactory = $timeFactory; - $this->urlGenerator = $urlGenerator; - $this->eventDispatcher = $eventDispatcher; } /** diff --git a/apps/dav/lib/Controller/InvitationResponseController.php b/apps/dav/lib/Controller/InvitationResponseController.php index cf4e24e8f1c..19eb4097b45 100644 --- a/apps/dav/lib/Controller/InvitationResponseController.php +++ b/apps/dav/lib/Controller/InvitationResponseController.php @@ -23,15 +23,6 @@ use Sabre\VObject\Reader; #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)] class InvitationResponseController extends Controller { - /** @var IDBConnection */ - private $db; - - /** @var ITimeFactory */ - private $timeFactory; - - /** @var InvitationResponseServer */ - private $responseServer; - /** * InvitationResponseController constructor. * @@ -41,13 +32,14 @@ class InvitationResponseController extends Controller { * @param ITimeFactory $timeFactory * @param InvitationResponseServer $responseServer */ - public function __construct(string $appName, IRequest $request, - IDBConnection $db, ITimeFactory $timeFactory, - InvitationResponseServer $responseServer) { + public function __construct( + string $appName, + IRequest $request, + private IDBConnection $db, + private ITimeFactory $timeFactory, + private InvitationResponseServer $responseServer, + ) { parent::__construct($appName, $request); - $this->db = $db; - $this->timeFactory = $timeFactory; - $this->responseServer = $responseServer; // Don't run `$server->exec()`, because we just need access to the // fully initialized schedule plugin, but we don't want Sabre/DAV // to actually handle and reply to the request diff --git a/apps/dav/lib/Controller/UpcomingEventsController.php b/apps/dav/lib/Controller/UpcomingEventsController.php index 879fe05d613..c8eb39abb17 100644 --- a/apps/dav/lib/Controller/UpcomingEventsController.php +++ b/apps/dav/lib/Controller/UpcomingEventsController.php @@ -23,17 +23,12 @@ use OCP\IRequest; * @psalm-import-type DAVUpcomingEvent from ResponseDefinitions */ class UpcomingEventsController extends OCSController { - private ?string $userId; - private UpcomingEventsService $service; - public function __construct( IRequest $request, - ?string $userId, - UpcomingEventsService $service) { + private ?string $userId, + private UpcomingEventsService $service, + ) { parent::__construct(Application::APP_ID, $request); - - $this->userId = $userId; - $this->service = $service; } /** diff --git a/apps/dav/lib/DAV/CustomPropertiesBackend.php b/apps/dav/lib/DAV/CustomPropertiesBackend.php index dde97cabf37..f73246161ba 100644 --- a/apps/dav/lib/DAV/CustomPropertiesBackend.php +++ b/apps/dav/lib/DAV/CustomPropertiesBackend.php @@ -113,30 +113,12 @@ class CustomPropertiesBackend implements BackendInterface { ]; /** - * @var Tree - */ - private $tree; - - /** - * @var IDBConnection - */ - private $connection; - - /** - * @var IUser - */ - private $user; - - /** * Properties cache * * @var array */ private $userCache = []; - - private Server $server; private XmlService $xmlService; - private DefaultCalendarValidator $defaultCalendarValidator; /** * @param Tree $tree node tree @@ -144,22 +126,17 @@ class CustomPropertiesBackend implements BackendInterface { * @param IUser $user owner of the tree and properties */ public function __construct( - Server $server, - Tree $tree, - IDBConnection $connection, - IUser $user, - DefaultCalendarValidator $defaultCalendarValidator, + private Server $server, + private Tree $tree, + private IDBConnection $connection, + private IUser $user, + private DefaultCalendarValidator $defaultCalendarValidator, ) { - $this->server = $server; - $this->tree = $tree; - $this->connection = $connection; - $this->user = $user; $this->xmlService = new XmlService(); $this->xmlService->elementMap = array_merge( $this->xmlService->elementMap, self::COMPLEX_XML_ELEMENT_MAP, ); - $this->defaultCalendarValidator = $defaultCalendarValidator; } /** diff --git a/apps/dav/lib/DAV/GroupPrincipalBackend.php b/apps/dav/lib/DAV/GroupPrincipalBackend.php index 887f3b2d7e9..143fc7d69f1 100644 --- a/apps/dav/lib/DAV/GroupPrincipalBackend.php +++ b/apps/dav/lib/DAV/GroupPrincipalBackend.php @@ -20,32 +20,17 @@ use Sabre\DAVACL\PrincipalBackend\BackendInterface; class GroupPrincipalBackend implements BackendInterface { public const PRINCIPAL_PREFIX = 'principals/groups'; - /** @var IGroupManager */ - private $groupManager; - - /** @var IUserSession */ - private $userSession; - - /** @var IShareManager */ - private $shareManager; - /** @var IConfig */ - private $config; - /** - * @param IGroupManager $IGroupManager + * @param IGroupManager $groupManager * @param IUserSession $userSession * @param IShareManager $shareManager */ public function __construct( - IGroupManager $IGroupManager, - IUserSession $userSession, - IShareManager $shareManager, - IConfig $config, + private IGroupManager $groupManager, + private IUserSession $userSession, + private IShareManager $shareManager, + private IConfig $config, ) { - $this->groupManager = $IGroupManager; - $this->userSession = $userSession; - $this->shareManager = $shareManager; - $this->config = $config; } /** diff --git a/apps/dav/lib/DAV/Sharing/Plugin.php b/apps/dav/lib/DAV/Sharing/Plugin.php index c228d6993c2..cef8dc0b689 100644 --- a/apps/dav/lib/DAV/Sharing/Plugin.php +++ b/apps/dav/lib/DAV/Sharing/Plugin.php @@ -26,26 +26,18 @@ class Plugin extends ServerPlugin { public const NS_OWNCLOUD = 'http://owncloud.org/ns'; public const NS_NEXTCLOUD = 'http://nextcloud.com/ns'; - /** @var Auth */ - private $auth; - - /** @var IRequest */ - private $request; - - /** @var IConfig */ - private $config; - /** * Plugin constructor. * - * @param Auth $authBackEnd + * @param Auth $auth * @param IRequest $request * @param IConfig $config */ - public function __construct(Auth $authBackEnd, IRequest $request, IConfig $config) { - $this->auth = $authBackEnd; - $this->request = $request; - $this->config = $config; + public function __construct( + private Auth $auth, + private IRequest $request, + private IConfig $config, + ) { } /** diff --git a/apps/dav/lib/DAV/Sharing/Xml/Invite.php b/apps/dav/lib/DAV/Sharing/Xml/Invite.php index 91eda03f45b..7a20dbe6df7 100644 --- a/apps/dav/lib/DAV/Sharing/Xml/Invite.php +++ b/apps/dav/lib/DAV/Sharing/Xml/Invite.php @@ -27,21 +27,6 @@ use Sabre\Xml\XmlSerializable; class Invite implements XmlSerializable { /** - * The list of users a calendar has been shared to. - * - * @var array - */ - protected $users; - - /** - * The organizer contains information about the person who shared the - * object. - * - * @var array|null - */ - protected $organizer; - - /** * Creates the property. * * Users is an array. Each element of the array has the following @@ -67,9 +52,17 @@ class Invite implements XmlSerializable { * * @param array $users */ - public function __construct(array $users, ?array $organizer = null) { - $this->users = $users; - $this->organizer = $organizer; + public function __construct( + /** + * The list of users a calendar has been shared to. + */ + protected array $users, + /** + * The organizer contains information about the person who shared the + * object. + */ + protected ?array $organizer = null, + ) { } /** diff --git a/apps/dav/lib/DAV/Sharing/Xml/ShareRequest.php b/apps/dav/lib/DAV/Sharing/Xml/ShareRequest.php index aa3a880df6b..aefb39c5701 100644 --- a/apps/dav/lib/DAV/Sharing/Xml/ShareRequest.php +++ b/apps/dav/lib/DAV/Sharing/Xml/ShareRequest.php @@ -12,19 +12,16 @@ use Sabre\Xml\Reader; use Sabre\Xml\XmlDeserializable; class ShareRequest implements XmlDeserializable { - public $set = []; - - public $remove = []; - /** * Constructor * * @param array $set * @param array $remove */ - public function __construct(array $set, array $remove) { - $this->set = $set; - $this->remove = $remove; + public function __construct( + public array $set, + public array $remove, + ) { } public static function xmlDeserialize(Reader $reader) { diff --git a/apps/dav/lib/DAV/ViewOnlyPlugin.php b/apps/dav/lib/DAV/ViewOnlyPlugin.php index d8c8649b4b7..d53a74923fe 100644 --- a/apps/dav/lib/DAV/ViewOnlyPlugin.php +++ b/apps/dav/lib/DAV/ViewOnlyPlugin.php @@ -24,12 +24,10 @@ use Sabre\HTTP\RequestInterface; */ class ViewOnlyPlugin extends ServerPlugin { private ?Server $server = null; - private ?Folder $userFolder; public function __construct( - ?Folder $userFolder, + private ?Folder $userFolder, ) { - $this->userFolder = $userFolder; } /** diff --git a/apps/dav/lib/Direct/DirectFile.php b/apps/dav/lib/Direct/DirectFile.php index 3c684b83ef2..7f41dd65f41 100644 --- a/apps/dav/lib/Direct/DirectFile.php +++ b/apps/dav/lib/Direct/DirectFile.php @@ -18,21 +18,14 @@ use Sabre\DAV\Exception\NotFound; use Sabre\DAV\IFile; class DirectFile implements IFile { - /** @var Direct */ - private $direct; - - /** @var IRootFolder */ - private $rootFolder; - /** @var File */ private $file; - private $eventDispatcher; - - public function __construct(Direct $direct, IRootFolder $rootFolder, IEventDispatcher $eventDispatcher) { - $this->direct = $direct; - $this->rootFolder = $rootFolder; - $this->eventDispatcher = $eventDispatcher; + public function __construct( + private Direct $direct, + private IRootFolder $rootFolder, + private IEventDispatcher $eventDispatcher, + ) { } public function put($data) { diff --git a/apps/dav/lib/Direct/DirectHome.php b/apps/dav/lib/Direct/DirectHome.php index 66fe6f0f3d4..10e1017f5a4 100644 --- a/apps/dav/lib/Direct/DirectHome.php +++ b/apps/dav/lib/Direct/DirectHome.php @@ -22,38 +22,14 @@ use Sabre\DAV\ICollection; class DirectHome implements ICollection { - /** @var IRootFolder */ - private $rootFolder; - - /** @var DirectMapper */ - private $mapper; - - /** @var ITimeFactory */ - private $timeFactory; - - /** @var IThrottler */ - private $throttler; - - /** @var IRequest */ - private $request; - - /** @var IEventDispatcher */ - private $eventDispatcher; - public function __construct( - IRootFolder $rootFolder, - DirectMapper $mapper, - ITimeFactory $timeFactory, - IThrottler $throttler, - IRequest $request, - IEventDispatcher $eventDispatcher, + private IRootFolder $rootFolder, + private DirectMapper $mapper, + private ITimeFactory $timeFactory, + private IThrottler $throttler, + private IRequest $request, + private IEventDispatcher $eventDispatcher, ) { - $this->rootFolder = $rootFolder; - $this->mapper = $mapper; - $this->timeFactory = $timeFactory; - $this->throttler = $throttler; - $this->request = $request; - $this->eventDispatcher = $eventDispatcher; } public function createFile($name, $data = null) { diff --git a/apps/dav/lib/Direct/ServerFactory.php b/apps/dav/lib/Direct/ServerFactory.php index e64dc3a3266..473439361c2 100644 --- a/apps/dav/lib/Direct/ServerFactory.php +++ b/apps/dav/lib/Direct/ServerFactory.php @@ -20,17 +20,15 @@ use OCP\L10N\IFactory; use OCP\Security\Bruteforce\IThrottler; class ServerFactory { - /** @var IConfig */ - private $config; /** @var IL10N */ private $l10n; - /** @var IEventDispatcher */ - private $eventDispatcher; - public function __construct(IConfig $config, IFactory $l10nFactory, IEventDispatcher $eventDispatcher) { - $this->config = $config; + public function __construct( + private IConfig $config, + IFactory $l10nFactory, + private IEventDispatcher $eventDispatcher, + ) { $this->l10n = $l10nFactory->get('dav'); - $this->eventDispatcher = $eventDispatcher; } public function createServer(string $baseURI, diff --git a/apps/dav/lib/Events/AddressBookCreatedEvent.php b/apps/dav/lib/Events/AddressBookCreatedEvent.php index ec8e3cb6116..1a56bcbf63f 100644 --- a/apps/dav/lib/Events/AddressBookCreatedEvent.php +++ b/apps/dav/lib/Events/AddressBookCreatedEvent.php @@ -18,12 +18,6 @@ use OCP\EventDispatcher\Event; */ class AddressBookCreatedEvent extends Event { - /** @var int */ - private $addressBookId; - - /** @var array */ - private $addressBookData; - /** * AddressBookCreatedEvent constructor. * @@ -31,11 +25,11 @@ class AddressBookCreatedEvent extends Event { * @param array $addressBookData * @since 20.0.0 */ - public function __construct(int $addressBookId, - array $addressBookData) { + public function __construct( + private int $addressBookId, + private array $addressBookData, + ) { parent::__construct(); - $this->addressBookId = $addressBookId; - $this->addressBookData = $addressBookData; } /** diff --git a/apps/dav/lib/Events/AddressBookDeletedEvent.php b/apps/dav/lib/Events/AddressBookDeletedEvent.php index bc46106a47a..b1ec4125513 100644 --- a/apps/dav/lib/Events/AddressBookDeletedEvent.php +++ b/apps/dav/lib/Events/AddressBookDeletedEvent.php @@ -18,15 +18,6 @@ use OCP\EventDispatcher\Event; */ class AddressBookDeletedEvent extends Event { - /** @var int */ - private $addressBookId; - - /** @var array */ - private $addressBookData; - - /** @var array */ - private $shares; - /** * AddressBookDeletedEvent constructor. * @@ -35,13 +26,12 @@ class AddressBookDeletedEvent extends Event { * @param array $shares * @since 20.0.0 */ - public function __construct(int $addressBookId, - array $addressBookData, - array $shares) { + public function __construct( + private int $addressBookId, + private array $addressBookData, + private array $shares, + ) { parent::__construct(); - $this->addressBookId = $addressBookId; - $this->addressBookData = $addressBookData; - $this->shares = $shares; } /** diff --git a/apps/dav/lib/Events/AddressBookShareUpdatedEvent.php b/apps/dav/lib/Events/AddressBookShareUpdatedEvent.php index 14a63bee4a6..9a574fb548e 100644 --- a/apps/dav/lib/Events/AddressBookShareUpdatedEvent.php +++ b/apps/dav/lib/Events/AddressBookShareUpdatedEvent.php @@ -18,21 +18,6 @@ use OCP\EventDispatcher\Event; */ class AddressBookShareUpdatedEvent extends Event { - /** @var int */ - private $addressBookId; - - /** @var array */ - private $addressBookData; - - /** @var array */ - private $oldShares; - - /** @var array */ - private $added; - - /** @var array */ - private $removed; - /** * AddressBookShareUpdatedEvent constructor. * @@ -43,17 +28,14 @@ class AddressBookShareUpdatedEvent extends Event { * @param array $removed * @since 20.0.0 */ - public function __construct(int $addressBookId, - array $addressBookData, - array $oldShares, - array $added, - array $removed) { + public function __construct( + private int $addressBookId, + private array $addressBookData, + private array $oldShares, + private array $added, + private array $removed, + ) { parent::__construct(); - $this->addressBookId = $addressBookId; - $this->addressBookData = $addressBookData; - $this->oldShares = $oldShares; - $this->added = $added; - $this->removed = $removed; } /** diff --git a/apps/dav/lib/Events/AddressBookUpdatedEvent.php b/apps/dav/lib/Events/AddressBookUpdatedEvent.php index 48e2f101f7e..fe6dc024cd2 100644 --- a/apps/dav/lib/Events/AddressBookUpdatedEvent.php +++ b/apps/dav/lib/Events/AddressBookUpdatedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class AddressBookUpdatedEvent extends Event { - /** @var int */ - private $addressBookId; - - /** @var array */ - private $addressBookData; - - /** @var array */ - private $shares; - - /** @var array */ - private $mutations; - /** * AddressBookUpdatedEvent constructor. * @@ -39,15 +27,13 @@ class AddressBookUpdatedEvent extends Event { * @param array $mutations * @since 20.0.0 */ - public function __construct(int $addressBookId, - array $addressBookData, - array $shares, - array $mutations) { + public function __construct( + private int $addressBookId, + private array $addressBookData, + private array $shares, + private array $mutations, + ) { parent::__construct(); - $this->addressBookId = $addressBookId; - $this->addressBookData = $addressBookData; - $this->shares = $shares; - $this->mutations = $mutations; } /** diff --git a/apps/dav/lib/Events/BeforeFileDirectDownloadedEvent.php b/apps/dav/lib/Events/BeforeFileDirectDownloadedEvent.php index adaa7f1a81c..a79d730e8ff 100644 --- a/apps/dav/lib/Events/BeforeFileDirectDownloadedEvent.php +++ b/apps/dav/lib/Events/BeforeFileDirectDownloadedEvent.php @@ -15,11 +15,10 @@ use OCP\Files\File; * @since 22.0.0 */ class BeforeFileDirectDownloadedEvent extends Event { - private $file; - - public function __construct(File $file) { + public function __construct( + private File $file, + ) { parent::__construct(); - $this->file = $file; } /** diff --git a/apps/dav/lib/Events/CachedCalendarObjectCreatedEvent.php b/apps/dav/lib/Events/CachedCalendarObjectCreatedEvent.php index 536472de6fe..ea1c344ed27 100644 --- a/apps/dav/lib/Events/CachedCalendarObjectCreatedEvent.php +++ b/apps/dav/lib/Events/CachedCalendarObjectCreatedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class CachedCalendarObjectCreatedEvent extends Event { - /** @var int */ - private $subscriptionId; - - /** @var array */ - private $subscriptionData; - - /** @var array */ - private $shares; - - /** @var array */ - private $objectData; - /** * CachedCalendarObjectCreatedEvent constructor. * @@ -39,15 +27,13 @@ class CachedCalendarObjectCreatedEvent extends Event { * @param array $objectData * @since 20.0.0 */ - public function __construct(int $subscriptionId, - array $subscriptionData, - array $shares, - array $objectData) { + public function __construct( + private int $subscriptionId, + private array $subscriptionData, + private array $shares, + private array $objectData, + ) { parent::__construct(); - $this->subscriptionId = $subscriptionId; - $this->subscriptionData = $subscriptionData; - $this->shares = $shares; - $this->objectData = $objectData; } /** diff --git a/apps/dav/lib/Events/CachedCalendarObjectDeletedEvent.php b/apps/dav/lib/Events/CachedCalendarObjectDeletedEvent.php index c3d98fd94d9..8f8e55d32e5 100644 --- a/apps/dav/lib/Events/CachedCalendarObjectDeletedEvent.php +++ b/apps/dav/lib/Events/CachedCalendarObjectDeletedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class CachedCalendarObjectDeletedEvent extends Event { - /** @var int */ - private $subscriptionId; - - /** @var array */ - private $subscriptionData; - - /** @var array */ - private $shares; - - /** @var array */ - private $objectData; - /** * CachedCalendarObjectDeletedEvent constructor. * @@ -39,15 +27,13 @@ class CachedCalendarObjectDeletedEvent extends Event { * @param array $objectData * @since 20.0.0 */ - public function __construct(int $subscriptionId, - array $subscriptionData, - array $shares, - array $objectData) { + public function __construct( + private int $subscriptionId, + private array $subscriptionData, + private array $shares, + private array $objectData, + ) { parent::__construct(); - $this->subscriptionId = $subscriptionId; - $this->subscriptionData = $subscriptionData; - $this->shares = $shares; - $this->objectData = $objectData; } /** diff --git a/apps/dav/lib/Events/CachedCalendarObjectUpdatedEvent.php b/apps/dav/lib/Events/CachedCalendarObjectUpdatedEvent.php index 12c712a2aa7..0adb4164dc9 100644 --- a/apps/dav/lib/Events/CachedCalendarObjectUpdatedEvent.php +++ b/apps/dav/lib/Events/CachedCalendarObjectUpdatedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class CachedCalendarObjectUpdatedEvent extends Event { - /** @var int */ - private $subscriptionId; - - /** @var array */ - private $subscriptionData; - - /** @var array */ - private $shares; - - /** @var array */ - private $objectData; - /** * CachedCalendarObjectUpdatedEvent constructor. * @@ -39,15 +27,13 @@ class CachedCalendarObjectUpdatedEvent extends Event { * @param array $objectData * @since 20.0.0 */ - public function __construct(int $subscriptionId, - array $subscriptionData, - array $shares, - array $objectData) { + public function __construct( + private int $subscriptionId, + private array $subscriptionData, + private array $shares, + private array $objectData, + ) { parent::__construct(); - $this->subscriptionId = $subscriptionId; - $this->subscriptionData = $subscriptionData; - $this->shares = $shares; - $this->objectData = $objectData; } /** diff --git a/apps/dav/lib/Events/CalendarCreatedEvent.php b/apps/dav/lib/Events/CalendarCreatedEvent.php index abefda54358..46d1194914e 100644 --- a/apps/dav/lib/Events/CalendarCreatedEvent.php +++ b/apps/dav/lib/Events/CalendarCreatedEvent.php @@ -18,12 +18,6 @@ use OCP\EventDispatcher\Event; */ class CalendarCreatedEvent extends Event { - /** @var int */ - private $calendarId; - - /** @var array */ - private $calendarData; - /** * CalendarCreatedEvent constructor. * @@ -31,11 +25,11 @@ class CalendarCreatedEvent extends Event { * @param array $calendarData * @since 20.0.0 */ - public function __construct(int $calendarId, - array $calendarData) { + public function __construct( + private int $calendarId, + private array $calendarData, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; } /** diff --git a/apps/dav/lib/Events/CalendarDeletedEvent.php b/apps/dav/lib/Events/CalendarDeletedEvent.php index 326af0702ad..c8ab4265b27 100644 --- a/apps/dav/lib/Events/CalendarDeletedEvent.php +++ b/apps/dav/lib/Events/CalendarDeletedEvent.php @@ -18,15 +18,6 @@ use OCP\EventDispatcher\Event; */ class CalendarDeletedEvent extends Event { - /** @var int */ - private $calendarId; - - /** @var array */ - private $calendarData; - - /** @var array */ - private $shares; - /** * CalendarDeletedEvent constructor. * @@ -35,13 +26,12 @@ class CalendarDeletedEvent extends Event { * @param array $shares * @since 20.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - array $shares) { + public function __construct( + private int $calendarId, + private array $calendarData, + private array $shares, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->shares = $shares; } /** diff --git a/apps/dav/lib/Events/CalendarMovedToTrashEvent.php b/apps/dav/lib/Events/CalendarMovedToTrashEvent.php index b2eb8e1f018..8bb660a98c6 100644 --- a/apps/dav/lib/Events/CalendarMovedToTrashEvent.php +++ b/apps/dav/lib/Events/CalendarMovedToTrashEvent.php @@ -15,28 +15,18 @@ use OCP\EventDispatcher\Event; */ class CalendarMovedToTrashEvent extends Event { - /** @var int */ - private $calendarId; - - /** @var array */ - private $calendarData; - - /** @var array */ - private $shares; - /** * @param int $calendarId * @param array $calendarData * @param array $shares * @since 22.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - array $shares) { + public function __construct( + private int $calendarId, + private array $calendarData, + private array $shares, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->shares = $shares; } /** diff --git a/apps/dav/lib/Events/CalendarObjectCreatedEvent.php b/apps/dav/lib/Events/CalendarObjectCreatedEvent.php index 5531f9954e7..187ded2dcd4 100644 --- a/apps/dav/lib/Events/CalendarObjectCreatedEvent.php +++ b/apps/dav/lib/Events/CalendarObjectCreatedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class CalendarObjectCreatedEvent extends Event { - /** @var int */ - private $calendarId; - - /** @var array */ - private $calendarData; - - /** @var array */ - private $shares; - - /** @var array */ - private $objectData; - /** * CalendarObjectCreatedEvent constructor. * @@ -39,15 +27,13 @@ class CalendarObjectCreatedEvent extends Event { * @param array $objectData * @since 20.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - array $shares, - array $objectData) { + public function __construct( + private int $calendarId, + private array $calendarData, + private array $shares, + private array $objectData, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->shares = $shares; - $this->objectData = $objectData; } /** diff --git a/apps/dav/lib/Events/CalendarObjectDeletedEvent.php b/apps/dav/lib/Events/CalendarObjectDeletedEvent.php index f3a1441fbc2..9928080f99b 100644 --- a/apps/dav/lib/Events/CalendarObjectDeletedEvent.php +++ b/apps/dav/lib/Events/CalendarObjectDeletedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class CalendarObjectDeletedEvent extends Event { - /** @var int */ - private $calendarId; - - /** @var array */ - private $calendarData; - - /** @var array */ - private $shares; - - /** @var array */ - private $objectData; - /** * CalendarObjectDeletedEvent constructor. * @@ -39,15 +27,13 @@ class CalendarObjectDeletedEvent extends Event { * @param array $objectData * @since 20.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - array $shares, - array $objectData) { + public function __construct( + private int $calendarId, + private array $calendarData, + private array $shares, + private array $objectData, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->shares = $shares; - $this->objectData = $objectData; } /** diff --git a/apps/dav/lib/Events/CalendarObjectMovedEvent.php b/apps/dav/lib/Events/CalendarObjectMovedEvent.php index b3adfae20bd..0b57919ddc9 100644 --- a/apps/dav/lib/Events/CalendarObjectMovedEvent.php +++ b/apps/dav/lib/Events/CalendarObjectMovedEvent.php @@ -17,32 +17,19 @@ use OCP\EventDispatcher\Event; * @since 25.0.0 */ class CalendarObjectMovedEvent extends Event { - private int $sourceCalendarId; - private array $sourceCalendarData; - private int $targetCalendarId; - private array $targetCalendarData; - private array $sourceShares; - private array $targetShares; - private array $objectData; - /** * @since 25.0.0 */ - public function __construct(int $sourceCalendarId, - array $sourceCalendarData, - int $targetCalendarId, - array $targetCalendarData, - array $sourceShares, - array $targetShares, - array $objectData) { + public function __construct( + private int $sourceCalendarId, + private array $sourceCalendarData, + private int $targetCalendarId, + private array $targetCalendarData, + private array $sourceShares, + private array $targetShares, + private array $objectData, + ) { parent::__construct(); - $this->sourceCalendarId = $sourceCalendarId; - $this->sourceCalendarData = $sourceCalendarData; - $this->targetCalendarId = $targetCalendarId; - $this->targetCalendarData = $targetCalendarData; - $this->sourceShares = $sourceShares; - $this->targetShares = $targetShares; - $this->objectData = $objectData; } /** diff --git a/apps/dav/lib/Events/CalendarObjectMovedToTrashEvent.php b/apps/dav/lib/Events/CalendarObjectMovedToTrashEvent.php index f2ccd2731bc..a26aca4ff2b 100644 --- a/apps/dav/lib/Events/CalendarObjectMovedToTrashEvent.php +++ b/apps/dav/lib/Events/CalendarObjectMovedToTrashEvent.php @@ -15,18 +15,6 @@ use OCP\EventDispatcher\Event; */ class CalendarObjectMovedToTrashEvent extends Event { - /** @var int */ - private $calendarId; - - /** @var array */ - private $calendarData; - - /** @var array */ - private $shares; - - /** @var array */ - private $objectData; - /** * @param int $calendarId * @param array $calendarData @@ -34,15 +22,13 @@ class CalendarObjectMovedToTrashEvent extends Event { * @param array $objectData * @since 22.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - array $shares, - array $objectData) { + public function __construct( + private int $calendarId, + private array $calendarData, + private array $shares, + private array $objectData, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->shares = $shares; - $this->objectData = $objectData; } /** diff --git a/apps/dav/lib/Events/CalendarObjectRestoredEvent.php b/apps/dav/lib/Events/CalendarObjectRestoredEvent.php index bfd64be72b5..99d752de466 100644 --- a/apps/dav/lib/Events/CalendarObjectRestoredEvent.php +++ b/apps/dav/lib/Events/CalendarObjectRestoredEvent.php @@ -15,18 +15,6 @@ use OCP\EventDispatcher\Event; */ class CalendarObjectRestoredEvent extends Event { - /** @var int */ - private $calendarId; - - /** @var array */ - private $calendarData; - - /** @var array */ - private $shares; - - /** @var array */ - private $objectData; - /** * @param int $calendarId * @param array $calendarData @@ -34,15 +22,13 @@ class CalendarObjectRestoredEvent extends Event { * @param array $objectData * @since 22.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - array $shares, - array $objectData) { + public function __construct( + private int $calendarId, + private array $calendarData, + private array $shares, + private array $objectData, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->shares = $shares; - $this->objectData = $objectData; } /** diff --git a/apps/dav/lib/Events/CalendarObjectUpdatedEvent.php b/apps/dav/lib/Events/CalendarObjectUpdatedEvent.php index 2f15ce6b3f2..8c4b843609d 100644 --- a/apps/dav/lib/Events/CalendarObjectUpdatedEvent.php +++ b/apps/dav/lib/Events/CalendarObjectUpdatedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class CalendarObjectUpdatedEvent extends Event { - /** @var int */ - private $calendarId; - - /** @var array */ - private $calendarData; - - /** @var array */ - private $shares; - - /** @var array */ - private $objectData; - /** * CalendarObjectUpdatedEvent constructor. * @@ -39,15 +27,13 @@ class CalendarObjectUpdatedEvent extends Event { * @param array $objectData * @since 20.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - array $shares, - array $objectData) { + public function __construct( + private int $calendarId, + private array $calendarData, + private array $shares, + private array $objectData, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->shares = $shares; - $this->objectData = $objectData; } /** diff --git a/apps/dav/lib/Events/CalendarPublishedEvent.php b/apps/dav/lib/Events/CalendarPublishedEvent.php index 922781e3cb7..32fb1c36963 100644 --- a/apps/dav/lib/Events/CalendarPublishedEvent.php +++ b/apps/dav/lib/Events/CalendarPublishedEvent.php @@ -17,10 +17,6 @@ use OCP\EventDispatcher\Event; * @since 20.0.0 */ class CalendarPublishedEvent extends Event { - private int $calendarId; - private array $calendarData; - private string $publicUri; - /** * CalendarPublishedEvent constructor. * @@ -29,13 +25,12 @@ class CalendarPublishedEvent extends Event { * @param string $publicUri * @since 20.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - string $publicUri) { + public function __construct( + private int $calendarId, + private array $calendarData, + private string $publicUri, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->publicUri = $publicUri; } /** diff --git a/apps/dav/lib/Events/CalendarRestoredEvent.php b/apps/dav/lib/Events/CalendarRestoredEvent.php index 5ea754ef200..f404771dea2 100644 --- a/apps/dav/lib/Events/CalendarRestoredEvent.php +++ b/apps/dav/lib/Events/CalendarRestoredEvent.php @@ -15,28 +15,18 @@ use OCP\EventDispatcher\Event; */ class CalendarRestoredEvent extends Event { - /** @var int */ - private $calendarId; - - /** @var array */ - private $calendarData; - - /** @var array */ - private $shares; - /** * @param int $calendarId * @param array $calendarData * @param array $shares * @since 22.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - array $shares) { + public function __construct( + private int $calendarId, + private array $calendarData, + private array $shares, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->shares = $shares; } /** diff --git a/apps/dav/lib/Events/CalendarShareUpdatedEvent.php b/apps/dav/lib/Events/CalendarShareUpdatedEvent.php index cdd1bc86cc0..762307b202f 100644 --- a/apps/dav/lib/Events/CalendarShareUpdatedEvent.php +++ b/apps/dav/lib/Events/CalendarShareUpdatedEvent.php @@ -19,20 +19,6 @@ use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet; * @since 20.0.0 */ class CalendarShareUpdatedEvent extends Event { - private int $calendarId; - - /** @var array{id: int, uri: string, '{http://calendarserver.org/ns/}getctag': string, '{http://sabredav.org/ns}sync-token': int, '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set': SupportedCalendarComponentSet, '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp': ScheduleCalendarTransp, '{urn:ietf:params:xml:ns:caldav}calendar-timezone': ?string } */ - private array $calendarData; - - /** @var list<array{href: string, commonName: string, status: int, readOnly: bool, '{http://owncloud.org/ns}principal': string, '{http://owncloud.org/ns}group-share': bool}> */ - private array $oldShares; - - /** @var list<array{href: string, commonName: string, readOnly: bool}> */ - private array $added; - - /** @var list<string> */ - private array $removed; - /** * CalendarShareUpdatedEvent constructor. * @@ -43,17 +29,14 @@ class CalendarShareUpdatedEvent extends Event { * @param list<string> $removed * @since 20.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - array $oldShares, - array $added, - array $removed) { + public function __construct( + private int $calendarId, + private array $calendarData, + private array $oldShares, + private array $added, + private array $removed, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->oldShares = $oldShares; - $this->added = $added; - $this->removed = $removed; } /** diff --git a/apps/dav/lib/Events/CalendarUnpublishedEvent.php b/apps/dav/lib/Events/CalendarUnpublishedEvent.php index 5f10f1e2c62..10d1712686d 100644 --- a/apps/dav/lib/Events/CalendarUnpublishedEvent.php +++ b/apps/dav/lib/Events/CalendarUnpublishedEvent.php @@ -17,9 +17,6 @@ use OCP\EventDispatcher\Event; * @since 20.0.0 */ class CalendarUnpublishedEvent extends Event { - private int $calendarId; - private array $calendarData; - /** * CalendarUnpublishedEvent constructor. * @@ -27,11 +24,11 @@ class CalendarUnpublishedEvent extends Event { * @param array $calendarData * @since 20.0.0 */ - public function __construct(int $calendarId, - array $calendarData) { + public function __construct( + private int $calendarId, + private array $calendarData, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; } /** diff --git a/apps/dav/lib/Events/CalendarUpdatedEvent.php b/apps/dav/lib/Events/CalendarUpdatedEvent.php index 46964156b16..a603d3152f0 100644 --- a/apps/dav/lib/Events/CalendarUpdatedEvent.php +++ b/apps/dav/lib/Events/CalendarUpdatedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class CalendarUpdatedEvent extends Event { - /** @var int */ - private $calendarId; - - /** @var array */ - private $calendarData; - - /** @var array */ - private $shares; - - /** @var array */ - private $mutations; - /** * CalendarUpdatedEvent constructor. * @@ -39,15 +27,13 @@ class CalendarUpdatedEvent extends Event { * @param array $mutations * @since 20.0.0 */ - public function __construct(int $calendarId, - array $calendarData, - array $shares, - array $mutations) { + public function __construct( + private int $calendarId, + private array $calendarData, + private array $shares, + private array $mutations, + ) { parent::__construct(); - $this->calendarId = $calendarId; - $this->calendarData = $calendarData; - $this->shares = $shares; - $this->mutations = $mutations; } /** diff --git a/apps/dav/lib/Events/CardCreatedEvent.php b/apps/dav/lib/Events/CardCreatedEvent.php index 3036451862b..5a66d73e707 100644 --- a/apps/dav/lib/Events/CardCreatedEvent.php +++ b/apps/dav/lib/Events/CardCreatedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class CardCreatedEvent extends Event { - /** @var int */ - private $addressBookId; - - /** @var array */ - private $addressBookData; - - /** @var array */ - private $shares; - - /** @var array */ - private $cardData; - /** * CardCreatedEvent constructor. * @@ -39,15 +27,13 @@ class CardCreatedEvent extends Event { * @param array $cardData * @since 20.0.0 */ - public function __construct(int $addressBookId, - array $addressBookData, - array $shares, - array $cardData) { + public function __construct( + private int $addressBookId, + private array $addressBookData, + private array $shares, + private array $cardData, + ) { parent::__construct(); - $this->addressBookId = $addressBookId; - $this->addressBookData = $addressBookData; - $this->shares = $shares; - $this->cardData = $cardData; } /** diff --git a/apps/dav/lib/Events/CardDeletedEvent.php b/apps/dav/lib/Events/CardDeletedEvent.php index 8b2499f71e0..237ffa7d623 100644 --- a/apps/dav/lib/Events/CardDeletedEvent.php +++ b/apps/dav/lib/Events/CardDeletedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class CardDeletedEvent extends Event { - /** @var int */ - private $addressBookId; - - /** @var array */ - private $addressBookData; - - /** @var array */ - private $shares; - - /** @var array */ - private $cardData; - /** * CardDeletedEvent constructor. * @@ -39,15 +27,13 @@ class CardDeletedEvent extends Event { * @param array $cardData * @since 20.0.0 */ - public function __construct(int $addressBookId, - array $addressBookData, - array $shares, - array $cardData) { + public function __construct( + private int $addressBookId, + private array $addressBookData, + private array $shares, + private array $cardData, + ) { parent::__construct(); - $this->addressBookId = $addressBookId; - $this->addressBookData = $addressBookData; - $this->shares = $shares; - $this->cardData = $cardData; } /** diff --git a/apps/dav/lib/Events/CardMovedEvent.php b/apps/dav/lib/Events/CardMovedEvent.php index adeb513c5d9..be69a046537 100644 --- a/apps/dav/lib/Events/CardMovedEvent.php +++ b/apps/dav/lib/Events/CardMovedEvent.php @@ -17,32 +17,19 @@ use OCP\EventDispatcher\Event; * @since 27.0.0 */ class CardMovedEvent extends Event { - private int $sourceAddressBookId; - private array $sourceAddressBookData; - private int $targetAddressBookId; - private array $targetAddressBookData; - private array $sourceShares; - private array $targetShares; - private array $objectData; - /** * @since 27.0.0 */ - public function __construct(int $sourceAddressBookId, - array $sourceAddressBookData, - int $targetAddressBookId, - array $targetAddressBookData, - array $sourceShares, - array $targetShares, - array $objectData) { + public function __construct( + private int $sourceAddressBookId, + private array $sourceAddressBookData, + private int $targetAddressBookId, + private array $targetAddressBookData, + private array $sourceShares, + private array $targetShares, + private array $objectData, + ) { parent::__construct(); - $this->sourceAddressBookId = $sourceAddressBookId; - $this->sourceAddressBookData = $sourceAddressBookData; - $this->targetAddressBookId = $targetAddressBookId; - $this->targetAddressBookData = $targetAddressBookData; - $this->sourceShares = $sourceShares; - $this->targetShares = $targetShares; - $this->objectData = $objectData; } /** diff --git a/apps/dav/lib/Events/CardUpdatedEvent.php b/apps/dav/lib/Events/CardUpdatedEvent.php index 3d97b5adf2e..10fc5b74594 100644 --- a/apps/dav/lib/Events/CardUpdatedEvent.php +++ b/apps/dav/lib/Events/CardUpdatedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class CardUpdatedEvent extends Event { - /** @var int */ - private $addressBookId; - - /** @var array */ - private $addressBookData; - - /** @var array */ - private $shares; - - /** @var array */ - private $cardData; - /** * CardUpdatedEvent constructor. * @@ -39,15 +27,13 @@ class CardUpdatedEvent extends Event { * @param array $cardData * @since 20.0.0 */ - public function __construct(int $addressBookId, - array $addressBookData, - array $shares, - array $cardData) { + public function __construct( + private int $addressBookId, + private array $addressBookData, + private array $shares, + private array $cardData, + ) { parent::__construct(); - $this->addressBookId = $addressBookId; - $this->addressBookData = $addressBookData; - $this->shares = $shares; - $this->cardData = $cardData; } /** diff --git a/apps/dav/lib/Events/SabrePluginAddEvent.php b/apps/dav/lib/Events/SabrePluginAddEvent.php index 42ba7263e90..866fae2e224 100644 --- a/apps/dav/lib/Events/SabrePluginAddEvent.php +++ b/apps/dav/lib/Events/SabrePluginAddEvent.php @@ -19,15 +19,13 @@ use Sabre\DAV\Server; */ class SabrePluginAddEvent extends Event { - /** @var Server */ - private $server; - /** * @since 28.0.0 */ - public function __construct(Server $server) { + public function __construct( + private Server $server, + ) { parent::__construct(); - $this->server = $server; } /** diff --git a/apps/dav/lib/Events/SabrePluginAuthInitEvent.php b/apps/dav/lib/Events/SabrePluginAuthInitEvent.php index 1709756368d..d3d93770c74 100644 --- a/apps/dav/lib/Events/SabrePluginAuthInitEvent.php +++ b/apps/dav/lib/Events/SabrePluginAuthInitEvent.php @@ -19,14 +19,12 @@ use Sabre\DAV\Server; */ class SabrePluginAuthInitEvent extends Event { - /** @var Server */ - private $server; - /** * @since 20.0.0 */ - public function __construct(Server $server) { - $this->server = $server; + public function __construct( + private Server $server, + ) { } /** diff --git a/apps/dav/lib/Events/SubscriptionCreatedEvent.php b/apps/dav/lib/Events/SubscriptionCreatedEvent.php index b96477582ad..433b6db59b0 100644 --- a/apps/dav/lib/Events/SubscriptionCreatedEvent.php +++ b/apps/dav/lib/Events/SubscriptionCreatedEvent.php @@ -18,12 +18,6 @@ use OCP\EventDispatcher\Event; */ class SubscriptionCreatedEvent extends Event { - /** @var int */ - private $subscriptionId; - - /** @var array */ - private $subscriptionData; - /** * SubscriptionCreatedEvent constructor. * @@ -31,11 +25,11 @@ class SubscriptionCreatedEvent extends Event { * @param array $subscriptionData * @since 20.0.0 */ - public function __construct(int $subscriptionId, - array $subscriptionData) { + public function __construct( + private int $subscriptionId, + private array $subscriptionData, + ) { parent::__construct(); - $this->subscriptionId = $subscriptionId; - $this->subscriptionData = $subscriptionData; } /** diff --git a/apps/dav/lib/Events/SubscriptionDeletedEvent.php b/apps/dav/lib/Events/SubscriptionDeletedEvent.php index a99a72b125d..58d47ae98a4 100644 --- a/apps/dav/lib/Events/SubscriptionDeletedEvent.php +++ b/apps/dav/lib/Events/SubscriptionDeletedEvent.php @@ -18,15 +18,6 @@ use OCP\EventDispatcher\Event; */ class SubscriptionDeletedEvent extends Event { - /** @var int */ - private $subscriptionId; - - /** @var array */ - private $subscriptionData; - - /** @var array */ - private $shares; - /** * SubscriptionDeletedEvent constructor. * @@ -35,13 +26,12 @@ class SubscriptionDeletedEvent extends Event { * @param array $shares * @since 20.0.0 */ - public function __construct(int $subscriptionId, - array $subscriptionData, - array $shares) { + public function __construct( + private int $subscriptionId, + private array $subscriptionData, + private array $shares, + ) { parent::__construct(); - $this->subscriptionId = $subscriptionId; - $this->subscriptionData = $subscriptionData; - $this->shares = $shares; } /** diff --git a/apps/dav/lib/Events/SubscriptionUpdatedEvent.php b/apps/dav/lib/Events/SubscriptionUpdatedEvent.php index 879b8ec1074..1a1b2804663 100644 --- a/apps/dav/lib/Events/SubscriptionUpdatedEvent.php +++ b/apps/dav/lib/Events/SubscriptionUpdatedEvent.php @@ -18,18 +18,6 @@ use OCP\EventDispatcher\Event; */ class SubscriptionUpdatedEvent extends Event { - /** @var int */ - private $subscriptionId; - - /** @var array */ - private $subscriptionData; - - /** @var array */ - private $shares; - - /** @var array */ - private $mutations; - /** * SubscriptionUpdatedEvent constructor. * @@ -39,15 +27,13 @@ class SubscriptionUpdatedEvent extends Event { * @param array $mutations * @since 20.0.0 */ - public function __construct(int $subscriptionId, - array $subscriptionData, - array $shares, - array $mutations) { + public function __construct( + private int $subscriptionId, + private array $subscriptionData, + private array $shares, + private array $mutations, + ) { parent::__construct(); - $this->subscriptionId = $subscriptionId; - $this->subscriptionData = $subscriptionData; - $this->shares = $shares; - $this->mutations = $mutations; } /** diff --git a/apps/dav/lib/Files/FilesHome.php b/apps/dav/lib/Files/FilesHome.php index b865b7c1bb6..f8aa82cdcc9 100644 --- a/apps/dav/lib/Files/FilesHome.php +++ b/apps/dav/lib/Files/FilesHome.php @@ -15,18 +15,15 @@ use Sabre\DAV\Exception\Forbidden; class FilesHome extends Directory { /** - * @var array - */ - private $principalInfo; - - /** * FilesHome constructor. * * @param array $principalInfo * @param FileInfo $userFolder */ - public function __construct($principalInfo, FileInfo $userFolder) { - $this->principalInfo = $principalInfo; + public function __construct( + private $principalInfo, + FileInfo $userFolder, + ) { $view = Filesystem::getView(); parent::__construct($view, $userFolder); } diff --git a/apps/dav/lib/HookManager.php b/apps/dav/lib/HookManager.php index f717752038a..9f4bc95d89b 100644 --- a/apps/dav/lib/HookManager.php +++ b/apps/dav/lib/HookManager.php @@ -18,21 +18,9 @@ use Psr\Log\LoggerInterface; class HookManager { - /** @var IUserManager */ - private $userManager; - - /** @var SyncService */ - private $syncService; - /** @var IUser[] */ private $usersToDelete = []; - /** @var CalDavBackend */ - private $calDav; - - /** @var CardDavBackend */ - private $cardDav; - /** @var array */ private $calendarsToDelete = []; @@ -42,19 +30,13 @@ class HookManager { /** @var array */ private $addressBooksToDelete = []; - /** @var Defaults */ - private $themingDefaults; - - public function __construct(IUserManager $userManager, - SyncService $syncService, - CalDavBackend $calDav, - CardDavBackend $cardDav, - Defaults $themingDefaults) { - $this->userManager = $userManager; - $this->syncService = $syncService; - $this->calDav = $calDav; - $this->cardDav = $cardDav; - $this->themingDefaults = $themingDefaults; + public function __construct( + private IUserManager $userManager, + private SyncService $syncService, + private CalDavBackend $calDav, + private CardDavBackend $cardDav, + private Defaults $themingDefaults, + ) { } public function setup() { diff --git a/apps/dav/lib/Listener/ActivityUpdaterListener.php b/apps/dav/lib/Listener/ActivityUpdaterListener.php index 61dda3e8e47..700bc2f306c 100644 --- a/apps/dav/lib/Listener/ActivityUpdaterListener.php +++ b/apps/dav/lib/Listener/ActivityUpdaterListener.php @@ -30,16 +30,10 @@ use function sprintf; /** @template-implements IEventListener<CalendarCreatedEvent|CalendarUpdatedEvent|CalendarMovedToTrashEvent|CalendarRestoredEvent|CalendarDeletedEvent|CalendarObjectCreatedEvent|CalendarObjectUpdatedEvent|CalendarObjectMovedEvent|CalendarObjectMovedToTrashEvent|CalendarObjectRestoredEvent|CalendarObjectDeletedEvent> */ class ActivityUpdaterListener implements IEventListener { - /** @var ActivityBackend */ - private $activityBackend; - - /** @var LoggerInterface */ - private $logger; - - public function __construct(ActivityBackend $activityBackend, - LoggerInterface $logger) { - $this->activityBackend = $activityBackend; - $this->logger = $logger; + public function __construct( + private ActivityBackend $activityBackend, + private LoggerInterface $logger, + ) { } public function handle(Event $event): void { diff --git a/apps/dav/lib/Listener/AddressbookListener.php b/apps/dav/lib/Listener/AddressbookListener.php index 7c95cb1e0c7..4e38ce50dfd 100644 --- a/apps/dav/lib/Listener/AddressbookListener.php +++ b/apps/dav/lib/Listener/AddressbookListener.php @@ -21,16 +21,10 @@ use function sprintf; /** @template-implements IEventListener<AddressBookCreatedEvent|AddressBookUpdatedEvent|AddressBookDeletedEvent|AddressBookShareUpdatedEvent> */ class AddressbookListener implements IEventListener { - /** @var ActivityBackend */ - private $activityBackend; - - /** @var LoggerInterface */ - private $logger; - - public function __construct(ActivityBackend $activityBackend, - LoggerInterface $logger) { - $this->activityBackend = $activityBackend; - $this->logger = $logger; + public function __construct( + private ActivityBackend $activityBackend, + private LoggerInterface $logger, + ) { } public function handle(Event $event): void { diff --git a/apps/dav/lib/Listener/BirthdayListener.php b/apps/dav/lib/Listener/BirthdayListener.php index 61e47a8171b..3a464d668f9 100644 --- a/apps/dav/lib/Listener/BirthdayListener.php +++ b/apps/dav/lib/Listener/BirthdayListener.php @@ -17,10 +17,9 @@ use OCP\EventDispatcher\IEventListener; /** @template-implements IEventListener<CardCreatedEvent|CardUpdatedEvent|CardDeletedEvent> */ class BirthdayListener implements IEventListener { - private BirthdayService $birthdayService; - - public function __construct(BirthdayService $birthdayService) { - $this->birthdayService = $birthdayService; + public function __construct( + private BirthdayService $birthdayService, + ) { } public function handle(Event $event): void { diff --git a/apps/dav/lib/Listener/CalendarContactInteractionListener.php b/apps/dav/lib/Listener/CalendarContactInteractionListener.php index b4eab7b6544..8e574e150cd 100644 --- a/apps/dav/lib/Listener/CalendarContactInteractionListener.php +++ b/apps/dav/lib/Listener/CalendarContactInteractionListener.php @@ -32,31 +32,13 @@ use function substr; class CalendarContactInteractionListener implements IEventListener { private const URI_USERS = 'principals/users/'; - /** @var IEventDispatcher */ - private $dispatcher; - - /** @var IUserSession */ - private $userSession; - - /** @var Principal */ - private $principalConnector; - - /** @var IMailer */ - private $mailer; - - /** @var LoggerInterface */ - private $logger; - - public function __construct(IEventDispatcher $dispatcher, - IUserSession $userSession, - Principal $principalConnector, - IMailer $mailer, - LoggerInterface $logger) { - $this->dispatcher = $dispatcher; - $this->userSession = $userSession; - $this->principalConnector = $principalConnector; - $this->mailer = $mailer; - $this->logger = $logger; + public function __construct( + private IEventDispatcher $dispatcher, + private IUserSession $userSession, + private Principal $principalConnector, + private IMailer $mailer, + private LoggerInterface $logger, + ) { } public function handle(Event $event): void { diff --git a/apps/dav/lib/Listener/CalendarDeletionDefaultUpdaterListener.php b/apps/dav/lib/Listener/CalendarDeletionDefaultUpdaterListener.php index df8b190b993..0cfc435eb8c 100644 --- a/apps/dav/lib/Listener/CalendarDeletionDefaultUpdaterListener.php +++ b/apps/dav/lib/Listener/CalendarDeletionDefaultUpdaterListener.php @@ -20,16 +20,10 @@ use Throwable; */ class CalendarDeletionDefaultUpdaterListener implements IEventListener { - /** @var IConfig */ - private $config; - - /** @var LoggerInterface */ - private $logger; - - public function __construct(IConfig $config, - LoggerInterface $logger) { - $this->config = $config; - $this->logger = $logger; + public function __construct( + private IConfig $config, + private LoggerInterface $logger, + ) { } /** diff --git a/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php b/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php index 7b5026a9570..544c88af929 100644 --- a/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php +++ b/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php @@ -28,26 +28,12 @@ use function sprintf; /** @template-implements IEventListener<CalendarMovedToTrashEvent|CalendarDeletedEvent|CalendarRestoredEvent|CalendarObjectCreatedEvent|CalendarObjectUpdatedEvent|CalendarObjectMovedToTrashEvent|CalendarObjectRestoredEvent|CalendarObjectDeletedEvent> */ class CalendarObjectReminderUpdaterListener implements IEventListener { - /** @var ReminderBackend */ - private $reminderBackend; - - /** @var ReminderService */ - private $reminderService; - - /** @var CalDavBackend */ - private $calDavBackend; - - /** @var LoggerInterface */ - private $logger; - - public function __construct(ReminderBackend $reminderBackend, - ReminderService $reminderService, - CalDavBackend $calDavBackend, - LoggerInterface $logger) { - $this->reminderBackend = $reminderBackend; - $this->reminderService = $reminderService; - $this->calDavBackend = $calDavBackend; - $this->logger = $logger; + public function __construct( + private ReminderBackend $reminderBackend, + private ReminderService $reminderService, + private CalDavBackend $calDavBackend, + private LoggerInterface $logger, + ) { } public function handle(Event $event): void { diff --git a/apps/dav/lib/Listener/CalendarPublicationListener.php b/apps/dav/lib/Listener/CalendarPublicationListener.php index 2fd640d0c76..94a0a208d4e 100644 --- a/apps/dav/lib/Listener/CalendarPublicationListener.php +++ b/apps/dav/lib/Listener/CalendarPublicationListener.php @@ -17,13 +17,10 @@ use Psr\Log\LoggerInterface; /** @template-implements IEventListener<CalendarPublishedEvent|CalendarUnpublishedEvent> */ class CalendarPublicationListener implements IEventListener { - private Backend $activityBackend; - private LoggerInterface $logger; - - public function __construct(Backend $activityBackend, - LoggerInterface $logger) { - $this->activityBackend = $activityBackend; - $this->logger = $logger; + public function __construct( + private Backend $activityBackend, + private LoggerInterface $logger, + ) { } /** diff --git a/apps/dav/lib/Listener/CalendarShareUpdateListener.php b/apps/dav/lib/Listener/CalendarShareUpdateListener.php index 51a8968cac1..541b0d07736 100644 --- a/apps/dav/lib/Listener/CalendarShareUpdateListener.php +++ b/apps/dav/lib/Listener/CalendarShareUpdateListener.php @@ -16,13 +16,10 @@ use Psr\Log\LoggerInterface; /** @template-implements IEventListener<CalendarShareUpdatedEvent> */ class CalendarShareUpdateListener implements IEventListener { - private Backend $activityBackend; - private LoggerInterface $logger; - - public function __construct(Backend $activityBackend, - LoggerInterface $logger) { - $this->activityBackend = $activityBackend; - $this->logger = $logger; + public function __construct( + private Backend $activityBackend, + private LoggerInterface $logger, + ) { } /** diff --git a/apps/dav/lib/Listener/CardListener.php b/apps/dav/lib/Listener/CardListener.php index 346445c10a2..b9fd1a7f64b 100644 --- a/apps/dav/lib/Listener/CardListener.php +++ b/apps/dav/lib/Listener/CardListener.php @@ -21,16 +21,10 @@ use function sprintf; /** @template-implements IEventListener<CardCreatedEvent|CardUpdatedEvent|CardDeletedEvent> */ class CardListener implements IEventListener { - /** @var ActivityBackend */ - private $activityBackend; - - /** @var LoggerInterface */ - private $logger; - - public function __construct(ActivityBackend $activityBackend, - LoggerInterface $logger) { - $this->activityBackend = $activityBackend; - $this->logger = $logger; + public function __construct( + private ActivityBackend $activityBackend, + private LoggerInterface $logger, + ) { } public function handle(Event $event): void { diff --git a/apps/dav/lib/Listener/ClearPhotoCacheListener.php b/apps/dav/lib/Listener/ClearPhotoCacheListener.php index 70bf8e3fb35..eb599d33871 100644 --- a/apps/dav/lib/Listener/ClearPhotoCacheListener.php +++ b/apps/dav/lib/Listener/ClearPhotoCacheListener.php @@ -16,10 +16,9 @@ use OCP\EventDispatcher\IEventListener; /** @template-implements IEventListener<CardUpdatedEvent|CardDeletedEvent> */ class ClearPhotoCacheListener implements IEventListener { - private PhotoCache $photoCache; - - public function __construct(PhotoCache $photoCache) { - $this->photoCache = $photoCache; + public function __construct( + private PhotoCache $photoCache, + ) { } public function handle(Event $event): void { diff --git a/apps/dav/lib/Listener/SubscriptionListener.php b/apps/dav/lib/Listener/SubscriptionListener.php index 9c9904d1aa2..fc9dfcf122d 100644 --- a/apps/dav/lib/Listener/SubscriptionListener.php +++ b/apps/dav/lib/Listener/SubscriptionListener.php @@ -20,17 +20,12 @@ use Psr\Log\LoggerInterface; /** @template-implements IEventListener<SubscriptionCreatedEvent|SubscriptionDeletedEvent> */ class SubscriptionListener implements IEventListener { - private IJobList $jobList; - private RefreshWebcalService $refreshWebcalService; - private ReminderBackend $reminderBackend; - private LoggerInterface $logger; - - public function __construct(IJobList $jobList, RefreshWebcalService $refreshWebcalService, ReminderBackend $reminderBackend, - LoggerInterface $logger) { - $this->jobList = $jobList; - $this->refreshWebcalService = $refreshWebcalService; - $this->reminderBackend = $reminderBackend; - $this->logger = $logger; + public function __construct( + private IJobList $jobList, + private RefreshWebcalService $refreshWebcalService, + private ReminderBackend $reminderBackend, + private LoggerInterface $logger, + ) { } /** diff --git a/apps/dav/lib/Listener/TrustedServerRemovedListener.php b/apps/dav/lib/Listener/TrustedServerRemovedListener.php index 36cb37b88ec..9adbcfc14c2 100644 --- a/apps/dav/lib/Listener/TrustedServerRemovedListener.php +++ b/apps/dav/lib/Listener/TrustedServerRemovedListener.php @@ -15,10 +15,9 @@ use OCP\Federation\Events\TrustedServerRemovedEvent; /** @template-implements IEventListener<TrustedServerRemovedEvent> */ class TrustedServerRemovedListener implements IEventListener { - private CardDavBackend $cardDavBackend; - - public function __construct(CardDavBackend $cardDavBackend) { - $this->cardDavBackend = $cardDavBackend; + public function __construct( + private CardDavBackend $cardDavBackend, + ) { } public function handle(Event $event): void { diff --git a/apps/dav/lib/Listener/UserPreferenceListener.php b/apps/dav/lib/Listener/UserPreferenceListener.php index 436a312ea88..5f5fed05348 100644 --- a/apps/dav/lib/Listener/UserPreferenceListener.php +++ b/apps/dav/lib/Listener/UserPreferenceListener.php @@ -17,10 +17,9 @@ use OCP\EventDispatcher\IEventListener; /** @template-implements IEventListener<BeforePreferenceSetEvent|BeforePreferenceDeletedEvent> */ class UserPreferenceListener implements IEventListener { - protected IJobList $jobList; - - public function __construct(IJobList $jobList) { - $this->jobList = $jobList; + public function __construct( + protected IJobList $jobList, + ) { } public function handle(Event $event): void { diff --git a/apps/dav/lib/Migration/BuildSocialSearchIndex.php b/apps/dav/lib/Migration/BuildSocialSearchIndex.php index 16100196e1b..5fab3f4ef77 100644 --- a/apps/dav/lib/Migration/BuildSocialSearchIndex.php +++ b/apps/dav/lib/Migration/BuildSocialSearchIndex.php @@ -13,26 +13,16 @@ use OCP\Migration\IRepairStep; class BuildSocialSearchIndex implements IRepairStep { - /** @var IDBConnection */ - private $db; - - /** @var IJobList */ - private $jobList; - - /** @var IConfig */ - private $config; - /** * @param IDBConnection $db * @param IJobList $jobList * @param IConfig $config */ - public function __construct(IDBConnection $db, - IJobList $jobList, - IConfig $config) { - $this->db = $db; - $this->jobList = $jobList; - $this->config = $config; + public function __construct( + private IDBConnection $db, + private IJobList $jobList, + private IConfig $config, + ) { } /** diff --git a/apps/dav/lib/Migration/ChunkCleanup.php b/apps/dav/lib/Migration/ChunkCleanup.php index 96e84984700..681b38404b9 100644 --- a/apps/dav/lib/Migration/ChunkCleanup.php +++ b/apps/dav/lib/Migration/ChunkCleanup.php @@ -21,23 +21,12 @@ use OCP\Migration\IRepairStep; class ChunkCleanup implements IRepairStep { - /** @var IConfig */ - private $config; - /** @var IUserManager */ - private $userManager; - /** @var IRootFolder */ - private $rootFolder; - /** @var IJobList */ - private $jobList; - - public function __construct(IConfig $config, - IUserManager $userManager, - IRootFolder $rootFolder, - IJobList $jobList) { - $this->config = $config; - $this->userManager = $userManager; - $this->rootFolder = $rootFolder; - $this->jobList = $jobList; + public function __construct( + private IConfig $config, + private IUserManager $userManager, + private IRootFolder $rootFolder, + private IJobList $jobList, + ) { } public function getName(): string { diff --git a/apps/dav/lib/Migration/RegenerateBirthdayCalendars.php b/apps/dav/lib/Migration/RegenerateBirthdayCalendars.php index 94ef7e8a13b..14037801eb4 100644 --- a/apps/dav/lib/Migration/RegenerateBirthdayCalendars.php +++ b/apps/dav/lib/Migration/RegenerateBirthdayCalendars.php @@ -13,20 +13,14 @@ use OCP\Migration\IRepairStep; class RegenerateBirthdayCalendars implements IRepairStep { - /** @var IJobList */ - private $jobList; - - /** @var IConfig */ - private $config; - /** * @param IJobList $jobList * @param IConfig $config */ - public function __construct(IJobList $jobList, - IConfig $config) { - $this->jobList = $jobList; - $this->config = $config; + public function __construct( + private IJobList $jobList, + private IConfig $config, + ) { } /** diff --git a/apps/dav/lib/Migration/RemoveDeletedUsersCalendarSubscriptions.php b/apps/dav/lib/Migration/RemoveDeletedUsersCalendarSubscriptions.php index 0122ed37b06..e2b2b701e74 100644 --- a/apps/dav/lib/Migration/RemoveDeletedUsersCalendarSubscriptions.php +++ b/apps/dav/lib/Migration/RemoveDeletedUsersCalendarSubscriptions.php @@ -15,12 +15,6 @@ use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; class RemoveDeletedUsersCalendarSubscriptions implements IRepairStep { - /** @var IDBConnection */ - private $connection; - - /** @var IUserManager */ - private $userManager; - /** @var int */ private $progress = 0; @@ -29,9 +23,10 @@ class RemoveDeletedUsersCalendarSubscriptions implements IRepairStep { private const SUBSCRIPTIONS_CHUNK_SIZE = 1000; - public function __construct(IDBConnection $connection, IUserManager $userManager) { - $this->connection = $connection; - $this->userManager = $userManager; + public function __construct( + private IDBConnection $connection, + private IUserManager $userManager, + ) { } /** diff --git a/apps/dav/lib/Migration/RemoveObjectProperties.php b/apps/dav/lib/Migration/RemoveObjectProperties.php index b87eb82af19..3f505ecb1e2 100644 --- a/apps/dav/lib/Migration/RemoveObjectProperties.php +++ b/apps/dav/lib/Migration/RemoveObjectProperties.php @@ -15,16 +15,14 @@ class RemoveObjectProperties implements IRepairStep { private const ME_CARD_PROPERTY = '{http://calendarserver.org/ns/}me-card'; private const CALENDAR_TRANSP_PROPERTY = '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp'; - /** @var IDBConnection */ - private $connection; - /** * RemoveObjectProperties constructor. * * @param IDBConnection $connection */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; + public function __construct( + private IDBConnection $connection, + ) { } /** diff --git a/apps/dav/lib/Migration/Version1008Date20181105104826.php b/apps/dav/lib/Migration/Version1008Date20181105104826.php index 6447372ee5f..82612307cbb 100644 --- a/apps/dav/lib/Migration/Version1008Date20181105104826.php +++ b/apps/dav/lib/Migration/Version1008Date20181105104826.php @@ -17,16 +17,14 @@ use OCP\Migration\SimpleMigrationStep; class Version1008Date20181105104826 extends SimpleMigrationStep { - /** @var IDBConnection */ - private $connection; - /** * Version1008Date20181105104826 constructor. * * @param IDBConnection $connection */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; + public function __construct( + private IDBConnection $connection, + ) { } /** diff --git a/apps/dav/lib/Migration/Version1008Date20181105110300.php b/apps/dav/lib/Migration/Version1008Date20181105110300.php index 37d0c12ce43..72e8dee1bf8 100644 --- a/apps/dav/lib/Migration/Version1008Date20181105110300.php +++ b/apps/dav/lib/Migration/Version1008Date20181105110300.php @@ -17,16 +17,14 @@ use OCP\Migration\SimpleMigrationStep; class Version1008Date20181105110300 extends SimpleMigrationStep { - /** @var IDBConnection */ - private $connection; - /** * Version1008Date20181105110300 constructor. * * @param IDBConnection $connection */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; + public function __construct( + private IDBConnection $connection, + ) { } /** diff --git a/apps/dav/lib/Migration/Version1025Date20240308063933.php b/apps/dav/lib/Migration/Version1025Date20240308063933.php index 3a68760762b..d84acf8fea9 100644 --- a/apps/dav/lib/Migration/Version1025Date20240308063933.php +++ b/apps/dav/lib/Migration/Version1025Date20240308063933.php @@ -20,13 +20,10 @@ use OCP\Migration\SimpleMigrationStep; class Version1025Date20240308063933 extends SimpleMigrationStep { - private IAppConfig $appConfig; - private IDBConnection $db; - - public function __construct(IAppConfig $appConfig, - IDBConnection $db) { - $this->db = $db; - $this->appConfig = $appConfig; + public function __construct( + private IAppConfig $appConfig, + private IDBConnection $db, + ) { } /** diff --git a/apps/dav/lib/Profiler/ProfilerPlugin.php b/apps/dav/lib/Profiler/ProfilerPlugin.php index 3bcf0b21446..455760fc2bf 100644 --- a/apps/dav/lib/Profiler/ProfilerPlugin.php +++ b/apps/dav/lib/Profiler/ProfilerPlugin.php @@ -14,10 +14,9 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; class ProfilerPlugin extends \Sabre\DAV\ServerPlugin { - private IRequest $request; - - public function __construct(IRequest $request) { - $this->request = $request; + public function __construct( + private IRequest $request, + ) { } /** @return void */ diff --git a/apps/dav/lib/Provisioning/Apple/AppleProvisioningNode.php b/apps/dav/lib/Provisioning/Apple/AppleProvisioningNode.php index f1313b89582..198a09b4bc8 100644 --- a/apps/dav/lib/Provisioning/Apple/AppleProvisioningNode.php +++ b/apps/dav/lib/Provisioning/Apple/AppleProvisioningNode.php @@ -14,13 +14,12 @@ use Sabre\DAV\PropPatch; class AppleProvisioningNode implements INode, IProperties { public const FILENAME = 'apple-provisioning.mobileconfig'; - protected $timeFactory; - /** * @param ITimeFactory $timeFactory */ - public function __construct(ITimeFactory $timeFactory) { - $this->timeFactory = $timeFactory; + public function __construct( + protected ITimeFactory $timeFactory, + ) { } /** diff --git a/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php b/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php index 1a02457d653..36b08cd940c 100644 --- a/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php +++ b/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php @@ -21,52 +21,22 @@ class AppleProvisioningPlugin extends ServerPlugin { protected $server; /** - * @var IURLGenerator - */ - protected $urlGenerator; - - /** - * @var IUserSession - */ - protected $userSession; - - /** * @var \OC_Defaults */ protected $themingDefaults; /** - * @var IRequest - */ - protected $request; - - /** - * @var IL10N - */ - protected $l10n; - - /** - * @var \Closure - */ - protected $uuidClosure; - - /** * AppleProvisioningPlugin constructor. */ public function __construct( - IUserSession $userSession, - IURLGenerator $urlGenerator, + protected IUserSession $userSession, + protected IURLGenerator $urlGenerator, \OC_Defaults $themingDefaults, - IRequest $request, - IL10N $l10n, - \Closure $uuidClosure, + protected IRequest $request, + protected IL10N $l10n, + protected \Closure $uuidClosure, ) { - $this->userSession = $userSession; - $this->urlGenerator = $urlGenerator; $this->themingDefaults = $themingDefaults; - $this->request = $request; - $this->l10n = $l10n; - $this->uuidClosure = $uuidClosure; } /** diff --git a/apps/dav/lib/Search/ACalendarSearchProvider.php b/apps/dav/lib/Search/ACalendarSearchProvider.php index 04e97f80cb1..331d05cb500 100644 --- a/apps/dav/lib/Search/ACalendarSearchProvider.php +++ b/apps/dav/lib/Search/ACalendarSearchProvider.php @@ -23,18 +23,6 @@ use Sabre\VObject\Reader; */ abstract class ACalendarSearchProvider implements IProvider { - /** @var IAppManager */ - protected $appManager; - - /** @var IL10N */ - protected $l10n; - - /** @var IURLGenerator */ - protected $urlGenerator; - - /** @var CalDavBackend */ - protected $backend; - /** * ACalendarSearchProvider constructor. * @@ -43,14 +31,12 @@ abstract class ACalendarSearchProvider implements IProvider { * @param IURLGenerator $urlGenerator * @param CalDavBackend $backend */ - public function __construct(IAppManager $appManager, - IL10N $l10n, - IURLGenerator $urlGenerator, - CalDavBackend $backend) { - $this->appManager = $appManager; - $this->l10n = $l10n; - $this->urlGenerator = $urlGenerator; - $this->backend = $backend; + public function __construct( + protected IAppManager $appManager, + protected IL10N $l10n, + protected IURLGenerator $urlGenerator, + protected CalDavBackend $backend, + ) { } /** diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php index 986f7465051..835a13a45b2 100644 --- a/apps/dav/lib/Server.php +++ b/apps/dav/lib/Server.php @@ -85,12 +85,13 @@ use Sabre\DAV\UUIDUtil; use SearchDAV\DAV\SearchPlugin; class Server { - private IRequest $request; - private string $baseUri; public Connector\Sabre\Server $server; private IProfiler $profiler; - public function __construct(IRequest $request, string $baseUri) { + public function __construct( + private IRequest $request, + private string $baseUri, + ) { $this->profiler = \OC::$server->get(IProfiler::class); if ($this->profiler->isEnabled()) { /** @var IEventLogger $eventLogger */ @@ -98,9 +99,6 @@ class Server { $eventLogger->start('runtime', 'DAV Runtime'); } - $this->request = $request; - $this->baseUri = $baseUri; - $logger = \OCP\Server::get(LoggerInterface::class); $eventDispatcher = \OCP\Server::get(IEventDispatcher::class); @@ -180,7 +178,7 @@ class Server { $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DefaultCalendarValidator::class))); $this->server->addPlugin(\OC::$server->get(\OCA\DAV\CalDAV\Trashbin\Plugin::class)); - $this->server->addPlugin(new \OCA\DAV\CalDAV\WebcalCaching\Plugin($request)); + $this->server->addPlugin(new \OCA\DAV\CalDAV\WebcalCaching\Plugin($this->request)); if (\OC::$server->getConfig()->getAppValue('dav', 'allow_calendar_link_subscriptions', 'yes') === 'yes') { $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); } @@ -237,7 +235,7 @@ class Server { // Some WebDAV clients do require Class 2 WebDAV support (locking), since // we do not provide locking we emulate it using a fake locking plugin. - if ($request->isUserAgent([ + if ($this->request->isUserAgent([ '/WebDAVFS/', '/OneNote/', '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 diff --git a/apps/dav/lib/Settings/AvailabilitySettings.php b/apps/dav/lib/Settings/AvailabilitySettings.php index 6afb03bda8d..a1ada96b255 100644 --- a/apps/dav/lib/Settings/AvailabilitySettings.php +++ b/apps/dav/lib/Settings/AvailabilitySettings.php @@ -20,21 +20,14 @@ use OCP\User\IAvailabilityCoordinator; use Psr\Log\LoggerInterface; class AvailabilitySettings implements ISettings { - protected IConfig $config; - protected IInitialState $initialState; - protected ?string $userId; - public function __construct( - IConfig $config, - IInitialState $initialState, - ?string $userId, + protected IConfig $config, + protected IInitialState $initialState, + protected ?string $userId, private LoggerInterface $logger, private IAvailabilityCoordinator $coordinator, private AbsenceMapper $absenceMapper, ) { - $this->config = $config; - $this->initialState = $initialState; - $this->userId = $userId; } public function getForm(): TemplateResponse { diff --git a/apps/dav/lib/Settings/CalDAVSettings.php b/apps/dav/lib/Settings/CalDAVSettings.php index 7c738a83148..5b6b7fa7e3d 100644 --- a/apps/dav/lib/Settings/CalDAVSettings.php +++ b/apps/dav/lib/Settings/CalDAVSettings.php @@ -15,15 +15,6 @@ use OCP\Settings\IDelegatedSettings; class CalDAVSettings implements IDelegatedSettings { - /** @var IConfig */ - private $config; - - /** @var IInitialState */ - private $initialState; - - private IURLGenerator $urlGenerator; - private IAppManager $appManager; - private const defaults = [ 'sendInvitations' => 'yes', 'generateBirthdayCalendar' => 'yes', @@ -38,11 +29,12 @@ class CalDAVSettings implements IDelegatedSettings { * @param IConfig $config * @param IInitialState $initialState */ - public function __construct(IConfig $config, IInitialState $initialState, IURLGenerator $urlGenerator, IAppManager $appManager) { - $this->config = $config; - $this->initialState = $initialState; - $this->urlGenerator = $urlGenerator; - $this->appManager = $appManager; + public function __construct( + private IConfig $config, + private IInitialState $initialState, + private IURLGenerator $urlGenerator, + private IAppManager $appManager, + ) { } public function getForm(): TemplateResponse { diff --git a/apps/dav/lib/SystemTag/SystemTagNode.php b/apps/dav/lib/SystemTag/SystemTagNode.php index 06eead814b2..9357f207779 100644 --- a/apps/dav/lib/SystemTag/SystemTagNode.php +++ b/apps/dav/lib/SystemTag/SystemTagNode.php @@ -23,30 +23,6 @@ use Sabre\DAV\Exception\NotFound; */ class SystemTagNode implements \Sabre\DAV\INode { - /** - * @var ISystemTag - */ - protected $tag; - - /** - * @var ISystemTagManager - */ - protected $tagManager; - - /** - * User - * - * @var IUser - */ - protected $user; - - /** - * Whether to allow permissions for admins - * - * @var bool - */ - protected $isAdmin; - protected int $numberOfFiles = -1; protected int $referenceFileId = -1; @@ -58,11 +34,18 @@ class SystemTagNode implements \Sabre\DAV\INode { * @param bool $isAdmin whether to allow operations for admins * @param ISystemTagManager $tagManager tag manager */ - public function __construct(ISystemTag $tag, IUser $user, $isAdmin, ISystemTagManager $tagManager) { - $this->tag = $tag; - $this->user = $user; - $this->isAdmin = $isAdmin; - $this->tagManager = $tagManager; + public function __construct( + protected ISystemTag $tag, + /** + * User + */ + protected IUser $user, + /** + * Whether to allow permissions for admins + */ + protected $isAdmin, + protected ISystemTagManager $tagManager, + ) { } /** diff --git a/apps/dav/lib/SystemTag/SystemTagPlugin.php b/apps/dav/lib/SystemTag/SystemTagPlugin.php index 6098a41ab3b..3c34f4263f6 100644 --- a/apps/dav/lib/SystemTag/SystemTagPlugin.php +++ b/apps/dav/lib/SystemTag/SystemTagPlugin.php @@ -52,38 +52,17 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin { */ private $server; - /** - * @var ISystemTagManager - */ - protected $tagManager; - - /** - * @var IUserSession - */ - protected $userSession; - - /** - * @var IGroupManager - */ - protected $groupManager; - /** @var array<int, string[]> */ private array $cachedTagMappings = []; /** @var array<string, ISystemTag> */ private array $cachedTags = []; - private ISystemTagObjectMapper $tagMapper; - public function __construct( - ISystemTagManager $tagManager, - IGroupManager $groupManager, - IUserSession $userSession, - ISystemTagObjectMapper $tagMapper, + protected ISystemTagManager $tagManager, + protected IGroupManager $groupManager, + protected IUserSession $userSession, + private ISystemTagObjectMapper $tagMapper, ) { - $this->tagManager = $tagManager; - $this->userSession = $userSession; - $this->groupManager = $groupManager; - $this->tagMapper = $tagMapper; } /** diff --git a/apps/dav/lib/SystemTag/SystemTagsByIdCollection.php b/apps/dav/lib/SystemTag/SystemTagsByIdCollection.php index 13e79c99b65..cf889985d1b 100644 --- a/apps/dav/lib/SystemTag/SystemTagsByIdCollection.php +++ b/apps/dav/lib/SystemTag/SystemTagsByIdCollection.php @@ -20,21 +20,6 @@ use Sabre\DAV\ICollection; class SystemTagsByIdCollection implements ICollection { /** - * @var ISystemTagManager - */ - private $tagManager; - - /** - * @var IGroupManager - */ - private $groupManager; - - /** - * @var IUserSession - */ - private $userSession; - - /** * SystemTagsByIdCollection constructor. * * @param ISystemTagManager $tagManager @@ -42,13 +27,10 @@ class SystemTagsByIdCollection implements ICollection { * @param IGroupManager $groupManager */ public function __construct( - ISystemTagManager $tagManager, - IUserSession $userSession, - IGroupManager $groupManager, + private ISystemTagManager $tagManager, + private IUserSession $userSession, + private IGroupManager $groupManager, ) { - $this->tagManager = $tagManager; - $this->userSession = $userSession; - $this->groupManager = $groupManager; } /** diff --git a/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php b/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php index 0431acc553a..6a3dd0c2155 100644 --- a/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php +++ b/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php @@ -21,24 +21,16 @@ use Sabre\DAV\Exception\NotFound; use Sabre\DAV\SimpleCollection; class SystemTagsInUseCollection extends SimpleCollection { - protected IUserSession $userSession; - protected IRootFolder $rootFolder; - protected string $mediaType; - protected ISystemTagManager $systemTagManager; protected SystemTagsInFilesDetector $systemTagsInFilesDetector; /** @noinspection PhpMissingParentConstructorInspection */ public function __construct( - IUserSession $userSession, - IRootFolder $rootFolder, - ISystemTagManager $systemTagManager, + protected IUserSession $userSession, + protected IRootFolder $rootFolder, + protected ISystemTagManager $systemTagManager, SystemTagsInFilesDetector $systemTagsInFilesDetector, - string $mediaType = '', + protected string $mediaType = '', ) { - $this->userSession = $userSession; - $this->rootFolder = $rootFolder; - $this->systemTagManager = $systemTagManager; - $this->mediaType = $mediaType; $this->systemTagsInFilesDetector = $systemTagsInFilesDetector; $this->name = 'systemtags-assigned'; if ($this->mediaType != '') { diff --git a/apps/dav/lib/Upload/CleanupService.php b/apps/dav/lib/Upload/CleanupService.php index 2b939941c55..36b75280504 100644 --- a/apps/dav/lib/Upload/CleanupService.php +++ b/apps/dav/lib/Upload/CleanupService.php @@ -13,14 +13,10 @@ use OCP\BackgroundJob\IJobList; use OCP\IUserSession; class CleanupService { - /** @var IUserSession */ - private $userSession; - /** @var IJobList */ - private $jobList; - - public function __construct(IUserSession $userSession, IJobList $jobList) { - $this->userSession = $userSession; - $this->jobList = $jobList; + public function __construct( + private IUserSession $userSession, + private IJobList $jobList, + ) { } public function addJob(string $folder) { diff --git a/apps/dav/lib/Upload/FutureFile.php b/apps/dav/lib/Upload/FutureFile.php index 5ef15bd2b56..ba37c56978d 100644 --- a/apps/dav/lib/Upload/FutureFile.php +++ b/apps/dav/lib/Upload/FutureFile.php @@ -20,18 +20,14 @@ use Sabre\DAV\IFile; * @package OCA\DAV\Upload */ class FutureFile implements \Sabre\DAV\IFile { - /** @var Directory */ - private $root; - /** @var string */ - private $name; - /** * @param Directory $root * @param string $name */ - public function __construct(Directory $root, $name) { - $this->root = $root; - $this->name = $name; + public function __construct( + private Directory $root, + private $name, + ) { } /** diff --git a/apps/dav/lib/Upload/PartFile.php b/apps/dav/lib/Upload/PartFile.php index a711fe083b9..11900997a90 100644 --- a/apps/dav/lib/Upload/PartFile.php +++ b/apps/dav/lib/Upload/PartFile.php @@ -16,14 +16,10 @@ use Sabre\DAV\IFile; * but handled directly by external storage services like S3 with Multipart Upload */ class PartFile implements IFile { - /** @var Directory */ - private $root; - /** @var array */ - private $partInfo; - - public function __construct(Directory $root, array $partInfo) { - $this->root = $root; - $this->partInfo = $partInfo; + public function __construct( + private Directory $root, + private array $partInfo, + ) { } /** diff --git a/apps/dav/lib/Upload/RootCollection.php b/apps/dav/lib/Upload/RootCollection.php index 1adab40671b..6b12363367a 100644 --- a/apps/dav/lib/Upload/RootCollection.php +++ b/apps/dav/lib/Upload/RootCollection.php @@ -14,14 +14,12 @@ use Sabre\DAVACL\PrincipalBackend; class RootCollection extends AbstractPrincipalCollection { - /** @var CleanupService */ - private $cleanupService; - - public function __construct(PrincipalBackend\BackendInterface $principalBackend, + public function __construct( + PrincipalBackend\BackendInterface $principalBackend, string $principalPrefix, - CleanupService $cleanupService) { + private CleanupService $cleanupService, + ) { parent::__construct($principalBackend, $principalPrefix); - $this->cleanupService = $cleanupService; } /** diff --git a/apps/dav/lib/Upload/UploadFile.php b/apps/dav/lib/Upload/UploadFile.php index 742eda78d08..7301e855cfe 100644 --- a/apps/dav/lib/Upload/UploadFile.php +++ b/apps/dav/lib/Upload/UploadFile.php @@ -12,11 +12,9 @@ use OCA\DAV\Connector\Sabre\File; use Sabre\DAV\IFile; class UploadFile implements IFile { - /** @var File */ - private $file; - - public function __construct(File $file) { - $this->file = $file; + public function __construct( + private File $file, + ) { } public function put($data) { diff --git a/apps/dav/lib/Upload/UploadFolder.php b/apps/dav/lib/Upload/UploadFolder.php index 3f84f7a8597..8ea0591ab16 100644 --- a/apps/dav/lib/Upload/UploadFolder.php +++ b/apps/dav/lib/Upload/UploadFolder.php @@ -15,17 +15,11 @@ use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\ICollection; class UploadFolder implements ICollection { - /** @var Directory */ - private $node; - /** @var CleanupService */ - private $cleanupService; - /** @var IStorage */ - private $storage; - - public function __construct(Directory $node, CleanupService $cleanupService, IStorage $storage) { - $this->node = $node; - $this->cleanupService = $cleanupService; - $this->storage = $storage; + public function __construct( + private Directory $node, + private CleanupService $cleanupService, + private IStorage $storage, + ) { } public function createFile($name, $data = null) { diff --git a/apps/dav/lib/Upload/UploadHome.php b/apps/dav/lib/Upload/UploadHome.php index 3e7e3c6c986..739c38feb30 100644 --- a/apps/dav/lib/Upload/UploadHome.php +++ b/apps/dav/lib/Upload/UploadHome.php @@ -14,14 +14,10 @@ use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\ICollection; class UploadHome implements ICollection { - /** @var array */ - private $principalInfo; - /** @var CleanupService */ - private $cleanupService; - - public function __construct(array $principalInfo, CleanupService $cleanupService) { - $this->principalInfo = $principalInfo; - $this->cleanupService = $cleanupService; + public function __construct( + private array $principalInfo, + private CleanupService $cleanupService, + ) { } public function createFile($name, $data = null) { diff --git a/apps/dav/lib/UserMigration/CalendarMigrator.php b/apps/dav/lib/UserMigration/CalendarMigrator.php index 7e5bdcd7890..73e9c375490 100644 --- a/apps/dav/lib/UserMigration/CalendarMigrator.php +++ b/apps/dav/lib/UserMigration/CalendarMigrator.php @@ -41,17 +41,6 @@ class CalendarMigrator implements IMigrator, ISizeEstimationMigrator { use TMigratorBasicVersionHandling; - private CalDavBackend $calDavBackend; - - private ICalendarManager $calendarManager; - - // ICSExportPlugin is injected as the mergeObjects() method is required and is not to be used as a SabreDAV server plugin - private ICSExportPlugin $icsExportPlugin; - - private Defaults $defaults; - - private IL10N $l10n; - private SabreDavServer $sabreDavServer; private const USERS_URI_ROOT = 'principals/users/'; @@ -63,18 +52,12 @@ class CalendarMigrator implements IMigrator, ISizeEstimationMigrator { private const EXPORT_ROOT = Application::APP_ID . '/calendars/'; public function __construct( - CalDavBackend $calDavBackend, - ICalendarManager $calendarManager, - ICSExportPlugin $icsExportPlugin, - Defaults $defaults, - IL10N $l10n, + private CalDavBackend $calDavBackend, + private ICalendarManager $calendarManager, + private ICSExportPlugin $icsExportPlugin, + private Defaults $defaults, + private IL10N $l10n, ) { - $this->calDavBackend = $calDavBackend; - $this->calendarManager = $calendarManager; - $this->icsExportPlugin = $icsExportPlugin; - $this->defaults = $defaults; - $this->l10n = $l10n; - $root = new RootCollection(); $this->sabreDavServer = new SabreDavServer(new CachingTree($root)); $this->sabreDavServer->addPlugin(new CalDAVPlugin()); diff --git a/apps/dav/lib/UserMigration/ContactsMigrator.php b/apps/dav/lib/UserMigration/ContactsMigrator.php index 50787dc4e5d..96d623938a3 100644 --- a/apps/dav/lib/UserMigration/ContactsMigrator.php +++ b/apps/dav/lib/UserMigration/ContactsMigrator.php @@ -37,10 +37,6 @@ class ContactsMigrator implements IMigrator, ISizeEstimationMigrator { use TMigratorBasicVersionHandling; - private CardDavBackend $cardDavBackend; - - private IL10N $l10n; - private SabreDavServer $sabreDavServer; private const USERS_URI_ROOT = 'principals/users/'; @@ -54,12 +50,9 @@ class ContactsMigrator implements IMigrator, ISizeEstimationMigrator { private const PATH_ROOT = Application::APP_ID . '/address_books/'; public function __construct( - CardDavBackend $cardDavBackend, - IL10N $l10n, + private CardDavBackend $cardDavBackend, + private IL10N $l10n, ) { - $this->cardDavBackend = $cardDavBackend; - $this->l10n = $l10n; - $root = new RootCollection(); $this->sabreDavServer = new SabreDavServer(new CachingTree($root)); $this->sabreDavServer->addPlugin(new CardDAVPlugin()); diff --git a/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php b/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php index f895deb7fd1..e60efc6fb19 100644 --- a/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php +++ b/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php @@ -18,7 +18,7 @@ class EnablePluginTest extends TestCase { /** @var \Sabre\DAV\Server|\PHPUnit\Framework\MockObject\MockObject */ protected $server; - /** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ protected $config; /** @var BirthdayService |\PHPUnit\Framework\MockObject\MockObject */ diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php index bdb318ee32f..6c46a2aed2d 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php @@ -14,6 +14,7 @@ use OCA\DAV\CalDAV\Reminder\NotificationProvider\PushProvider; use OCA\DAV\CalDAV\Reminder\NotificationProviderManager; use OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException; use OCA\DAV\Capabilities; +use OCP\AppFramework\QueryException; use Test\TestCase; class NotificationProviderManagerTest extends TestCase { @@ -22,7 +23,7 @@ class NotificationProviderManagerTest extends TestCase { private $providerManager; /** - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ protected function setUp(): void { parent::setUp(); @@ -65,7 +66,7 @@ class NotificationProviderManagerTest extends TestCase { } /** - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ public function testRegisterBadProvider(): void { $this->expectException(\InvalidArgumentException::class); diff --git a/apps/dav/tests/unit/Command/ListCalendarsTest.php b/apps/dav/tests/unit/Command/ListCalendarsTest.php index 2640b4d966b..1f5f9882ac4 100644 --- a/apps/dav/tests/unit/Command/ListCalendarsTest.php +++ b/apps/dav/tests/unit/Command/ListCalendarsTest.php @@ -19,7 +19,7 @@ use Test\TestCase; */ class ListCalendarsTest extends TestCase { - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */ + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */ private $userManager; /** @var CalDavBackend|\PHPUnit\Framework\MockObject\MockObject $l10n */ diff --git a/apps/dav/tests/unit/Command/MoveCalendarTest.php b/apps/dav/tests/unit/Command/MoveCalendarTest.php index 892b00968f9..9b935ca3cdb 100644 --- a/apps/dav/tests/unit/Command/MoveCalendarTest.php +++ b/apps/dav/tests/unit/Command/MoveCalendarTest.php @@ -24,10 +24,10 @@ use Test\TestCase; * @package OCA\DAV\Tests\Command */ class MoveCalendarTest extends TestCase { - /** @var \OCP\IUserManager|MockObject $userManager */ + /** @var IUserManager|MockObject $userManager */ private $userManager; - /** @var \OCP\IGroupManager|MockObject $groupManager */ + /** @var IGroupManager|MockObject $groupManager */ private $groupManager; /** @var \OCP\Share\IManager|MockObject $shareManager */ diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php index 6996022b607..e5a68e5a726 100644 --- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php @@ -18,7 +18,7 @@ use Psr\Log\LoggerInterface; class EntityCollectionTest extends \Test\TestCase { - /** @var \OCP\Comments\ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ protected $commentsManager; /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ protected $userManager; diff --git a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php index 15b8073481c..e5706099270 100644 --- a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php @@ -18,7 +18,7 @@ class EntityTypeCollectionTest extends \Test\TestCase { /** @var ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ protected $commentsManager; - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ protected $userManager; /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php index 8f58e5c3c5f..5d9e828f687 100644 --- a/apps/dav/tests/unit/Comments/RootCollectionTest.php +++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php @@ -20,19 +20,19 @@ use Psr\Log\LoggerInterface; class RootCollectionTest extends \Test\TestCase { - /** @var \OCP\Comments\ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ protected $commentsManager; - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ protected $userManager; /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var RootCollection */ protected $collection; - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */ protected $userSession; /** @var IEventDispatcher */ protected $dispatcher; - /** @var \OCP\IUser|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */ protected $user; protected function setUp(): void { diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php index 3f134745f86..72d5e7198a3 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php @@ -40,7 +40,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase { private $plugin; /** - * @var \OCP\IUser + * @var IUser */ private $user; diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index d659b01d039..7510340aa57 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -23,14 +23,11 @@ use OCP\Files\StorageNotAvailableException; use Test\Traits\UserTrait; class TestViewDirectory extends View { - private $updatables; - private $deletables; - private $canRename; - - public function __construct($updatables, $deletables, $canRename = true) { - $this->updatables = $updatables; - $this->deletables = $deletables; - $this->canRename = $canRename; + public function __construct( + private $updatables, + private $deletables, + private $canRename = true, + ) { } public function isUpdatable($path) { @@ -61,9 +58,9 @@ class TestViewDirectory extends View { class DirectoryTest extends \Test\TestCase { use UserTrait; - /** @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject */ + /** @var View|\PHPUnit\Framework\MockObject\MockObject */ private $view; - /** @var \OC\Files\FileInfo | \PHPUnit\Framework\MockObject\MockObject */ + /** @var FileInfo|\PHPUnit\Framework\MockObject\MockObject */ private $info; protected function setUp(): void { diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php index cf1ea4c6bae..df48cd61114 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php @@ -13,24 +13,15 @@ use Sabre\HTTP\ResponseInterface; class Auth implements BackendInterface { /** - * @var string - */ - private $user; - - /** - * @var string - */ - private $password; - - /** * Auth constructor. * * @param string $user * @param string $password */ - public function __construct($user, $password) { - $this->user = $user; - $this->password = $password; + public function __construct( + private $user, + private $password, + ) { } /** diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php index 67c2aa61430..4085bc93c78 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php @@ -64,7 +64,7 @@ abstract class RequestTestCase extends TestCase { } /** - * @param \OC\Files\View $view the view to run the webdav server against + * @param View $view the view to run the webdav server against * @param string $user * @param string $password * @param string $method diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/Sapi.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/Sapi.php index f7bcdd930ca..f12c93468ff 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/Sapi.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/Sapi.php @@ -12,11 +12,6 @@ use Sabre\HTTP\Response; class Sapi { /** - * @var \Sabre\HTTP\Request - */ - private $request; - - /** * @var \Sabre\HTTP\Response */ private $response; @@ -31,8 +26,9 @@ class Sapi { return $this->request; } - public function __construct(Request $request) { - $this->request = $request; + public function __construct( + private Request $request, + ) { } /** diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php index 125fe3959bb..97d3ba79046 100644 --- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php @@ -38,7 +38,7 @@ class SharesPluginTest extends \Test\TestCase { private $shareManager; /** - * @var \OCP\Files\Folder + * @var Folder */ private $userFolder; diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php index 59fd1e56963..bdab8135b1c 100644 --- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php @@ -33,12 +33,12 @@ class TagsPluginTest extends \Test\TestCase { private $tree; /** - * @var \OCP\ITagManager + * @var ITagManager */ private $tagManager; /** - * @var \OCP\ITags + * @var ITags */ private $tagger; diff --git a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php index 7ad1d34d94f..fd2bb451021 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php @@ -19,12 +19,12 @@ use Sabre\DAV\Exception\Forbidden; class SystemTagNodeTest extends \Test\TestCase { /** - * @var \OCP\SystemTag\ISystemTagManager|\PHPUnit\Framework\MockObject\MockObject + * @var ISystemTagManager|\PHPUnit\Framework\MockObject\MockObject */ private $tagManager; /** - * @var \OCP\IUser + * @var IUser */ private $user; diff --git a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php index 91dab4ecf11..e1517eec425 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php @@ -42,7 +42,7 @@ class SystemTagPluginTest extends \Test\TestCase { private $tree; /** - * @var \OCP\SystemTag\ISystemTagManager + * @var ISystemTagManager */ private $tagManager; diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php index 2ffbc1cf01f..57e2454f06c 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php @@ -18,12 +18,12 @@ use OCP\SystemTag\TagNotFoundException; class SystemTagsByIdCollectionTest extends \Test\TestCase { /** - * @var \OCP\SystemTag\ISystemTagManager + * @var ISystemTagManager */ private $tagManager; /** - * @var \OCP\IUser + * @var IUser */ private $user; diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php index 62f6963e202..ba9304d33fc 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php @@ -24,17 +24,17 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase { private $node; /** - * @var \OCP\SystemTag\ISystemTagManager + * @var ISystemTagManager */ private $tagManager; /** - * @var \OCP\SystemTag\ISystemTagObjectMapper + * @var ISystemTagObjectMapper */ private $tagMapper; /** - * @var \OCP\Files\Folder + * @var Folder */ private $userFolder; diff --git a/apps/encryption/lib/Controller/RecoveryController.php b/apps/encryption/lib/Controller/RecoveryController.php index 66011fe2439..d75406e6319 100644 --- a/apps/encryption/lib/Controller/RecoveryController.php +++ b/apps/encryption/lib/Controller/RecoveryController.php @@ -18,34 +18,20 @@ use OCP\IRequest; class RecoveryController extends Controller { /** - * @var IConfig - */ - private $config; - /** - * @var IL10N - */ - private $l; - /** - * @var Recovery - */ - private $recovery; - - /** * @param string $AppName * @param IRequest $request * @param IConfig $config - * @param IL10N $l10n + * @param IL10N $l * @param Recovery $recovery */ - public function __construct($AppName, + public function __construct( + $AppName, IRequest $request, - IConfig $config, - IL10N $l10n, - Recovery $recovery) { + private IConfig $config, + private IL10N $l, + private Recovery $recovery, + ) { parent::__construct($AppName, $request); - $this->config = $config; - $this->l = $l10n; - $this->recovery = $recovery; } /** diff --git a/apps/encryption/lib/Controller/SettingsController.php b/apps/encryption/lib/Controller/SettingsController.php index df896e52fa5..8548ea51c04 100644 --- a/apps/encryption/lib/Controller/SettingsController.php +++ b/apps/encryption/lib/Controller/SettingsController.php @@ -24,34 +24,10 @@ use OCP\IUserSession; class SettingsController extends Controller { - /** @var IL10N */ - private $l; - - /** @var IUserManager */ - private $userManager; - - /** @var IUserSession */ - private $userSession; - - /** @var KeyManager */ - private $keyManager; - - /** @var Crypt */ - private $crypt; - - /** @var Session */ - private $session; - - /** @var ISession */ - private $ocSession; - - /** @var Util */ - private $util; - /** * @param string $AppName * @param IRequest $request - * @param IL10N $l10n + * @param IL10N $l * @param IUserManager $userManager * @param IUserSession $userSession * @param KeyManager $keyManager @@ -60,26 +36,19 @@ class SettingsController extends Controller { * @param ISession $ocSession * @param Util $util */ - public function __construct($AppName, + public function __construct( + $AppName, IRequest $request, - IL10N $l10n, - IUserManager $userManager, - IUserSession $userSession, - KeyManager $keyManager, - Crypt $crypt, - Session $session, - ISession $ocSession, - Util $util, + private IL10N $l, + private IUserManager $userManager, + private IUserSession $userSession, + private KeyManager $keyManager, + private Crypt $crypt, + private Session $session, + private ISession $ocSession, + private Util $util, ) { parent::__construct($AppName, $request); - $this->l = $l10n; - $this->userSession = $userSession; - $this->userManager = $userManager; - $this->keyManager = $keyManager; - $this->crypt = $crypt; - $this->session = $session; - $this->ocSession = $ocSession; - $this->util = $util; } diff --git a/apps/encryption/lib/Controller/StatusController.php b/apps/encryption/lib/Controller/StatusController.php index 5c6a950d0a3..341ad6bc49f 100644 --- a/apps/encryption/lib/Controller/StatusController.php +++ b/apps/encryption/lib/Controller/StatusController.php @@ -17,32 +17,21 @@ use OCP\IRequest; class StatusController extends Controller { - /** @var IL10N */ - private $l; - - /** @var Session */ - private $session; - - /** @var IManager */ - private $encryptionManager; - /** * @param string $AppName * @param IRequest $request - * @param IL10N $l10n + * @param IL10N $l * @param Session $session * @param IManager $encryptionManager */ - public function __construct($AppName, + public function __construct( + $AppName, IRequest $request, - IL10N $l10n, - Session $session, - IManager $encryptionManager, + private IL10N $l, + private Session $session, + private IManager $encryptionManager, ) { parent::__construct($AppName, $request); - $this->l = $l10n; - $this->session = $session; - $this->encryptionManager = $encryptionManager; } /** diff --git a/apps/encryption/lib/Crypto/DecryptAll.php b/apps/encryption/lib/Crypto/DecryptAll.php index c336f2d92a2..362f43b8672 100644 --- a/apps/encryption/lib/Crypto/DecryptAll.php +++ b/apps/encryption/lib/Crypto/DecryptAll.php @@ -19,21 +19,6 @@ use Symfony\Component\Console\Question\Question; class DecryptAll { - /** @var Util */ - protected $util; - - /** @var QuestionHelper */ - protected $questionHelper; - - /** @var Crypt */ - protected $crypt; - - /** @var KeyManager */ - protected $keyManager; - - /** @var Session */ - protected $session; - /** * @param Util $util * @param KeyManager $keyManager @@ -42,17 +27,12 @@ class DecryptAll { * @param QuestionHelper $questionHelper */ public function __construct( - Util $util, - KeyManager $keyManager, - Crypt $crypt, - Session $session, - QuestionHelper $questionHelper, + protected Util $util, + protected KeyManager $keyManager, + protected Crypt $crypt, + protected Session $session, + protected QuestionHelper $questionHelper, ) { - $this->util = $util; - $this->keyManager = $keyManager; - $this->crypt = $crypt; - $this->session = $session; - $this->questionHelper = $questionHelper; } /** diff --git a/apps/encryption/lib/Crypto/EncryptAll.php b/apps/encryption/lib/Crypto/EncryptAll.php index e9db5034baa..6dfa36e6e3d 100644 --- a/apps/encryption/lib/Crypto/EncryptAll.php +++ b/apps/encryption/lib/Crypto/EncryptAll.php @@ -29,72 +29,28 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; class EncryptAll { - /** @var Setup */ - protected $userSetup; - - /** @var IUserManager */ - protected $userManager; - - /** @var View */ - protected $rootView; - - /** @var KeyManager */ - protected $keyManager; - - /** @var Util */ - protected $util; - /** @var array */ protected $userPasswords; - /** @var IConfig */ - protected $config; - - /** @var IMailer */ - protected $mailer; - - /** @var IL10N */ - protected $l; - - /** @var IFactory */ - protected $l10nFactory; - - /** @var QuestionHelper */ - protected $questionHelper; - /** @var OutputInterface */ protected $output; /** @var InputInterface */ protected $input; - /** @var ISecureRandom */ - protected $secureRandom; - public function __construct( - Setup $userSetup, - IUserManager $userManager, - View $rootView, - KeyManager $keyManager, - Util $util, - IConfig $config, - IMailer $mailer, - IL10N $l, - IFactory $l10nFactory, - QuestionHelper $questionHelper, - ISecureRandom $secureRandom, + protected Setup $userSetup, + protected IUserManager $userManager, + protected View $rootView, + protected KeyManager $keyManager, + protected Util $util, + protected IConfig $config, + protected IMailer $mailer, + protected IL10N $l, + protected IFactory $l10nFactory, + protected QuestionHelper $questionHelper, + protected ISecureRandom $secureRandom, ) { - $this->userSetup = $userSetup; - $this->userManager = $userManager; - $this->rootView = $rootView; - $this->keyManager = $keyManager; - $this->util = $util; - $this->config = $config; - $this->mailer = $mailer; - $this->l = $l; - $this->l10nFactory = $l10nFactory; - $this->questionHelper = $questionHelper; - $this->secureRandom = $secureRandom; // store one time passwords for the users $this->userPasswords = []; } diff --git a/apps/encryption/lib/Migration/SetMasterKeyStatus.php b/apps/encryption/lib/Migration/SetMasterKeyStatus.php index 56dcd15dae4..96194351296 100644 --- a/apps/encryption/lib/Migration/SetMasterKeyStatus.php +++ b/apps/encryption/lib/Migration/SetMasterKeyStatus.php @@ -17,12 +17,9 @@ use OCP\Migration\IRepairStep; class SetMasterKeyStatus implements IRepairStep { - /** @var IConfig */ - private $config; - - - public function __construct(IConfig $config) { - $this->config = $config; + public function __construct( + private IConfig $config, + ) { } /** diff --git a/apps/encryption/lib/Recovery.php b/apps/encryption/lib/Recovery.php index 3990067f19b..38e78f5e822 100644 --- a/apps/encryption/lib/Recovery.php +++ b/apps/encryption/lib/Recovery.php @@ -20,26 +20,6 @@ class Recovery { * @var null|IUser */ protected $user; - /** - * @var Crypt - */ - protected $crypt; - /** - * @var KeyManager - */ - private $keyManager; - /** - * @var IConfig - */ - private $config; - /** - * @var View - */ - private $view; - /** - * @var IFile - */ - private $file; /** * @param IUserSession $userSession @@ -49,18 +29,15 @@ class Recovery { * @param IFile $file * @param View $view */ - public function __construct(IUserSession $userSession, - Crypt $crypt, - KeyManager $keyManager, - IConfig $config, - IFile $file, - View $view) { + public function __construct( + IUserSession $userSession, + protected Crypt $crypt, + private KeyManager $keyManager, + private IConfig $config, + private IFile $file, + private View $view, + ) { $this->user = ($userSession->isLoggedIn()) ? $userSession->getUser() : null; - $this->crypt = $crypt; - $this->keyManager = $keyManager; - $this->config = $config; - $this->view = $view; - $this->file = $file; } /** diff --git a/apps/encryption/lib/Services/PassphraseService.php b/apps/encryption/lib/Services/PassphraseService.php index 4b3e83375f5..0786cd3399a 100644 --- a/apps/encryption/lib/Services/PassphraseService.php +++ b/apps/encryption/lib/Services/PassphraseService.php @@ -8,6 +8,7 @@ declare(strict_types=1); namespace OCA\Encryption\Services; +use OC\Files\Filesystem; use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\KeyManager; use OCA\Encryption\Recovery; @@ -78,7 +79,7 @@ class PassphraseService { } $this->logger->error('Encryption could not update users encryption password'); - + // NOTE: Session does not need to be updated as the // private key has not changed, only the passphrase // used to decrypt it has changed @@ -137,6 +138,6 @@ class PassphraseService { * Init mount points for given user */ private function initMountPoints(IUser $user): void { - \OC\Files\Filesystem::initMountPoints($user); + Filesystem::initMountPoints($user); } } diff --git a/apps/encryption/lib/Session.php b/apps/encryption/lib/Session.php index 4b759618eb2..e2731d9611d 100644 --- a/apps/encryption/lib/Session.php +++ b/apps/encryption/lib/Session.php @@ -12,9 +12,6 @@ use OCP\ISession; class Session { - /** @var ISession */ - protected $session; - public const NOT_INITIALIZED = '0'; public const INIT_EXECUTED = '1'; public const INIT_SUCCESSFUL = '2'; @@ -22,8 +19,9 @@ class Session { /** * @param ISession $session */ - public function __construct(ISession $session) { - $this->session = $session; + public function __construct( + protected ISession $session, + ) { } /** diff --git a/apps/encryption/lib/Settings/Personal.php b/apps/encryption/lib/Settings/Personal.php index b544ea1dc3e..63e50ccc078 100644 --- a/apps/encryption/lib/Settings/Personal.php +++ b/apps/encryption/lib/Settings/Personal.php @@ -14,20 +14,12 @@ use OCP\Settings\ISettings; class Personal implements ISettings { - /** @var IConfig */ - private $config; - /** @var Session */ - private $session; - /** @var Util */ - private $util; - /** @var IUserSession */ - private $userSession; - - public function __construct(IConfig $config, Session $session, Util $util, IUserSession $userSession) { - $this->config = $config; - $this->session = $session; - $this->util = $util; - $this->userSession = $userSession; + public function __construct( + private IConfig $config, + private Session $session, + private Util $util, + private IUserSession $userSession, + ) { } /** diff --git a/apps/encryption/lib/Util.php b/apps/encryption/lib/Util.php index 61656ddcda3..26d04220733 100644 --- a/apps/encryption/lib/Util.php +++ b/apps/encryption/lib/Util.php @@ -7,6 +7,7 @@ */ namespace OCA\Encryption; +use OC\Files\Storage\Storage; use OC\Files\View; use OCA\Encryption\Crypto\Crypt; use OCP\IConfig; @@ -131,7 +132,7 @@ class Util { * get storage of path * * @param string $path - * @return \OC\Files\Storage\Storage|null + * @return Storage|null */ public function getStorage($path) { return $this->files->getMount($path)->getStorage(); diff --git a/apps/encryption/tests/Command/TestEnableMasterKey.php b/apps/encryption/tests/Command/TestEnableMasterKey.php index 2ed29becf2a..c4678b778bc 100644 --- a/apps/encryption/tests/Command/TestEnableMasterKey.php +++ b/apps/encryption/tests/Command/TestEnableMasterKey.php @@ -23,7 +23,7 @@ class TestEnableMasterKey extends TestCase { /** @var Util | \PHPUnit\Framework\MockObject\MockObject */ protected $util; - /** @var \OCP\IConfig | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ protected $config; /** @var \Symfony\Component\Console\Helper\QuestionHelper | \PHPUnit\Framework\MockObject\MockObject */ diff --git a/apps/encryption/tests/Controller/RecoveryControllerTest.php b/apps/encryption/tests/Controller/RecoveryControllerTest.php index 57015975cfc..9de583b387c 100644 --- a/apps/encryption/tests/Controller/RecoveryControllerTest.php +++ b/apps/encryption/tests/Controller/RecoveryControllerTest.php @@ -18,11 +18,11 @@ use Test\TestCase; class RecoveryControllerTest extends TestCase { /** @var RecoveryController */ private $controller; - /** @var \OCP\IRequest|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */ private $requestMock; - /** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $configMock; - /** @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ private $l10nMock; /** @var Recovery|\PHPUnit\Framework\MockObject\MockObject */ private $recoveryMock; diff --git a/apps/encryption/tests/Controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php index 830536dc835..b676d57164f 100644 --- a/apps/encryption/tests/Controller/SettingsControllerTest.php +++ b/apps/encryption/tests/Controller/SettingsControllerTest.php @@ -27,16 +27,16 @@ class SettingsControllerTest extends TestCase { /** @var SettingsController */ private $controller; - /** @var \OCP\IRequest|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */ private $requestMock; - /** @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ private $l10nMock; - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ private $userManagerMock; - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */ private $userSessionMock; /** @var KeyManager|\PHPUnit\Framework\MockObject\MockObject */ @@ -50,7 +50,7 @@ class SettingsControllerTest extends TestCase { /** @var MockObject|IUser */ private $user; - /** @var \OCP\ISession|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ISession|\PHPUnit\Framework\MockObject\MockObject */ private $ocSessionMock; /** @var Util|\PHPUnit\Framework\MockObject\MockObject */ diff --git a/apps/encryption/tests/Controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php index e52aaba30c1..fbe44f52fb7 100644 --- a/apps/encryption/tests/Controller/StatusControllerTest.php +++ b/apps/encryption/tests/Controller/StatusControllerTest.php @@ -16,10 +16,10 @@ use Test\TestCase; class StatusControllerTest extends TestCase { - /** @var \OCP\IRequest|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */ private $requestMock; - /** @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ private $l10nMock; /** @var Session|\PHPUnit\Framework\MockObject\MockObject */ diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php index ba0227ec56a..74afc6d44a1 100644 --- a/apps/encryption/tests/Crypto/CryptTest.php +++ b/apps/encryption/tests/Crypto/CryptTest.php @@ -19,13 +19,13 @@ class CryptTest extends TestCase { /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */ private $userSession; - /** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; - /** @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ private $l; /** @var Crypt */ diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php index 9de4f6c2c67..d702c123b9b 100644 --- a/apps/encryption/tests/Crypto/EncryptAllTest.php +++ b/apps/encryption/tests/Crypto/EncryptAllTest.php @@ -35,22 +35,22 @@ class EncryptAllTest extends TestCase { /** @var \PHPUnit\Framework\MockObject\MockObject|Util */ protected $util; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IUserManager */ + /** @var \PHPUnit\Framework\MockObject\MockObject|IUserManager */ protected $userManager; /** @var \PHPUnit\Framework\MockObject\MockObject|Setup */ protected $setupUser; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OC\Files\View */ + /** @var \PHPUnit\Framework\MockObject\MockObject|View */ protected $view; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IConfig */ + /** @var \PHPUnit\Framework\MockObject\MockObject|IConfig */ protected $config; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\Mail\IMailer */ + /** @var \PHPUnit\Framework\MockObject\MockObject|IMailer */ protected $mailer; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IL10N */ + /** @var \PHPUnit\Framework\MockObject\MockObject|IL10N */ protected $l; /** @var \PHPUnit\Framework\MockObject\MockObject | IFactory */ @@ -65,10 +65,10 @@ class EncryptAllTest extends TestCase { /** @var \PHPUnit\Framework\MockObject\MockObject | \Symfony\Component\Console\Output\OutputInterface */ protected $outputInterface; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\UserInterface */ + /** @var \PHPUnit\Framework\MockObject\MockObject|UserInterface */ protected $userInterface; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\Security\ISecureRandom */ + /** @var \PHPUnit\Framework\MockObject\MockObject|ISecureRandom */ protected $secureRandom; /** @var EncryptAll */ diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 2390012a97a..7f3d9d1f348 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -50,7 +50,7 @@ class EncryptionTest extends TestCase { /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $loggerMock; - /** @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ private $l10nMock; private IStorage&MockObject $storageMock; diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php index 54c1bc2295a..8f5c9a78faf 100644 --- a/apps/encryption/tests/KeyManagerTest.php +++ b/apps/encryption/tests/KeyManagerTest.php @@ -46,7 +46,7 @@ class KeyManagerTest extends TestCase { /** @var Crypt|\PHPUnit\Framework\MockObject\MockObject */ private $cryptMock; - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */ private $userMock; /** @var Session|\PHPUnit\Framework\MockObject\MockObject */ @@ -58,7 +58,7 @@ class KeyManagerTest extends TestCase { /** @var Util|\PHPUnit\Framework\MockObject\MockObject */ private $utilMock; - /** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $configMock; /** @var ILockingProvider|MockObject */ @@ -661,7 +661,7 @@ class KeyManagerTest extends TestCase { ->with('/admin/files/myfile.txt') ->willReturn(false); - /** @var \OC\Files\View $view */ + /** @var View $view */ $this->assertSame(0, $this->instance->getVersion('/admin/files/myfile.txt', $view)); } @@ -678,7 +678,7 @@ class KeyManagerTest extends TestCase { ->with('/admin/files/myfile.txt') ->willReturn($fileInfo); - /** @var \OC\Files\View $view */ + /** @var View $view */ $this->assertSame(1337, $this->instance->getVersion('/admin/files/myfile.txt', $view)); } @@ -708,7 +708,7 @@ class KeyManagerTest extends TestCase { ->with('/admin/files/myfile.txt') ->willReturn($fileInfo); - /** @var \OC\Files\View $view */ + /** @var View $view */ $this->instance->setVersion('/admin/files/myfile.txt', 5, $view); } @@ -720,7 +720,7 @@ class KeyManagerTest extends TestCase { ->with('/admin/files/myfile.txt') ->willReturn(false); - /** @var \OC\Files\View $view */ + /** @var View $view */ $this->instance->setVersion('/admin/files/myfile.txt', 5, $view); } diff --git a/apps/encryption/tests/RecoveryTest.php b/apps/encryption/tests/RecoveryTest.php index 725e16342e7..17ad385eca0 100644 --- a/apps/encryption/tests/RecoveryTest.php +++ b/apps/encryption/tests/RecoveryTest.php @@ -21,15 +21,15 @@ use Test\TestCase; class RecoveryTest extends TestCase { private static $tempStorage = []; /** - * @var \OCP\Encryption\IFile|\PHPUnit\Framework\MockObject\MockObject + * @var IFile|\PHPUnit\Framework\MockObject\MockObject */ private $fileMock; /** - * @var \OC\Files\View|\PHPUnit\Framework\MockObject\MockObject + * @var View|\PHPUnit\Framework\MockObject\MockObject */ private $viewMock; /** - * @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject + * @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */ private $userSessionMock; /** @@ -41,7 +41,7 @@ class RecoveryTest extends TestCase { */ private $keyManagerMock; /** - * @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject + * @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $configMock; /** diff --git a/apps/encryption/tests/SessionTest.php b/apps/encryption/tests/SessionTest.php index c9486658bcb..3072bc6ef3b 100644 --- a/apps/encryption/tests/SessionTest.php +++ b/apps/encryption/tests/SessionTest.php @@ -18,7 +18,7 @@ class SessionTest extends TestCase { * @var Session */ private $instance; - /** @var \OCP\ISession|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ISession|\PHPUnit\Framework\MockObject\MockObject */ private $sessionMock; diff --git a/apps/encryption/tests/UtilTest.php b/apps/encryption/tests/UtilTest.php index 5571a9483db..711564af5bd 100644 --- a/apps/encryption/tests/UtilTest.php +++ b/apps/encryption/tests/UtilTest.php @@ -22,16 +22,16 @@ use Test\TestCase; class UtilTest extends TestCase { private static $tempStorage = []; - /** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $configMock; - /** @var \OC\Files\View|\PHPUnit\Framework\MockObject\MockObject */ + /** @var View|\PHPUnit\Framework\MockObject\MockObject */ private $filesMock; - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ private $userManagerMock; - /** @var \OCP\Files\Mount\IMountPoint|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IMountPoint|\PHPUnit\Framework\MockObject\MockObject */ private $mountMock; /** @var Util */ diff --git a/apps/federatedfilesharing/lib/AddressHandler.php b/apps/federatedfilesharing/lib/AddressHandler.php index a2986618729..d21516c698c 100644 --- a/apps/federatedfilesharing/lib/AddressHandler.php +++ b/apps/federatedfilesharing/lib/AddressHandler.php @@ -20,30 +20,18 @@ use OCP\Util; */ class AddressHandler { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - /** @var ICloudIdManager */ - private $cloudIdManager; - /** * AddressHandler constructor. * * @param IURLGenerator $urlGenerator - * @param IL10N $il10n + * @param IL10N $l * @param ICloudIdManager $cloudIdManager */ public function __construct( - IURLGenerator $urlGenerator, - IL10N $il10n, - ICloudIdManager $cloudIdManager, + private IURLGenerator $urlGenerator, + private IL10N $l, + private ICloudIdManager $cloudIdManager, ) { - $this->l = $il10n; - $this->urlGenerator = $urlGenerator; - $this->cloudIdManager = $cloudIdManager; } /** diff --git a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php index f72209642ba..9d66cd71812 100644 --- a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php +++ b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php @@ -22,7 +22,6 @@ use OCP\BackgroundJob\Job; */ class RetryJob extends Job { private bool $retainJob = true; - private Notifications $notifications; /** @var int max number of attempts to send the request */ private int $maxTry = 20; @@ -30,10 +29,11 @@ class RetryJob extends Job { /** @var int how much time should be between two tries (10 minutes) */ private int $interval = 600; - public function __construct(Notifications $notifications, - ITimeFactory $time) { + public function __construct( + private Notifications $notifications, + ITimeFactory $time, + ) { parent::__construct($time); - $this->notifications = $notifications; } /** diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php index d19414f3c11..222c6490b83 100644 --- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php +++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php @@ -26,6 +26,7 @@ use OCP\Federation\Exceptions\ProviderDoesNotExistsException; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\ICloudIdManager; +use OCP\HintException; use OCP\IDBConnection; use OCP\IRequest; use OCP\IUserManager; @@ -38,69 +39,25 @@ use Psr\Log\LoggerInterface; #[OpenAPI(scope: OpenAPI::SCOPE_FEDERATION)] class RequestHandlerController extends OCSController { - /** @var FederatedShareProvider */ - private $federatedShareProvider; - - /** @var IDBConnection */ - private $connection; - - /** @var Share\IManager */ - private $shareManager; - - /** @var Notifications */ - private $notifications; - - /** @var AddressHandler */ - private $addressHandler; - - /** @var IUserManager */ - private $userManager; - /** @var string */ private $shareTable = 'share'; - /** @var ICloudIdManager */ - private $cloudIdManager; - - /** @var LoggerInterface */ - private $logger; - - /** @var ICloudFederationFactory */ - private $cloudFederationFactory; - - /** @var ICloudFederationProviderManager */ - private $cloudFederationProviderManager; - - /** @var IEventDispatcher */ - private $eventDispatcher; - - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - FederatedShareProvider $federatedShareProvider, - IDBConnection $connection, - Share\IManager $shareManager, - Notifications $notifications, - AddressHandler $addressHandler, - IUserManager $userManager, - ICloudIdManager $cloudIdManager, - LoggerInterface $logger, - ICloudFederationFactory $cloudFederationFactory, - ICloudFederationProviderManager $cloudFederationProviderManager, - IEventDispatcher $eventDispatcher, + private FederatedShareProvider $federatedShareProvider, + private IDBConnection $connection, + private Share\IManager $shareManager, + private Notifications $notifications, + private AddressHandler $addressHandler, + private IUserManager $userManager, + private ICloudIdManager $cloudIdManager, + private LoggerInterface $logger, + private ICloudFederationFactory $cloudFederationFactory, + private ICloudFederationProviderManager $cloudFederationProviderManager, + private IEventDispatcher $eventDispatcher, ) { parent::__construct($appName, $request); - - $this->federatedShareProvider = $federatedShareProvider; - $this->connection = $connection; - $this->shareManager = $shareManager; - $this->notifications = $notifications; - $this->addressHandler = $addressHandler; - $this->userManager = $userManager; - $this->cloudIdManager = $cloudIdManager; - $this->logger = $logger; - $this->cloudFederationFactory = $cloudFederationFactory; - $this->cloudFederationProviderManager = $cloudFederationProviderManager; - $this->eventDispatcher = $eventDispatcher; } /** @@ -232,7 +189,7 @@ class RequestHandlerController extends OCSController { * @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}> * @throws OCSException * @throws ShareNotFound - * @throws \OCP\HintException + * @throws HintException * * 200: Share accepted successfully */ diff --git a/apps/federatedfilesharing/lib/Events/FederatedShareAddedEvent.php b/apps/federatedfilesharing/lib/Events/FederatedShareAddedEvent.php index 7654262a57a..2a79f434b8c 100644 --- a/apps/federatedfilesharing/lib/Events/FederatedShareAddedEvent.php +++ b/apps/federatedfilesharing/lib/Events/FederatedShareAddedEvent.php @@ -17,14 +17,12 @@ use OCP\EventDispatcher\Event; */ class FederatedShareAddedEvent extends Event { - /** @var string */ - private $remote; - /** * @since 20.0.0 */ - public function __construct(string $remote) { - $this->remote = $remote; + public function __construct( + private string $remote, + ) { } /** diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index c115c613338..11e78f5cb97 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -17,6 +17,7 @@ use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; +use OCP\HintException; use OCP\IConfig; use OCP\IDBConnection; use OCP\IL10N; @@ -349,7 +350,7 @@ class FederatedShareProvider implements IShareProvider { * * @param IShare $share * @throws ShareNotFound - * @throws \OCP\HintException + * @throws HintException */ protected function sendPermissionUpdate(IShare $share) { $remoteId = $this->getRemoteId($share); @@ -458,7 +459,7 @@ class FederatedShareProvider implements IShareProvider { * * @param IShare $share * @throws ShareNotFound - * @throws \OCP\HintException + * @throws HintException */ public function delete(IShare $share) { [, $remote] = $this->addressHandler->splitUserRemote($share->getSharedWith()); @@ -485,7 +486,7 @@ class FederatedShareProvider implements IShareProvider { * @param IShare $share * @param bool $isOwner the user can either be the owner or the user who re-sahred it * @throws ShareNotFound - * @throws \OCP\HintException + * @throws HintException */ protected function revokeShare($share, $isOwner) { if ($this->userManager->userExists($share->getShareOwner()) && $this->userManager->userExists($share->getSharedBy())) { @@ -680,7 +681,7 @@ class FederatedShareProvider implements IShareProvider { /** * Get shares for a given path * - * @param \OCP\Files\Node $path + * @param Node $path * @return IShare[] */ public function getSharesByPath(Node $path) { @@ -850,7 +851,7 @@ class FederatedShareProvider implements IShareProvider { * * @param string $userId * @param int $id - * @return \OCP\Files\Node + * @return Node * @throws InvalidShare */ private function getNode($userId, $id) { diff --git a/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php b/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php index 78517e3a297..e78c93ec1a5 100644 --- a/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php +++ b/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php @@ -18,11 +18,9 @@ use OCP\Migration\SimpleMigrationStep; class Version1011Date20201120125158 extends SimpleMigrationStep { - /** @var IDBConnection */ - private $connection; - - public function __construct(IDBConnection $connection) { - $this->connection = $connection; + public function __construct( + private IDBConnection $connection, + ) { } public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php index e107065d0c1..3c971773587 100644 --- a/apps/federatedfilesharing/lib/Notifications.php +++ b/apps/federatedfilesharing/lib/Notifications.php @@ -13,6 +13,7 @@ use OCP\BackgroundJob\IJobList; use OCP\EventDispatcher\IEventDispatcher; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; +use OCP\HintException; use OCP\Http\Client\IClientService; use OCP\OCS\IDiscoveryService; use Psr\Log\LoggerInterface; @@ -45,7 +46,7 @@ class Notifications { * @param string $sharedByFederatedId * @param int $shareType (can be a remote user or group share) * @return bool - * @throws \OCP\HintException + * @throws HintException * @throws \OC\ServerNotAvailableException */ public function sendRemoteShare($token, $shareWith, $name, $remoteId, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) { @@ -104,7 +105,7 @@ class Notifications { * @param int $permission * @param string $filename * @return array|false - * @throws \OCP\HintException + * @throws HintException * @throws \OC\ServerNotAvailableException */ public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename) { diff --git a/apps/federatedfilesharing/lib/Notifier.php b/apps/federatedfilesharing/lib/Notifier.php index 4c4380d0875..10b57c578a2 100644 --- a/apps/federatedfilesharing/lib/Notifier.php +++ b/apps/federatedfilesharing/lib/Notifier.php @@ -18,16 +18,8 @@ use OCP\Notification\INotifier; use OCP\Notification\UnknownNotificationException; class Notifier implements INotifier { - /** @var IFactory */ - protected $factory; - /** @var IManager */ - protected $contactsManager; - /** @var IURLGenerator */ - protected $url; /** @var array */ protected $federatedContacts; - /** @var ICloudIdManager */ - protected $cloudIdManager; /** * @param IFactory $factory @@ -35,11 +27,12 @@ class Notifier implements INotifier { * @param IURLGenerator $url * @param ICloudIdManager $cloudIdManager */ - public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) { - $this->factory = $factory; - $this->contactsManager = $contactsManager; - $this->url = $url; - $this->cloudIdManager = $cloudIdManager; + public function __construct( + protected IFactory $factory, + protected IManager $contactsManager, + protected IURLGenerator $url, + protected ICloudIdManager $cloudIdManager, + ) { } /** diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php index f78112e2ce6..7e07703f430 100644 --- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php @@ -14,6 +14,7 @@ use OCA\Files_Sharing\External\Manager; use OCA\GlobalSiteSelector\Service\SlaveService; use OCP\Activity\IManager as IActivityManager; use OCP\App\IAppManager; +use OCP\AppFramework\QueryException; use OCP\Constants; use OCP\Federation\Exceptions\ActionNotSupportedException; use OCP\Federation\Exceptions\AuthenticationFailedException; @@ -79,7 +80,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @return string provider specific unique ID of the share * * @throws ProviderCouldNotAddShareException - * @throws \OCP\AppFramework\QueryException + * @throws QueryException * @throws HintException * @since 14.0.0 */ diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php index a7bdc545413..1343513e65a 100644 --- a/apps/federatedfilesharing/lib/Settings/Admin.php +++ b/apps/federatedfilesharing/lib/Settings/Admin.php @@ -14,27 +14,16 @@ use OCP\IURLGenerator; use OCP\Settings\IDelegatedSettings; class Admin implements IDelegatedSettings { - private FederatedShareProvider $fedShareProvider; - private IConfig $gsConfig; - private IL10N $l; - private IURLGenerator $urlGenerator; - private IInitialState $initialState; - /** * Admin constructor. */ public function __construct( - FederatedShareProvider $fedShareProvider, - IConfig $globalScaleConfig, - IL10N $l, - IURLGenerator $urlGenerator, - IInitialState $initialState, + private FederatedShareProvider $fedShareProvider, + private IConfig $gsConfig, + private IL10N $l, + private IURLGenerator $urlGenerator, + private IInitialState $initialState, ) { - $this->fedShareProvider = $fedShareProvider; - $this->gsConfig = $globalScaleConfig; - $this->l = $l; - $this->urlGenerator = $urlGenerator; - $this->initialState = $initialState; } /** diff --git a/apps/federatedfilesharing/lib/Settings/Personal.php b/apps/federatedfilesharing/lib/Settings/Personal.php index 93ca36ab420..b71b064859e 100644 --- a/apps/federatedfilesharing/lib/Settings/Personal.php +++ b/apps/federatedfilesharing/lib/Settings/Personal.php @@ -17,24 +17,13 @@ use OCP\IUserSession; use OCP\Settings\ISettings; class Personal implements ISettings { - private FederatedShareProvider $federatedShareProvider; - private IUserSession $userSession; - private Defaults $defaults; - private IInitialState $initialState; - private IURLGenerator $urlGenerator; - public function __construct( - FederatedShareProvider $federatedShareProvider, - IUserSession $userSession, - Defaults $defaults, - IInitialState $initialState, - IURLGenerator $urlGenerator, + private FederatedShareProvider $federatedShareProvider, + private IUserSession $userSession, + private Defaults $defaults, + private IInitialState $initialState, + private IURLGenerator $urlGenerator, ) { - $this->federatedShareProvider = $federatedShareProvider; - $this->userSession = $userSession; - $this->defaults = $defaults; - $this->initialState = $initialState; - $this->urlGenerator = $urlGenerator; } /** diff --git a/apps/federatedfilesharing/lib/Settings/PersonalSection.php b/apps/federatedfilesharing/lib/Settings/PersonalSection.php index 528c2b6c717..5ef1e180c31 100644 --- a/apps/federatedfilesharing/lib/Settings/PersonalSection.php +++ b/apps/federatedfilesharing/lib/Settings/PersonalSection.php @@ -10,14 +10,10 @@ use OCP\IURLGenerator; use OCP\Settings\IIconSection; class PersonalSection implements IIconSection { - /** @var IURLGenerator */ - private $urlGenerator; - /** @var IL10N */ - private $l; - - public function __construct(IURLGenerator $urlGenerator, IL10N $l) { - $this->urlGenerator = $urlGenerator; - $this->l = $l; + public function __construct( + private IURLGenerator $urlGenerator, + private IL10N $l, + ) { } /** diff --git a/apps/federatedfilesharing/lib/TokenHandler.php b/apps/federatedfilesharing/lib/TokenHandler.php index e0a6d2cbe8c..0151d12f5d9 100644 --- a/apps/federatedfilesharing/lib/TokenHandler.php +++ b/apps/federatedfilesharing/lib/TokenHandler.php @@ -17,16 +17,14 @@ use OCP\Security\ISecureRandom; class TokenHandler { public const TOKEN_LENGTH = 15; - /** @var ISecureRandom */ - private $secureRandom; - /** * TokenHandler constructor. * * @param ISecureRandom $secureRandom */ - public function __construct(ISecureRandom $secureRandom) { - $this->secureRandom = $secureRandom; + public function __construct( + private ISecureRandom $secureRandom, + ) { } /** diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php index 92196e68e01..8574f1f9000 100644 --- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php +++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php @@ -30,11 +30,6 @@ use Psr\Log\LoggerInterface; */ class GetSharedSecret extends Job { private IClient $httpClient; - private IJobList $jobList; - private IURLGenerator $urlGenerator; - private TrustedServers $trustedServers; - private IDiscoveryService $ocsDiscoveryService; - private LoggerInterface $logger; protected bool $retainJob = false; private string $defaultEndPoint = '/ocs/v2.php/apps/federation/api/v1/shared-secret'; /** 30 day = 2592000sec */ @@ -42,20 +37,15 @@ class GetSharedSecret extends Job { public function __construct( IClientService $httpClientService, - IURLGenerator $urlGenerator, - IJobList $jobList, - TrustedServers $trustedServers, - LoggerInterface $logger, - IDiscoveryService $ocsDiscoveryService, + private IURLGenerator $urlGenerator, + private IJobList $jobList, + private TrustedServers $trustedServers, + private LoggerInterface $logger, + private IDiscoveryService $ocsDiscoveryService, ITimeFactory $timeFactory, ) { parent::__construct($timeFactory); - $this->logger = $logger; $this->httpClient = $httpClientService->newClient(); - $this->jobList = $jobList; - $this->urlGenerator = $urlGenerator; - $this->ocsDiscoveryService = $ocsDiscoveryService; - $this->trustedServers = $trustedServers; } /** diff --git a/apps/federation/lib/Command/SyncFederationAddressBooks.php b/apps/federation/lib/Command/SyncFederationAddressBooks.php index 018ba5a45f8..36cb99473f7 100644 --- a/apps/federation/lib/Command/SyncFederationAddressBooks.php +++ b/apps/federation/lib/Command/SyncFederationAddressBooks.php @@ -14,12 +14,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class SyncFederationAddressBooks extends Command { - private SyncService $syncService; - - public function __construct(SyncService $syncService) { + public function __construct( + private SyncService $syncService, + ) { parent::__construct(); - - $this->syncService = $syncService; } protected function configure() { diff --git a/apps/federation/lib/Controller/OCSAuthAPIController.php b/apps/federation/lib/Controller/OCSAuthAPIController.php index 221a9321cd7..0aa3f8bd148 100644 --- a/apps/federation/lib/Controller/OCSAuthAPIController.php +++ b/apps/federation/lib/Controller/OCSAuthAPIController.php @@ -33,34 +33,18 @@ use Psr\Log\LoggerInterface; */ #[OpenAPI(scope: OpenAPI::SCOPE_FEDERATION)] class OCSAuthAPIController extends OCSController { - private ISecureRandom $secureRandom; - private IJobList $jobList; - private TrustedServers $trustedServers; - private DbHandler $dbHandler; - private LoggerInterface $logger; - private ITimeFactory $timeFactory; - private IThrottler $throttler; - public function __construct( string $appName, IRequest $request, - ISecureRandom $secureRandom, - IJobList $jobList, - TrustedServers $trustedServers, - DbHandler $dbHandler, - LoggerInterface $logger, - ITimeFactory $timeFactory, - IThrottler $throttler, + private ISecureRandom $secureRandom, + private IJobList $jobList, + private TrustedServers $trustedServers, + private DbHandler $dbHandler, + private LoggerInterface $logger, + private ITimeFactory $timeFactory, + private IThrottler $throttler, ) { parent::__construct($appName, $request); - - $this->secureRandom = $secureRandom; - $this->jobList = $jobList; - $this->trustedServers = $trustedServers; - $this->dbHandler = $dbHandler; - $this->logger = $logger; - $this->timeFactory = $timeFactory; - $this->throttler = $throttler; } /** diff --git a/apps/federation/lib/Controller/SettingsController.php b/apps/federation/lib/Controller/SettingsController.php index 18ebc516cb8..83e97e52415 100644 --- a/apps/federation/lib/Controller/SettingsController.php +++ b/apps/federation/lib/Controller/SettingsController.php @@ -17,17 +17,13 @@ use OCP\IL10N; use OCP\IRequest; class SettingsController extends Controller { - private IL10N $l; - private TrustedServers $trustedServers; - - public function __construct(string $AppName, + public function __construct( + string $AppName, IRequest $request, - IL10N $l10n, - TrustedServers $trustedServers, + private IL10N $l, + private TrustedServers $trustedServers, ) { parent::__construct($AppName, $request); - $this->l = $l10n; - $this->trustedServers = $trustedServers; } diff --git a/apps/federation/lib/DAV/FedAuth.php b/apps/federation/lib/DAV/FedAuth.php index 09e558cb2ea..45bf422c104 100644 --- a/apps/federation/lib/DAV/FedAuth.php +++ b/apps/federation/lib/DAV/FedAuth.php @@ -15,16 +15,14 @@ use Sabre\HTTP\ResponseInterface; class FedAuth extends AbstractBasic { - /** @var DbHandler */ - private $db; - /** * FedAuth constructor. * * @param DbHandler $db */ - public function __construct(DbHandler $db) { - $this->db = $db; + public function __construct( + private DbHandler $db, + ) { $this->principalPrefix = 'principals/system/'; // setup realm diff --git a/apps/federation/lib/DbHandler.php b/apps/federation/lib/DbHandler.php index 4b7fc1a8da1..877663b058a 100644 --- a/apps/federation/lib/DbHandler.php +++ b/apps/federation/lib/DbHandler.php @@ -25,16 +25,12 @@ use OCP\IL10N; * @package OCA\Federation */ class DbHandler { - private IDBConnection $connection; - private IL10N $IL10N; private string $dbTable = 'trusted_servers'; public function __construct( - IDBConnection $connection, - IL10N $il10n, + private IDBConnection $connection, + private IL10N $IL10N, ) { - $this->connection = $connection; - $this->IL10N = $il10n; } /** diff --git a/apps/federation/lib/Listener/SabrePluginAuthInitListener.php b/apps/federation/lib/Listener/SabrePluginAuthInitListener.php index a7f82c349f3..514a893fb39 100644 --- a/apps/federation/lib/Listener/SabrePluginAuthInitListener.php +++ b/apps/federation/lib/Listener/SabrePluginAuthInitListener.php @@ -19,10 +19,9 @@ use Sabre\DAV\Auth\Plugin; * @template-implements IEventListener<SabrePluginAuthInitEvent> */ class SabrePluginAuthInitListener implements IEventListener { - private FedAuth $fedAuth; - - public function __construct(FedAuth $fedAuth) { - $this->fedAuth = $fedAuth; + public function __construct( + private FedAuth $fedAuth, + ) { } public function handle(Event $event): void { diff --git a/apps/federation/lib/Middleware/AddServerMiddleware.php b/apps/federation/lib/Middleware/AddServerMiddleware.php index 8868e5c9207..0e38dd8e700 100644 --- a/apps/federation/lib/Middleware/AddServerMiddleware.php +++ b/apps/federation/lib/Middleware/AddServerMiddleware.php @@ -17,14 +17,11 @@ use OCP\IL10N; use Psr\Log\LoggerInterface; class AddServerMiddleware extends Middleware { - protected string $appName; - protected IL10N $l; - protected LoggerInterface $logger; - - public function __construct(string $appName, IL10N $l, LoggerInterface $logger) { - $this->appName = $appName; - $this->l = $l; - $this->logger = $logger; + public function __construct( + protected string $appName, + protected IL10N $l, + protected LoggerInterface $logger, + ) { } /** diff --git a/apps/federation/lib/Settings/Admin.php b/apps/federation/lib/Settings/Admin.php index 67078bd6eb1..f9630c4b557 100644 --- a/apps/federation/lib/Settings/Admin.php +++ b/apps/federation/lib/Settings/Admin.php @@ -11,12 +11,10 @@ use OCP\IL10N; use OCP\Settings\IDelegatedSettings; class Admin implements IDelegatedSettings { - private TrustedServers $trustedServers; - private IL10N $l; - - public function __construct(TrustedServers $trustedServers, IL10N $l) { - $this->trustedServers = $trustedServers; - $this->l = $l; + public function __construct( + private TrustedServers $trustedServers, + private IL10N $l, + ) { } /** diff --git a/apps/federation/lib/SyncFederationAddressBooks.php b/apps/federation/lib/SyncFederationAddressBooks.php index 8060a78ada7..05144b40879 100644 --- a/apps/federation/lib/SyncFederationAddressBooks.php +++ b/apps/federation/lib/SyncFederationAddressBooks.php @@ -14,20 +14,15 @@ use OCP\OCS\IDiscoveryService; use Psr\Log\LoggerInterface; class SyncFederationAddressBooks { - protected DbHandler $dbHandler; - private SyncService $syncService; private DiscoveryService $ocsDiscoveryService; - private LoggerInterface $logger; - public function __construct(DbHandler $dbHandler, - SyncService $syncService, + public function __construct( + protected DbHandler $dbHandler, + private SyncService $syncService, IDiscoveryService $ocsDiscoveryService, - LoggerInterface $logger, + private LoggerInterface $logger, ) { - $this->syncService = $syncService; - $this->dbHandler = $dbHandler; $this->ocsDiscoveryService = $ocsDiscoveryService; - $this->logger = $logger; } /** diff --git a/apps/federation/lib/SyncJob.php b/apps/federation/lib/SyncJob.php index 7f41b20b921..21f8318f6f9 100644 --- a/apps/federation/lib/SyncJob.php +++ b/apps/federation/lib/SyncJob.php @@ -12,16 +12,15 @@ use OCP\BackgroundJob\TimedJob; use Psr\Log\LoggerInterface; class SyncJob extends TimedJob { - protected SyncFederationAddressBooks $syncService; - protected LoggerInterface $logger; - - public function __construct(SyncFederationAddressBooks $syncService, LoggerInterface $logger, ITimeFactory $timeFactory) { + public function __construct( + protected SyncFederationAddressBooks $syncService, + protected LoggerInterface $logger, + ITimeFactory $timeFactory, + ) { parent::__construct($timeFactory); // Run once a day $this->setInterval(24 * 60 * 60); $this->setTimeSensitivity(self::TIME_INSENSITIVE); - $this->syncService = $syncService; - $this->logger = $logger; } protected function run($argument) { diff --git a/apps/federation/lib/TrustedServers.php b/apps/federation/lib/TrustedServers.php index e59f281df0b..4b8ff5726c3 100644 --- a/apps/federation/lib/TrustedServers.php +++ b/apps/federation/lib/TrustedServers.php @@ -31,36 +31,19 @@ class TrustedServers { /** remote server revoked access */ public const STATUS_ACCESS_REVOKED = 4; - private DbHandler $dbHandler; - private IClientService $httpClientService; - private LoggerInterface $logger; - private IJobList $jobList; - private ISecureRandom $secureRandom; - private IConfig $config; - private IEventDispatcher $dispatcher; - private ITimeFactory $timeFactory; - /** @var list<array{id: int, url: string, url_hash: string, shared_secret: ?string, status: int, sync_token: ?string}>|null */ private ?array $trustedServersCache = null; public function __construct( - DbHandler $dbHandler, - IClientService $httpClientService, - LoggerInterface $logger, - IJobList $jobList, - ISecureRandom $secureRandom, - IConfig $config, - IEventDispatcher $dispatcher, - ITimeFactory $timeFactory, + private DbHandler $dbHandler, + private IClientService $httpClientService, + private LoggerInterface $logger, + private IJobList $jobList, + private ISecureRandom $secureRandom, + private IConfig $config, + private IEventDispatcher $dispatcher, + private ITimeFactory $timeFactory, ) { - $this->dbHandler = $dbHandler; - $this->httpClientService = $httpClientService; - $this->logger = $logger; - $this->jobList = $jobList; - $this->secureRandom = $secureRandom; - $this->config = $config; - $this->dispatcher = $dispatcher; - $this->timeFactory = $timeFactory; } /** diff --git a/apps/federation/tests/Controller/SettingsControllerTest.php b/apps/federation/tests/Controller/SettingsControllerTest.php index c2156bac3dc..a2969b510ad 100644 --- a/apps/federation/tests/Controller/SettingsControllerTest.php +++ b/apps/federation/tests/Controller/SettingsControllerTest.php @@ -18,10 +18,10 @@ use Test\TestCase; class SettingsControllerTest extends TestCase { private SettingsController $controller; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IRequest */ + /** @var \PHPUnit\Framework\MockObject\MockObject|IRequest */ private $request; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IL10N */ + /** @var \PHPUnit\Framework\MockObject\MockObject|IL10N */ private $l10n; /** @var \PHPUnit\Framework\MockObject\MockObject|TrustedServers */ diff --git a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php index d5ee241a85a..0ad619f8114 100644 --- a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php +++ b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php @@ -20,7 +20,7 @@ class AddServerMiddlewareTest extends TestCase { /** @var \PHPUnit\Framework\MockObject\MockObject | LoggerInterface */ private $logger; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IL10N */ + /** @var \PHPUnit\Framework\MockObject\MockObject|IL10N */ private $l10n; private AddServerMiddleware $middleware; 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()) diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index 4ba0e40ce46..761fc97b7aa 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -47,6 +47,7 @@ use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\AppFramework\QueryException; use OCP\Files\Config\IMountProviderCollection; use OCP\Group\Events\GroupDeletedEvent; use OCP\User\Events\UserDeletedEvent; @@ -62,7 +63,7 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide /** * Application constructor. * - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ public function __construct(array $urlParams = []) { parent::__construct(self::APP_ID, $urlParams); diff --git a/apps/files_external/lib/BackgroundJob/CredentialsCleanup.php b/apps/files_external/lib/BackgroundJob/CredentialsCleanup.php index 6d86c2f347b..90a5ae17ab2 100644 --- a/apps/files_external/lib/BackgroundJob/CredentialsCleanup.php +++ b/apps/files_external/lib/BackgroundJob/CredentialsCleanup.php @@ -18,22 +18,14 @@ use OCP\IUserManager; use OCP\Security\ICredentialsManager; class CredentialsCleanup extends TimedJob { - private $credentialsManager; - private $userGlobalStoragesService; - private $userManager; - public function __construct( ITimeFactory $time, - ICredentialsManager $credentialsManager, - UserGlobalStoragesService $userGlobalStoragesService, - IUserManager $userManager, + private ICredentialsManager $credentialsManager, + private UserGlobalStoragesService $userGlobalStoragesService, + private IUserManager $userManager, ) { parent::__construct($time); - $this->credentialsManager = $credentialsManager; - $this->userGlobalStoragesService = $userGlobalStoragesService; - $this->userManager = $userManager; - // run every day $this->setInterval(24 * 60 * 60); $this->setTimeSensitivity(self::TIME_INSENSITIVE); diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php index be435d4de2f..c84fbb19102 100644 --- a/apps/files_external/lib/Config/ConfigAdapter.php +++ b/apps/files_external/lib/Config/ConfigAdapter.php @@ -15,7 +15,9 @@ use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\MountConfig; use OCA\Files_External\Service\UserGlobalStoragesService; use OCA\Files_External\Service\UserStoragesService; +use OCP\AppFramework\QueryException; use OCP\Files\Config\IMountProvider; +use OCP\Files\Mount\IMountPoint; use OCP\Files\ObjectStore\IObjectStore; use OCP\Files\Storage\IConstructableStorage; use OCP\Files\Storage\IStorage; @@ -40,7 +42,7 @@ class ConfigAdapter implements IMountProvider { /** * Process storage ready for mounting * - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ private function prepareStorageConfig(StorageConfig &$storage, IUser $user): void { foreach ($storage->getBackendOptions() as $option => $value) { @@ -82,7 +84,7 @@ class ConfigAdapter implements IMountProvider { /** * Get all mountpoints applicable for the user * - * @return \OCP\Files\Mount\IMountPoint[] + * @return IMountPoint[] */ public function getMountsForUser(IUser $user, IStorageFactory $loader) { $this->userStoragesService->setUser($user); diff --git a/apps/files_external/lib/Config/ExternalMountPoint.php b/apps/files_external/lib/Config/ExternalMountPoint.php index fea1976780e..0dc2eab5120 100644 --- a/apps/files_external/lib/Config/ExternalMountPoint.php +++ b/apps/files_external/lib/Config/ExternalMountPoint.php @@ -11,11 +11,15 @@ use OCA\Files_External\Lib\StorageConfig; class ExternalMountPoint extends MountPoint { - /** @var StorageConfig */ - protected $storageConfig; - - public function __construct(StorageConfig $storageConfig, $storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) { - $this->storageConfig = $storageConfig; + public function __construct( + protected StorageConfig $storageConfig, + $storage, + $mountpoint, + $arguments = null, + $loader = null, + $mountOptions = null, + $mountId = null, + ) { parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId, ConfigAdapter::class); } diff --git a/apps/files_external/lib/Config/UserContext.php b/apps/files_external/lib/Config/UserContext.php index 5d9d2910ea2..55193c8ef24 100644 --- a/apps/files_external/lib/Config/UserContext.php +++ b/apps/files_external/lib/Config/UserContext.php @@ -14,26 +14,15 @@ use OCP\Share\IManager as ShareManager; class UserContext { - /** @var IUserSession */ - private $session; - - /** @var ShareManager */ - private $shareManager; - - /** @var IRequest */ - private $request; - /** @var string */ private $userId; - /** @var IUserManager */ - private $userManager; - - public function __construct(IUserSession $session, ShareManager $manager, IRequest $request, IUserManager $userManager) { - $this->session = $session; - $this->shareManager = $manager; - $this->request = $request; - $this->userManager = $userManager; + public function __construct( + private IUserSession $session, + private ShareManager $shareManager, + private IRequest $request, + private IUserManager $userManager, + ) { } public function getSession(): IUserSession { diff --git a/apps/files_external/lib/Controller/AjaxController.php b/apps/files_external/lib/Controller/AjaxController.php index dab7e092f00..dfc5947ed77 100644 --- a/apps/files_external/lib/Controller/AjaxController.php +++ b/apps/files_external/lib/Controller/AjaxController.php @@ -16,15 +16,6 @@ use OCP\IRequest; use OCP\IUserSession; class AjaxController extends Controller { - /** @var RSA */ - private $rsaMechanism; - /** @var GlobalAuth */ - private $globalAuth; - /** @var IUserSession */ - private $userSession; - /** @var IGroupManager */ - private $groupManager; - /** * @param string $appName * @param IRequest $request @@ -33,17 +24,15 @@ class AjaxController extends Controller { * @param IUserSession $userSession * @param IGroupManager $groupManager */ - public function __construct($appName, + public function __construct( + $appName, IRequest $request, - RSA $rsaMechanism, - GlobalAuth $globalAuth, - IUserSession $userSession, - IGroupManager $groupManager) { + private RSA $rsaMechanism, + private GlobalAuth $globalAuth, + private IUserSession $userSession, + private IGroupManager $groupManager, + ) { parent::__construct($appName, $request); - $this->rsaMechanism = $rsaMechanism; - $this->globalAuth = $globalAuth; - $this->userSession = $userSession; - $this->groupManager = $groupManager; } /** diff --git a/apps/files_external/lib/Controller/ApiController.php b/apps/files_external/lib/Controller/ApiController.php index cb8d8cbb0ff..5a7eddf1540 100644 --- a/apps/files_external/lib/Controller/ApiController.php +++ b/apps/files_external/lib/Controller/ApiController.php @@ -25,18 +25,13 @@ use OCP\IRequest; */ class ApiController extends OCSController { - private UserGlobalStoragesService $userGlobalStoragesService; - private UserStoragesService $userStoragesService; - public function __construct( string $appName, IRequest $request, - UserGlobalStoragesService $userGlobalStorageService, - UserStoragesService $userStorageService, + private UserGlobalStoragesService $userGlobalStoragesService, + private UserStoragesService $userStoragesService, ) { parent::__construct($appName, $request); - $this->userGlobalStoragesService = $userGlobalStorageService; - $this->userStoragesService = $userStorageService; } /** diff --git a/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php b/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php index f11dab2785f..ee23c28b993 100644 --- a/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php +++ b/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php @@ -21,12 +21,10 @@ class GlobalAuth extends AuthMechanism { public const CREDENTIALS_IDENTIFIER = 'password::global'; private const PWD_PLACEHOLDER = '************************'; - /** @var ICredentialsManager */ - protected $credentialsManager; - - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { - $this->credentialsManager = $credentialsManager; - + public function __construct( + IL10N $l, + protected ICredentialsManager $credentialsManager, + ) { $this ->setIdentifier('password::global') ->setVisibility(BackendService::VISIBILITY_DEFAULT) diff --git a/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php b/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php index 5c36f843307..176e1877d94 100644 --- a/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php +++ b/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php @@ -28,31 +28,14 @@ use OCP\User\Events\UserLoggedInEvent; class LoginCredentials extends AuthMechanism { public const CREDENTIALS_IDENTIFIER = 'password::logincredentials/credentials'; - /** @var ISession */ - protected $session; - - /** @var ICredentialsManager */ - protected $credentialsManager; - - /** @var CredentialsStore */ - private $credentialsStore; - - /** @var ILDAPProviderFactory */ - private $ldapFactory; - public function __construct( IL10N $l, - ISession $session, - ICredentialsManager $credentialsManager, - CredentialsStore $credentialsStore, + protected ISession $session, + protected ICredentialsManager $credentialsManager, + private CredentialsStore $credentialsStore, IEventDispatcher $eventDispatcher, - ILDAPProviderFactory $ldapFactory, + private ILDAPProviderFactory $ldapFactory, ) { - $this->session = $session; - $this->credentialsManager = $credentialsManager; - $this->credentialsStore = $credentialsStore; - $this->ldapFactory = $ldapFactory; - $this ->setIdentifier('password::logincredentials') ->setScheme(self::SCHEME_PASSWORD) diff --git a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php index 314ab82385e..ced43ebf357 100644 --- a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php +++ b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php @@ -22,12 +22,10 @@ use OCP\IUser; */ class SessionCredentials extends AuthMechanism { - /** @var CredentialsStore */ - private $credentialsStore; - - public function __construct(IL10N $l, CredentialsStore $credentialsStore) { - $this->credentialsStore = $credentialsStore; - + public function __construct( + IL10N $l, + private CredentialsStore $credentialsStore, + ) { $this->setIdentifier('password::sessioncredentials') ->setScheme(self::SCHEME_PASSWORD) ->setText($l->t('Log-in credentials, save in session')) diff --git a/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php b/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php index 84f2c698f07..cb7165261ac 100644 --- a/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php +++ b/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php @@ -23,12 +23,10 @@ use OCP\Security\ICredentialsManager; class UserGlobalAuth extends AuthMechanism { private const CREDENTIALS_IDENTIFIER = 'password::global'; - /** @var ICredentialsManager */ - protected $credentialsManager; - - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { - $this->credentialsManager = $credentialsManager; - + public function __construct( + IL10N $l, + protected ICredentialsManager $credentialsManager, + ) { $this ->setIdentifier('password::global::user') ->setVisibility(BackendService::VISIBILITY_DEFAULT) diff --git a/apps/files_external/lib/Lib/Auth/Password/UserProvided.php b/apps/files_external/lib/Lib/Auth/Password/UserProvided.php index a7c51d7353a..7f937cf14c1 100644 --- a/apps/files_external/lib/Lib/Auth/Password/UserProvided.php +++ b/apps/files_external/lib/Lib/Auth/Password/UserProvided.php @@ -22,12 +22,10 @@ use OCP\Security\ICredentialsManager; class UserProvided extends AuthMechanism implements IUserProvided { public const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/'; - /** @var ICredentialsManager */ - protected $credentialsManager; - - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { - $this->credentialsManager = $credentialsManager; - + public function __construct( + IL10N $l, + protected ICredentialsManager $credentialsManager, + ) { $this ->setIdentifier('password::userprovided') ->setVisibility(BackendService::VISIBILITY_ADMIN) diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php index 9b47cf72bb7..2371ce0a219 100644 --- a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php +++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php @@ -19,12 +19,10 @@ use phpseclib\Crypt\RSA as RSACrypt; */ class RSA extends AuthMechanism { - /** @var IConfig */ - private $config; - - public function __construct(IL10N $l, IConfig $config) { - $this->config = $config; - + public function __construct( + IL10N $l, + private IConfig $config, + ) { $this ->setIdentifier('publickey::rsa') ->setScheme(self::SCHEME_PUBLICKEY) diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php index ab770d25d09..8c2e2f3d6ec 100644 --- a/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php +++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php @@ -18,12 +18,10 @@ use phpseclib\Crypt\RSA as RSACrypt; */ class RSAPrivateKey extends AuthMechanism { - /** @var IConfig */ - private $config; - - public function __construct(IL10N $l, IConfig $config) { - $this->config = $config; - + public function __construct( + IL10N $l, + private IConfig $config, + ) { $this ->setIdentifier('publickey::rsa_private') ->setScheme(self::SCHEME_PUBLICKEY) diff --git a/apps/files_external/lib/Lib/Auth/SMB/KerberosApacheAuth.php b/apps/files_external/lib/Lib/Auth/SMB/KerberosApacheAuth.php index 7a6ecb08ae5..26671110294 100644 --- a/apps/files_external/lib/Lib/Auth/SMB/KerberosApacheAuth.php +++ b/apps/files_external/lib/Lib/Auth/SMB/KerberosApacheAuth.php @@ -13,10 +13,10 @@ use OCP\Authentication\LoginCredentials\IStore; use OCP\IL10N; class KerberosApacheAuth extends AuthMechanism { - /** @var IStore */ - private $credentialsStore; - - public function __construct(IL10N $l, IStore $credentialsStore) { + public function __construct( + IL10N $l, + private IStore $credentialsStore, + ) { $realm = new DefinitionParameter('default_realm', 'Default realm'); $realm ->setType(DefinitionParameter::VALUE_TEXT) @@ -27,7 +27,6 @@ class KerberosApacheAuth extends AuthMechanism { ->setScheme(self::SCHEME_SMB) ->setText($l->t('Kerberos ticket Apache mode')) ->addParameter($realm); - $this->credentialsStore = $credentialsStore; } public function getCredentialsStore(): IStore { diff --git a/apps/files_external/lib/Lib/Backend/InvalidBackend.php b/apps/files_external/lib/Lib/Backend/InvalidBackend.php index 22d0287244a..6082d46bd67 100644 --- a/apps/files_external/lib/Lib/Backend/InvalidBackend.php +++ b/apps/files_external/lib/Lib/Backend/InvalidBackend.php @@ -16,21 +16,19 @@ use OCP\IUser; */ class InvalidBackend extends Backend { - /** @var string Invalid backend id */ - private $invalidId; - /** * Constructs a new InvalidBackend with the id of the invalid backend * for display purposes * * @param string $invalidId id of the backend that did not exist */ - public function __construct($invalidId) { - $this->invalidId = $invalidId; + public function __construct( + private $invalidId, + ) { $this - ->setIdentifier($invalidId) + ->setIdentifier($this->invalidId) ->setStorageClass('\OC\Files\Storage\FailedStorage') - ->setText('Unknown storage backend ' . $invalidId); + ->setText('Unknown storage backend ' . $this->invalidId); } /** diff --git a/apps/files_external/lib/Lib/DefinitionParameter.php b/apps/files_external/lib/Lib/DefinitionParameter.php index 584fee1e498..1e611edd1ed 100644 --- a/apps/files_external/lib/Lib/DefinitionParameter.php +++ b/apps/files_external/lib/Lib/DefinitionParameter.php @@ -25,12 +25,6 @@ class DefinitionParameter implements \JsonSerializable { public const FLAG_OPTIONAL = 1; public const FLAG_USER_PROVIDED = 2; - /** @var string name of parameter */ - private string $name; - - /** @var string human-readable parameter text */ - private string $text; - /** @var string human-readable parameter tooltip */ private string $tooltip = ''; @@ -40,18 +34,16 @@ class DefinitionParameter implements \JsonSerializable { /** @var int flags, see self::FLAG_* constants */ private int $flags = self::FLAG_NONE; - /** @var mixed */ - private $defaultValue; - /** * @param string $name parameter name * @param string $text parameter description * @param mixed $defaultValue default value */ - public function __construct(string $name, string $text, $defaultValue = null) { - $this->name = $name; - $this->text = $text; - $this->defaultValue = $defaultValue; + public function __construct( + private string $name, + private string $text, + private $defaultValue = null, + ) { } /** diff --git a/apps/files_external/lib/Lib/MissingDependency.php b/apps/files_external/lib/Lib/MissingDependency.php index 9f48a523861..5c2c6880f23 100644 --- a/apps/files_external/lib/Lib/MissingDependency.php +++ b/apps/files_external/lib/Lib/MissingDependency.php @@ -11,17 +11,15 @@ namespace OCA\Files_External\Lib; */ class MissingDependency { - /** @var string */ - private $dependency; - /** @var string|null Custom message */ private $message = null; /** * @param string $dependency */ - public function __construct($dependency) { - $this->dependency = $dependency; + public function __construct( + private $dependency, + ) { } public function getDependency(): string { diff --git a/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php b/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php index 153cae1bd38..deaf005e2c6 100644 --- a/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php +++ b/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php @@ -12,11 +12,6 @@ use OCP\Files\Notify\INotifyHandler; class SMBNotifyHandler implements INotifyHandler { /** - * @var \Icewind\SMB\INotifyHandler - */ - private $shareNotifyHandler; - - /** * @var string */ private $root; @@ -29,8 +24,10 @@ class SMBNotifyHandler implements INotifyHandler { * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler * @param string $root */ - public function __construct(\Icewind\SMB\INotifyHandler $shareNotifyHandler, $root) { - $this->shareNotifyHandler = $shareNotifyHandler; + public function __construct( + private \Icewind\SMB\INotifyHandler $shareNotifyHandler, + $root, + ) { $this->root = str_replace('\\', '/', $root); } diff --git a/apps/files_external/lib/Lib/PersonalMount.php b/apps/files_external/lib/Lib/PersonalMount.php index 610807bc7a2..01daddd7e2a 100644 --- a/apps/files_external/lib/Lib/PersonalMount.php +++ b/apps/files_external/lib/Lib/PersonalMount.php @@ -10,30 +10,27 @@ use OC\Files\Mount\MoveableMount; use OCA\Files_External\Config\ExternalMountPoint; use OCA\Files_External\Service\UserStoragesService; use OCP\Files\Storage\IStorage; +use OCP\Files\Storage\IStorageFactory; /** * Person mount points can be moved by the user */ class PersonalMount extends ExternalMountPoint implements MoveableMount { - /** @var UserStoragesService */ - protected $storagesService; - - /** @var int id of the external storage (mount) (not the numeric id of the resulting storage!) */ - protected $numericExternalStorageId; - /** * @param UserStoragesService $storagesService * @param int $storageId * @param IStorage $storage * @param string $mountpoint * @param array $arguments (optional) configuration for the storage backend - * @param \OCP\Files\Storage\IStorageFactory $loader + * @param IStorageFactory $loader * @param array $mountOptions mount specific options + * @param int $externalStorageId */ public function __construct( - UserStoragesService $storagesService, + protected UserStoragesService $storagesService, StorageConfig $storageConfig, - $externalStorageId, + /** @var int id of the external storage (mount) (not the numeric id of the resulting storage!) */ + protected $numericExternalStorageId, $storage, $mountpoint, $arguments = null, @@ -42,8 +39,6 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount { $mountId = null, ) { parent::__construct($storageConfig, $storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId); - $this->storagesService = $storagesService; - $this->numericExternalStorageId = $externalStorageId; } /** diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index 985d51dccd8..70b62e56474 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -17,7 +17,10 @@ use OC\Files\ObjectStore\SwiftFactory; use OC\Files\Storage\Common; use OCP\Cache\CappedMemoryCache; use OCP\Files\IMimeTypeDetector; +use OCP\Files\StorageAuthException; use OCP\Files\StorageBadConfigException; +use OCP\Files\StorageNotAvailableException; +use OCP\ICache; use OpenStack\Common\Error\BadResponseError; use OpenStack\ObjectStore\v1\Models\Container; use OpenStack\ObjectStore\v1\Models\StorageObject; @@ -55,7 +58,7 @@ class Swift extends Common { * \OpenCloud\OpenStack\ObjectStorage\Resource\DataObject for existing * paths and path to false for not existing paths. * - * @var \OCP\ICache + * @var ICache */ private $objectCache; @@ -81,8 +84,8 @@ class Swift extends Common { * * @return StorageObject|false object * or false if the object did not exist - * @throws \OCP\Files\StorageAuthException - * @throws \OCP\Files\StorageNotAvailableException + * @throws StorageAuthException + * @throws StorageNotAvailableException */ private function fetchObject(string $path): StorageObject|false { $cached = $this->objectCache->get($path); @@ -112,8 +115,8 @@ class Swift extends Common { * Returns whether the given path exists. * * @return bool true if the object exist, false otherwise - * @throws \OCP\Files\StorageAuthException - * @throws \OCP\Files\StorageNotAvailableException + * @throws StorageAuthException + * @throws StorageNotAvailableException */ private function doesObjectExist(string $path): bool { return $this->fetchObject($path) !== false; @@ -534,8 +537,8 @@ class Swift extends Common { * Returns the initialized object store container. * * @return Container - * @throws \OCP\Files\StorageAuthException - * @throws \OCP\Files\StorageNotAvailableException + * @throws StorageAuthException + * @throws StorageNotAvailableException */ public function getContainer(): Container { if (is_null($this->container)) { diff --git a/apps/files_external/lib/Listener/GroupDeletedListener.php b/apps/files_external/lib/Listener/GroupDeletedListener.php index aced4961e38..244b3b2371f 100644 --- a/apps/files_external/lib/Listener/GroupDeletedListener.php +++ b/apps/files_external/lib/Listener/GroupDeletedListener.php @@ -15,11 +15,9 @@ use OCP\Group\Events\GroupDeletedEvent; /** @template-implements IEventListener<GroupDeletedEvent> */ class GroupDeletedListener implements IEventListener { - /** @var DBConfigService */ - private $config; - - public function __construct(DBConfigService $config) { - $this->config = $config; + public function __construct( + private DBConfigService $config, + ) { } public function handle(Event $event): void { diff --git a/apps/files_external/lib/Listener/StorePasswordListener.php b/apps/files_external/lib/Listener/StorePasswordListener.php index 52da5450f49..8580176b014 100644 --- a/apps/files_external/lib/Listener/StorePasswordListener.php +++ b/apps/files_external/lib/Listener/StorePasswordListener.php @@ -17,11 +17,9 @@ use OCP\User\Events\UserLoggedInEvent; /** @template-implements IEventListener<PasswordUpdatedEvent|UserLoggedInEvent> */ class StorePasswordListener implements IEventListener { - /** @var ICredentialsManager */ - private $credentialsManager; - - public function __construct(ICredentialsManager $credentialsManager) { - $this->credentialsManager = $credentialsManager; + public function __construct( + private ICredentialsManager $credentialsManager, + ) { } public function handle(Event $event): void { diff --git a/apps/files_external/lib/Listener/UserDeletedListener.php b/apps/files_external/lib/Listener/UserDeletedListener.php index 24139350ae9..337fd12f311 100644 --- a/apps/files_external/lib/Listener/UserDeletedListener.php +++ b/apps/files_external/lib/Listener/UserDeletedListener.php @@ -15,11 +15,9 @@ use OCP\User\Events\UserDeletedEvent; /** @template-implements IEventListener<UserDeletedEvent> */ class UserDeletedListener implements IEventListener { - /** @var DBConfigService */ - private $config; - - public function __construct(DBConfigService $config) { - $this->config = $config; + public function __construct( + private DBConfigService $config, + ) { } public function handle(Event $event): void { diff --git a/apps/files_external/lib/Migration/Version1015Date20211104103506.php b/apps/files_external/lib/Migration/Version1015Date20211104103506.php index 0cd8ffdf275..6027c795cdf 100644 --- a/apps/files_external/lib/Migration/Version1015Date20211104103506.php +++ b/apps/files_external/lib/Migration/Version1015Date20211104103506.php @@ -20,14 +20,10 @@ use Psr\Log\LoggerInterface; class Version1015Date20211104103506 extends SimpleMigrationStep { - /** @var IDBConnection */ - private $connection; - /** @var LoggerInterface */ - private $logger; - - public function __construct(IDBConnection $connection, LoggerInterface $logger) { - $this->connection = $connection; - $this->logger = $logger; + public function __construct( + private IDBConnection $connection, + private LoggerInterface $logger, + ) { } public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { @@ -64,7 +60,7 @@ class Version1015Date20211104103506 extends SimpleMigrationStep { /** * @throws Exception - * @return \OCP\DB\IResult|int + * @return IResult|int */ private function getS3Mounts() { $qb = $this->connection->getQueryBuilder(); diff --git a/apps/files_external/lib/MountConfig.php b/apps/files_external/lib/MountConfig.php index 744bdcacef3..ca14275ab13 100644 --- a/apps/files_external/lib/MountConfig.php +++ b/apps/files_external/lib/MountConfig.php @@ -6,6 +6,7 @@ */ namespace OCA\Files_External; +use OC\Files\Storage\Common; use OCA\Files_External\Config\IConfigHandler; use OCA\Files_External\Config\UserContext; use OCA\Files_External\Lib\Backend\Backend; @@ -13,6 +14,7 @@ use OCA\Files_External\Service\BackendService; use OCA\Files_External\Service\GlobalStoragesService; use OCA\Files_External\Service\UserGlobalStoragesService; use OCA\Files_External\Service\UserStoragesService; +use OCP\AppFramework\QueryException; use OCP\Files\StorageNotAvailableException; use OCP\IL10N; use OCP\Util; @@ -33,28 +35,18 @@ class MountConfig { // whether to skip backend test (for unit tests, as this static class is not mockable) public static $skipTest = false; - /** @var UserGlobalStoragesService */ - private $userGlobalStorageService; - /** @var UserStoragesService */ - private $userStorageService; - /** @var GlobalStoragesService */ - private $globalStorageService; - public function __construct( - UserGlobalStoragesService $userGlobalStorageService, - UserStoragesService $userStorageService, - GlobalStoragesService $globalStorageService, + private UserGlobalStoragesService $userGlobalStorageService, + private UserStoragesService $userStorageService, + private GlobalStoragesService $globalStorageService, ) { - $this->userGlobalStorageService = $userGlobalStorageService; - $this->userStorageService = $userStorageService; - $this->globalStorageService = $globalStorageService; } /** * @param mixed $input * @param string|null $userId * @return mixed - * @throws \OCP\AppFramework\QueryException + * @throws QueryException * @since 16.0.0 */ public static function substitutePlaceholdersInConfig($input, ?string $userId = null) { @@ -93,7 +85,7 @@ class MountConfig { } if (class_exists($class)) { try { - /** @var \OC\Files\Storage\Common $storage */ + /** @var Common $storage */ $storage = new $class($options); try { diff --git a/apps/files_external/lib/Service/BackendService.php b/apps/files_external/lib/Service/BackendService.php index a72179a3373..e37a0ab4649 100644 --- a/apps/files_external/lib/Service/BackendService.php +++ b/apps/files_external/lib/Service/BackendService.php @@ -32,9 +32,6 @@ class BackendService { /** Priority constants for PriorityTrait */ public const PRIORITY_DEFAULT = 100; - /** @var IConfig */ - protected $config; - /** @var bool */ private $userMountingAllowed = true; @@ -62,10 +59,8 @@ class BackendService { * @param IConfig $config */ public function __construct( - IConfig $config, + protected IConfig $config, ) { - $this->config = $config; - // Load config values if ($this->config->getAppValue('files_external', 'allow_user_mounting', 'yes') !== 'yes') { $this->userMountingAllowed = false; diff --git a/apps/files_external/lib/Service/StoragesService.php b/apps/files_external/lib/Service/StoragesService.php index 12bf074a095..88b9cf78ec3 100644 --- a/apps/files_external/lib/Service/StoragesService.php +++ b/apps/files_external/lib/Service/StoragesService.php @@ -27,37 +27,18 @@ use Psr\Log\LoggerInterface; */ abstract class StoragesService { - /** @var BackendService */ - protected $backendService; - - /** - * @var DBConfigService - */ - protected $dbConfig; - - /** - * @var IUserMountCache - */ - protected $userMountCache; - - protected IEventDispatcher $eventDispatcher; - /** * @param BackendService $backendService - * @param DBConfigService $dbConfigService + * @param DBConfigService $dbConfig * @param IUserMountCache $userMountCache * @param IEventDispatcher $eventDispatcher */ public function __construct( - BackendService $backendService, - DBConfigService $dbConfigService, - IUserMountCache $userMountCache, - IEventDispatcher $eventDispatcher, + protected BackendService $backendService, + protected DBConfigService $dbConfig, + protected IUserMountCache $userMountCache, + protected IEventDispatcher $eventDispatcher, ) { - $this->backendService = $backendService; - $this->dbConfig = $dbConfigService; - $this->userMountCache = $userMountCache; - $this->eventDispatcher = $eventDispatcher; } protected function readDBConfig() { diff --git a/apps/files_external/lib/Service/UserGlobalStoragesService.php b/apps/files_external/lib/Service/UserGlobalStoragesService.php index 6fc37ea99b3..01bc91ef3ff 100644 --- a/apps/files_external/lib/Service/UserGlobalStoragesService.php +++ b/apps/files_external/lib/Service/UserGlobalStoragesService.php @@ -20,9 +20,6 @@ use OCP\IUserSession; class UserGlobalStoragesService extends GlobalStoragesService { use UserTrait; - /** @var IGroupManager */ - protected $groupManager; - /** * @param BackendService $backendService * @param DBConfigService $dbConfig @@ -35,13 +32,12 @@ class UserGlobalStoragesService extends GlobalStoragesService { BackendService $backendService, DBConfigService $dbConfig, IUserSession $userSession, - IGroupManager $groupManager, + protected IGroupManager $groupManager, IUserMountCache $userMountCache, IEventDispatcher $eventDispatcher, ) { parent::__construct($backendService, $dbConfig, $userMountCache, $eventDispatcher); $this->userSession = $userSession; - $this->groupManager = $groupManager; } /** diff --git a/apps/files_external/lib/Settings/Admin.php b/apps/files_external/lib/Settings/Admin.php index 41f2c43b5f1..8476e87f3c6 100644 --- a/apps/files_external/lib/Settings/Admin.php +++ b/apps/files_external/lib/Settings/Admin.php @@ -15,28 +15,12 @@ use OCP\Settings\ISettings; class Admin implements ISettings { - /** @var IManager */ - private $encryptionManager; - - /** @var GlobalStoragesService */ - private $globalStoragesService; - - /** @var BackendService */ - private $backendService; - - /** @var GlobalAuth */ - private $globalAuth; - public function __construct( - IManager $encryptionManager, - GlobalStoragesService $globalStoragesService, - BackendService $backendService, - GlobalAuth $globalAuth, + private IManager $encryptionManager, + private GlobalStoragesService $globalStoragesService, + private BackendService $backendService, + private GlobalAuth $globalAuth, ) { - $this->encryptionManager = $encryptionManager; - $this->globalStoragesService = $globalStoragesService; - $this->backendService = $backendService; - $this->globalAuth = $globalAuth; } /** diff --git a/apps/files_external/lib/Settings/Personal.php b/apps/files_external/lib/Settings/Personal.php index 186b2638e1f..f691c14270e 100644 --- a/apps/files_external/lib/Settings/Personal.php +++ b/apps/files_external/lib/Settings/Personal.php @@ -16,33 +16,13 @@ use OCP\Settings\ISettings; class Personal implements ISettings { - /** @var IManager */ - private $encryptionManager; - - /** @var UserGlobalStoragesService */ - private $userGlobalStoragesService; - - /** @var BackendService */ - private $backendService; - - /** @var GlobalAuth */ - private $globalAuth; - - /** @var IUserSession */ - private $userSession; - public function __construct( - IManager $encryptionManager, - UserGlobalStoragesService $userGlobalStoragesService, - BackendService $backendService, - GlobalAuth $globalAuth, - IUserSession $userSession, + private IManager $encryptionManager, + private UserGlobalStoragesService $userGlobalStoragesService, + private BackendService $backendService, + private GlobalAuth $globalAuth, + private IUserSession $userSession, ) { - $this->encryptionManager = $encryptionManager; - $this->userGlobalStoragesService = $userGlobalStoragesService; - $this->backendService = $backendService; - $this->globalAuth = $globalAuth; - $this->userSession = $userSession; } /** diff --git a/apps/files_external/lib/Settings/PersonalSection.php b/apps/files_external/lib/Settings/PersonalSection.php index f72ef95ad7f..df494edce27 100644 --- a/apps/files_external/lib/Settings/PersonalSection.php +++ b/apps/files_external/lib/Settings/PersonalSection.php @@ -12,25 +12,13 @@ use OCP\IURLGenerator; use OCP\IUserSession; class PersonalSection extends Section { - /** @var IUserSession */ - private $userSession; - - /** @var UserGlobalStoragesService */ - private $userGlobalStoragesService; - - /** @var BackendService */ - private $backendService; - public function __construct( IURLGenerator $url, IL10N $l, - IUserSession $userSession, - UserGlobalStoragesService $userGlobalStoragesService, - BackendService $backendService, + private IUserSession $userSession, + private UserGlobalStoragesService $userGlobalStoragesService, + private BackendService $backendService, ) { parent::__construct($url, $l); - $this->userSession = $userSession; - $this->userGlobalStoragesService = $userGlobalStoragesService; - $this->backendService = $backendService; } } diff --git a/apps/files_external/lib/Settings/Section.php b/apps/files_external/lib/Settings/Section.php index 9bf5c092e57..8bc0814bb67 100644 --- a/apps/files_external/lib/Settings/Section.php +++ b/apps/files_external/lib/Settings/Section.php @@ -10,18 +10,14 @@ use OCP\IURLGenerator; use OCP\Settings\IIconSection; class Section implements IIconSection { - /** @var IL10N */ - private $l; - /** @var IURLGenerator */ - private $url; - /** * @param IURLGenerator $url * @param IL10N $l */ - public function __construct(IURLGenerator $url, IL10N $l) { - $this->url = $url; - $this->l = $l; + public function __construct( + private IURLGenerator $url, + private IL10N $l, + ) { } /** diff --git a/apps/files_external/tests/Auth/Password/GlobalAuth.php b/apps/files_external/tests/Auth/Password/GlobalAuth.php index aa28083e09e..998db198b53 100644 --- a/apps/files_external/tests/Auth/Password/GlobalAuth.php +++ b/apps/files_external/tests/Auth/Password/GlobalAuth.php @@ -15,12 +15,12 @@ use Test\TestCase; class GlobalAuthTest extends TestCase { /** - * @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject + * @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ private $l10n; /** - * @var \OCP\Security\ICredentialsManager|\PHPUnit\Framework\MockObject\MockObject + * @var ICredentialsManager|\PHPUnit\Framework\MockObject\MockObject */ private $credentialsManager; diff --git a/apps/files_external/tests/Command/ApplicableTest.php b/apps/files_external/tests/Command/ApplicableTest.php index 223b02706e5..8854e4ad485 100644 --- a/apps/files_external/tests/Command/ApplicableTest.php +++ b/apps/files_external/tests/Command/ApplicableTest.php @@ -12,9 +12,9 @@ use OCP\IUserManager; class ApplicableTest extends CommandTest { private function getInstance($storageService) { - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */ + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */ $userManager = $this->createMock(IUserManager::class); - /** @var \OCP\IGroupManager|\PHPUnit\Framework\MockObject\MockObject $groupManager */ + /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject $groupManager */ $groupManager = $this->createMock(IGroupManager::class); $userManager->expects($this->any()) diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php index 59907b07d6a..e7644d8e523 100644 --- a/apps/files_external/tests/Service/BackendServiceTest.php +++ b/apps/files_external/tests/Service/BackendServiceTest.php @@ -16,7 +16,7 @@ use OCP\IConfig; class BackendServiceTest extends \Test\TestCase { - /** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ protected $config; protected function setUp(): void { diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php index a4e823ab6f0..797d4382ae9 100644 --- a/apps/files_external/tests/Service/StoragesServiceTest.php +++ b/apps/files_external/tests/Service/StoragesServiceTest.php @@ -76,7 +76,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { protected static $hookCalls; /** - * @var \PHPUnit\Framework\MockObject\MockObject|\OCP\Files\Config\IUserMountCache + * @var \PHPUnit\Framework\MockObject\MockObject|IUserMountCache */ protected $mountCache; diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php index 7aef65cebee..571664b32c8 100644 --- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php @@ -23,7 +23,7 @@ use Test\Traits\UserTrait; class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { use UserTrait; - /** @var \OCP\IGroupManager|\PHPUnit\Framework\MockObject\MockObject groupManager */ + /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject groupManager */ protected $groupManager; /** @@ -48,7 +48,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { $this->globalStoragesService = $this->service; $this->user = new User(self::USER_ID, null, \OC::$server->get(IEventDispatcher::class)); - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */ + /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */ $userSession = $this->createMock(IUserSession::class); $userSession ->expects($this->any()) diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php index 4a4404839a4..7bf101ebfc4 100644 --- a/apps/files_external/tests/Service/UserStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php @@ -41,7 +41,7 @@ class UserStoragesServiceTest extends StoragesServiceTest { $this->createUser($this->userId, $this->userId); $this->user = \OC::$server->getUserManager()->get($this->userId); - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */ + /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */ $userSession = $this->createMock(IUserSession::class); $userSession ->expects($this->any()) 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 { diff --git a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php index b5980b27c0a..4e1c1b95fde 100644 --- a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php +++ b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php @@ -17,23 +17,15 @@ use OCP\IUser; use OCP\IUserManager; class ExpireTrash extends TimedJob { - private IConfig $config; - private Expiration $expiration; - private IUserManager $userManager; - public function __construct( - IConfig $config, - IUserManager $userManager, - Expiration $expiration, + private IConfig $config, + private IUserManager $userManager, + private Expiration $expiration, ITimeFactory $time, ) { parent::__construct($time); // Run once per 30 minutes $this->setInterval(60 * 30); - - $this->config = $config; - $this->userManager = $userManager; - $this->expiration = $expiration; } /** diff --git a/apps/files_trashbin/lib/Command/Expire.php b/apps/files_trashbin/lib/Command/Expire.php index b31e540ee38..f526438600e 100644 --- a/apps/files_trashbin/lib/Command/Expire.php +++ b/apps/files_trashbin/lib/Command/Expire.php @@ -14,15 +14,11 @@ class Expire implements ICommand { use FileAccess; /** - * @var string - */ - private $user; - - /** * @param string $user */ - public function __construct($user) { - $this->user = $user; + public function __construct( + private $user, + ) { } public function handle() { diff --git a/apps/files_trashbin/lib/Command/ExpireTrash.php b/apps/files_trashbin/lib/Command/ExpireTrash.php index c27d74c0c26..37b35689666 100644 --- a/apps/files_trashbin/lib/Command/ExpireTrash.php +++ b/apps/files_trashbin/lib/Command/ExpireTrash.php @@ -21,25 +21,14 @@ use Symfony\Component\Console\Output\OutputInterface; class ExpireTrash extends Command { /** - * @var Expiration - */ - private $expiration; - - /** - * @var IUserManager - */ - private $userManager; - - /** * @param IUserManager|null $userManager * @param Expiration|null $expiration */ - public function __construct(?IUserManager $userManager = null, - ?Expiration $expiration = null) { + public function __construct( + private ?IUserManager $userManager = null, + private ?Expiration $expiration = null, + ) { parent::__construct(); - - $this->userManager = $userManager; - $this->expiration = $expiration; } protected function configure() { diff --git a/apps/files_trashbin/lib/Command/RestoreAllFiles.php b/apps/files_trashbin/lib/Command/RestoreAllFiles.php index 81b59543a4e..cb4e7f97ecd 100644 --- a/apps/files_trashbin/lib/Command/RestoreAllFiles.php +++ b/apps/files_trashbin/lib/Command/RestoreAllFiles.php @@ -32,17 +32,6 @@ class RestoreAllFiles extends Base { 'all' => self::SCOPE_ALL ]; - /** @var IUserManager */ - protected $userManager; - - /** @var IRootFolder */ - protected $rootFolder; - - /** @var \OCP\IDBConnection */ - protected $dbConnection; - - protected ITrashManager $trashManager; - /** @var IL10N */ protected $l10n; @@ -53,12 +42,14 @@ class RestoreAllFiles extends Base { * @param ITrashManager $trashManager * @param IFactory $l10nFactory */ - public function __construct(IRootFolder $rootFolder, IUserManager $userManager, IDBConnection $dbConnection, ITrashManager $trashManager, IFactory $l10nFactory) { + public function __construct( + protected IRootFolder $rootFolder, + protected IUserManager $userManager, + protected IDBConnection $dbConnection, + protected ITrashManager $trashManager, + IFactory $l10nFactory, + ) { parent::__construct(); - $this->userManager = $userManager; - $this->rootFolder = $rootFolder; - $this->dbConnection = $dbConnection; - $this->trashManager = $trashManager; $this->l10n = $l10nFactory->get('files_trashbin'); } diff --git a/apps/files_trashbin/lib/Command/Size.php b/apps/files_trashbin/lib/Command/Size.php index 60b1f0981fa..11699ce25ea 100644 --- a/apps/files_trashbin/lib/Command/Size.php +++ b/apps/files_trashbin/lib/Command/Size.php @@ -19,20 +19,12 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Size extends Base { - private $config; - private $userManager; - private $commandBus; - public function __construct( - IConfig $config, - IUserManager $userManager, - IBus $commandBus, + private IConfig $config, + private IUserManager $userManager, + private IBus $commandBus, ) { parent::__construct(); - - $this->config = $config; - $this->userManager = $userManager; - $this->commandBus = $commandBus; } protected function configure() { diff --git a/apps/files_trashbin/lib/Controller/PreviewController.php b/apps/files_trashbin/lib/Controller/PreviewController.php index 78d501b68d4..d376ce80fda 100644 --- a/apps/files_trashbin/lib/Controller/PreviewController.php +++ b/apps/files_trashbin/lib/Controller/PreviewController.php @@ -25,42 +25,17 @@ use OCP\IRequest; use OCP\IUserSession; class PreviewController extends Controller { - /** @var IRootFolder */ - private $rootFolder; - - /** @var ITrashManager */ - private $trashManager; - - /** @var IUserSession */ - private $userSession; - - /** @var IMimeTypeDetector */ - private $mimeTypeDetector; - - /** @var IPreview */ - private $previewManager; - - /** @var ITimeFactory */ - private $time; - public function __construct( string $appName, IRequest $request, - IRootFolder $rootFolder, - ITrashManager $trashManager, - IUserSession $userSession, - IMimeTypeDetector $mimeTypeDetector, - IPreview $previewManager, - ITimeFactory $time, + private IRootFolder $rootFolder, + private ITrashManager $trashManager, + private IUserSession $userSession, + private IMimeTypeDetector $mimeTypeDetector, + private IPreview $previewManager, + private ITimeFactory $time, ) { parent::__construct($appName, $request); - - $this->trashManager = $trashManager; - $this->rootFolder = $rootFolder; - $this->userSession = $userSession; - $this->mimeTypeDetector = $mimeTypeDetector; - $this->previewManager = $previewManager; - $this->time = $time; } /** diff --git a/apps/files_trashbin/lib/Events/MoveToTrashEvent.php b/apps/files_trashbin/lib/Events/MoveToTrashEvent.php index ff54c67e178..1596315dd20 100644 --- a/apps/files_trashbin/lib/Events/MoveToTrashEvent.php +++ b/apps/files_trashbin/lib/Events/MoveToTrashEvent.php @@ -21,12 +21,10 @@ class MoveToTrashEvent extends Event { /** @var bool */ private $moveToTrashBin; - /** @var Node */ - private $node; - - public function __construct(Node $node) { + public function __construct( + private Node $node, + ) { $this->moveToTrashBin = true; - $this->node = $node; } /** diff --git a/apps/files_trashbin/lib/Expiration.php b/apps/files_trashbin/lib/Expiration.php index 26826f63931..ed5d62aa294 100644 --- a/apps/files_trashbin/lib/Expiration.php +++ b/apps/files_trashbin/lib/Expiration.php @@ -15,9 +15,6 @@ class Expiration { public const DEFAULT_RETENTION_OBLIGATION = 30; public const NO_OBLIGATION = -1; - /** @var ITimeFactory */ - private $timeFactory; - /** @var string */ private $retentionObligation; @@ -30,8 +27,10 @@ class Expiration { /** @var bool */ private $canPurgeToSaveSpace; - public function __construct(IConfig $config, ITimeFactory $timeFactory) { - $this->timeFactory = $timeFactory; + public function __construct( + IConfig $config, + private ITimeFactory $timeFactory, + ) { $this->setRetentionObligation($config->getSystemValue('trashbin_retention_obligation', 'auto')); } diff --git a/apps/files_trashbin/lib/Listener/EventListener.php b/apps/files_trashbin/lib/Listener/EventListener.php index 7568524e853..63ecc9c81f7 100644 --- a/apps/files_trashbin/lib/Listener/EventListener.php +++ b/apps/files_trashbin/lib/Listener/EventListener.php @@ -19,10 +19,9 @@ use OCP\User\Events\BeforeUserDeletedEvent; /** @template-implements IEventListener<NodeWrittenEvent|BeforeUserDeletedEvent|BeforeFileSystemSetupEvent> */ class EventListener implements IEventListener { - private ?string $userId; - - public function __construct(?string $userId = null) { - $this->userId = $userId; + public function __construct( + private ?string $userId = null, + ) { } public function handle(Event $event): void { diff --git a/apps/files_trashbin/lib/Sabre/AbstractTrash.php b/apps/files_trashbin/lib/Sabre/AbstractTrash.php index e46a7d5d638..343c8b6be6d 100644 --- a/apps/files_trashbin/lib/Sabre/AbstractTrash.php +++ b/apps/files_trashbin/lib/Sabre/AbstractTrash.php @@ -14,15 +14,10 @@ use OCP\Files\FileInfo; use OCP\IUser; abstract class AbstractTrash implements ITrash { - /** @var ITrashItem */ - protected $data; - - /** @var ITrashManager */ - protected $trashManager; - - public function __construct(ITrashManager $trashManager, ITrashItem $data) { - $this->trashManager = $trashManager; - $this->data = $data; + public function __construct( + protected ITrashManager $trashManager, + protected ITrashItem $data, + ) { } public function getFilename(): string { diff --git a/apps/files_trashbin/lib/Sabre/RootCollection.php b/apps/files_trashbin/lib/Sabre/RootCollection.php index 11c44266c3d..06b0ffbeba2 100644 --- a/apps/files_trashbin/lib/Sabre/RootCollection.php +++ b/apps/files_trashbin/lib/Sabre/RootCollection.php @@ -15,17 +15,12 @@ use Sabre\DAVACL\AbstractPrincipalCollection; use Sabre\DAVACL\PrincipalBackend; class RootCollection extends AbstractPrincipalCollection { - /** @var ITrashManager */ - private $trashManager; - public function __construct( - ITrashManager $trashManager, + private ITrashManager $trashManager, PrincipalBackend\BackendInterface $principalBackend, IConfig $config, ) { parent::__construct($principalBackend, 'principals/users'); - - $this->trashManager = $trashManager; $this->disableListing = !$config->getSystemValue('debug', false); } diff --git a/apps/files_trashbin/lib/Sabre/TrashHome.php b/apps/files_trashbin/lib/Sabre/TrashHome.php index 2c7fe749be5..fc291c76f17 100644 --- a/apps/files_trashbin/lib/Sabre/TrashHome.php +++ b/apps/files_trashbin/lib/Sabre/TrashHome.php @@ -15,23 +15,11 @@ use Sabre\DAV\Exception\NotFound; use Sabre\DAV\ICollection; class TrashHome implements ICollection { - /** @var ITrashManager */ - private $trashManager; - - /** @var array */ - private $principalInfo; - - /** @var IUser */ - private $user; - public function __construct( - array $principalInfo, - ITrashManager $trashManager, - IUser $user, + private array $principalInfo, + private ITrashManager $trashManager, + private IUser $user, ) { - $this->principalInfo = $principalInfo; - $this->trashManager = $trashManager; - $this->user = $user; } public function delete() { diff --git a/apps/files_trashbin/lib/Sabre/TrashRoot.php b/apps/files_trashbin/lib/Sabre/TrashRoot.php index e2661ccdec7..d6a4f5cc67e 100644 --- a/apps/files_trashbin/lib/Sabre/TrashRoot.php +++ b/apps/files_trashbin/lib/Sabre/TrashRoot.php @@ -19,15 +19,10 @@ use Sabre\DAV\ICollection; class TrashRoot implements ICollection { - /** @var IUser */ - private $user; - - /** @var ITrashManager */ - private $trashManager; - - public function __construct(IUser $user, ITrashManager $trashManager) { - $this->user = $user; - $this->trashManager = $trashManager; + public function __construct( + private IUser $user, + private ITrashManager $trashManager, + ) { } public function delete() { diff --git a/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php b/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php index 83564d2a783..b2864e9a1c6 100644 --- a/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php +++ b/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php @@ -28,13 +28,9 @@ class TrashbinPlugin extends ServerPlugin { /** @var Server */ private $server; - /** @var IPreview */ - private $previewManager; - public function __construct( - IPreview $previewManager, + private IPreview $previewManager, ) { - $this->previewManager = $previewManager; } public function initialize(Server $server) { diff --git a/apps/files_trashbin/lib/Storage.php b/apps/files_trashbin/lib/Storage.php index 5703f3be527..a1247eaed78 100644 --- a/apps/files_trashbin/lib/Storage.php +++ b/apps/files_trashbin/lib/Storage.php @@ -20,11 +20,6 @@ use Psr\Log\LoggerInterface; class Storage extends Wrapper { private string $mountPoint; - private IUserManager $userManager; - private LoggerInterface $logger; - private IEventDispatcher $eventDispatcher; - private IRootFolder $rootFolder; - private ITrashManager $trashManager; private bool $trashEnabled = true; /** @@ -33,18 +28,13 @@ class Storage extends Wrapper { */ public function __construct( $parameters, - ?ITrashManager $trashManager = null, - ?IUserManager $userManager = null, - ?LoggerInterface $logger = null, - ?IEventDispatcher $eventDispatcher = null, - ?IRootFolder $rootFolder = null, + private ?ITrashManager $trashManager = null, + private ?IUserManager $userManager = null, + private ?LoggerInterface $logger = null, + private ?IEventDispatcher $eventDispatcher = null, + private ?IRootFolder $rootFolder = null, ) { $this->mountPoint = $parameters['mountPoint']; - $this->trashManager = $trashManager; - $this->userManager = $userManager; - $this->logger = $logger; - $this->eventDispatcher = $eventDispatcher; - $this->rootFolder = $rootFolder; parent::__construct($parameters); } diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index f6e5a3830ad..f6791f78a38 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -14,6 +14,7 @@ use OC\Files\Filesystem; use OC\Files\Node\NonExistingFile; use OC\Files\Node\NonExistingFolder; use OC\Files\View; +use OC\User\NoUserException; use OC_User; use OCA\Files_Trashbin\AppInfo\Application; use OCA\Files_Trashbin\Command\Expire; @@ -67,7 +68,7 @@ class Trashbin implements IEventListener { * * @param string $filename * @return array - * @throws \OC\User\NoUserException + * @throws NoUserException */ public static function getUidAndFilename($filename) { $uid = Filesystem::getOwner($filename); diff --git a/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php b/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php index b58efbb38a6..baff1ef6032 100644 --- a/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php +++ b/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php @@ -32,20 +32,11 @@ class TrashbinMigrator implements IMigrator, ISizeEstimationMigrator { protected const PATH_FILES_FOLDER = Application::APP_ID . '/files'; protected const PATH_LOCATIONS_FILE = Application::APP_ID . '/locations.json'; - protected IRootFolder $root; - - protected IDBConnection $dbc; - - protected IL10N $l10n; - public function __construct( - IRootFolder $rootFolder, - IDBConnection $dbc, - IL10N $l10n, + protected IRootFolder $root, + protected IDBConnection $dbc, + protected IL10N $l10n, ) { - $this->root = $rootFolder; - $this->dbc = $dbc; - $this->l10n = $l10n; } /** diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php index 0d56ecf0a71..ec01e16b16a 100644 --- a/apps/files_trashbin/tests/StorageTest.php +++ b/apps/files_trashbin/tests/StorageTest.php @@ -55,12 +55,12 @@ class StorageTest extends \Test\TestCase { private $user; /** - * @var \OC\Files\View + * @var View */ private $rootView; /** - * @var \OC\Files\View + * @var View */ private $userView; @@ -502,7 +502,7 @@ class StorageTest extends \Test\TestCase { */ public function testSingleStorageDeleteFileFail(): void { /** - * @var \OC\Files\Storage\Temporary | \PHPUnit\Framework\MockObject\MockObject $storage + * @var Temporary|\PHPUnit\Framework\MockObject\MockObject $storage */ $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary') ->setConstructorArgs([[]]) @@ -539,7 +539,7 @@ class StorageTest extends \Test\TestCase { */ public function testSingleStorageDeleteFolderFail(): void { /** - * @var \OC\Files\Storage\Temporary | \PHPUnit\Framework\MockObject\MockObject $storage + * @var Temporary|\PHPUnit\Framework\MockObject\MockObject $storage */ $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary') ->setConstructorArgs([[]]) diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php index 72aa9b280e8..ea9abedd144 100644 --- a/apps/files_trashbin/tests/TrashbinTest.php +++ b/apps/files_trashbin/tests/TrashbinTest.php @@ -18,6 +18,7 @@ use OCA\Files_Trashbin\Helper; use OCA\Files_Trashbin\Trashbin; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Constants; +use OCP\Files\FileInfo; use OCP\IConfig; use OCP\Share\IShare; @@ -41,7 +42,7 @@ class TrashbinTest extends \Test\TestCase { private static $trashBinStatus; /** - * @var \OC\Files\View + * @var View */ private $rootView; @@ -159,7 +160,7 @@ class TrashbinTest extends \Test\TestCase { */ public function testExpireOldFiles(): void { - /** @var \OCP\AppFramework\Utility\ITimeFactory $time */ + /** @var ITimeFactory $time */ $time = \OC::$server->query(ITimeFactory::class); $currentTime = $time->getTime(); $expireAt = $currentTime - 2 * 24 * 60 * 60; @@ -282,7 +283,7 @@ class TrashbinTest extends \Test\TestCase { /** * verify that the array contains the expected results * - * @param OCP\Files\FileInfo[] $result + * @param FileInfo[] $result * @param string[] $expected */ private function verifyArray($result, $expected) { @@ -303,7 +304,7 @@ class TrashbinTest extends \Test\TestCase { } /** - * @param OCP\Files\FileInfo[] $files + * @param FileInfo[] $files * @param string $trashRoot * @param integer $expireDate */ @@ -374,7 +375,7 @@ class TrashbinTest extends \Test\TestCase { $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime'); $this->assertCount(1, $filesInTrash); - /** @var \OCP\Files\FileInfo */ + /** @var FileInfo */ $trashedFile = $filesInTrash[0]; $this->assertTrue( @@ -407,7 +408,7 @@ class TrashbinTest extends \Test\TestCase { $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime'); $this->assertCount(1, $filesInTrash); - /** @var \OCP\Files\FileInfo */ + /** @var FileInfo */ $trashedFile = $filesInTrash[0]; $this->assertTrue( @@ -440,7 +441,7 @@ class TrashbinTest extends \Test\TestCase { $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime'); $this->assertCount(1, $filesInTrash); - /** @var \OCP\Files\FileInfo */ + /** @var FileInfo */ $trashedFolder = $filesInTrash[0]; $this->assertTrue( @@ -473,7 +474,7 @@ class TrashbinTest extends \Test\TestCase { $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime'); $this->assertCount(1, $filesInTrash); - /** @var \OCP\Files\FileInfo */ + /** @var FileInfo */ $trashedFile = $filesInTrash[0]; $this->assertTrue( @@ -507,7 +508,7 @@ class TrashbinTest extends \Test\TestCase { $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime'); $this->assertCount(1, $filesInTrash); - /** @var \OCP\Files\FileInfo */ + /** @var FileInfo */ $trashedFile = $filesInTrash[0]; // delete source folder @@ -543,7 +544,7 @@ class TrashbinTest extends \Test\TestCase { $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime'); $this->assertCount(1, $filesInTrash); - /** @var \OCP\Files\FileInfo */ + /** @var FileInfo */ $trashedFile = $filesInTrash[0]; // create another file @@ -584,7 +585,7 @@ class TrashbinTest extends \Test\TestCase { $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime'); $this->assertCount(1, $filesInTrash); - /** @var \OCP\Files\FileInfo */ + /** @var FileInfo */ $trashedFile = $filesInTrash[0]; // create another file @@ -638,7 +639,7 @@ class TrashbinTest extends \Test\TestCase { $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime'); $this->assertCount(1, $filesInTrash); - /** @var \OCP\Files\FileInfo */ + /** @var FileInfo */ $trashedFile = $filesInTrash[0]; // delete source folder @@ -689,7 +690,7 @@ class TrashbinTest extends \Test\TestCase { class TrashbinForTesting extends Trashbin { /** - * @param OCP\Files\FileInfo[] $files + * @param FileInfo[] $files * @param integer $limit */ public function dummyDeleteExpiredFiles($files) { @@ -698,7 +699,7 @@ class TrashbinForTesting extends Trashbin { } /** - * @param OCP\Files\FileInfo[] $files + * @param FileInfo[] $files * @param integer $availableSpace */ public function dummyDeleteFiles($files, $availableSpace) { diff --git a/apps/files_versions/appinfo/routes.php b/apps/files_versions/appinfo/routes.php index cc853d31742..09aa3c7a3ec 100644 --- a/apps/files_versions/appinfo/routes.php +++ b/apps/files_versions/appinfo/routes.php @@ -6,6 +6,8 @@ */ namespace OCA\Files_Versions\AppInfo; +use OCP\Route\IRouter; + /** @var Application $application */ $application = \OC::$server->query(Application::class); $application->registerRoutes($this, [ @@ -18,7 +20,7 @@ $application->registerRoutes($this, [ ], ]); -/** @var \OCP\Route\IRouter $this */ +/** @var IRouter $this */ $this->create('files_versions_download', 'apps/files_versions/download.php') ->actionInclude('files_versions/download.php'); $this->create('files_versions_ajax_getVersions', 'apps/files_versions/ajax/getVersions.php') diff --git a/apps/files_versions/lib/BackgroundJob/ExpireVersions.php b/apps/files_versions/lib/BackgroundJob/ExpireVersions.php index 0df87d7d83b..6de29364835 100644 --- a/apps/files_versions/lib/BackgroundJob/ExpireVersions.php +++ b/apps/files_versions/lib/BackgroundJob/ExpireVersions.php @@ -18,18 +18,15 @@ use OCP\IUserManager; class ExpireVersions extends TimedJob { public const ITEMS_PER_SESSION = 1000; - private IConfig $config; - private Expiration $expiration; - private IUserManager $userManager; - - public function __construct(IConfig $config, IUserManager $userManager, Expiration $expiration, ITimeFactory $time) { + public function __construct( + private IConfig $config, + private IUserManager $userManager, + private Expiration $expiration, + ITimeFactory $time, + ) { parent::__construct($time); // Run once per 30 minutes $this->setInterval(60 * 30); - - $this->config = $config; - $this->expiration = $expiration; - $this->userManager = $userManager; } public function run($argument) { diff --git a/apps/files_versions/lib/Capabilities.php b/apps/files_versions/lib/Capabilities.php index 3566b82842a..4919006bce3 100644 --- a/apps/files_versions/lib/Capabilities.php +++ b/apps/files_versions/lib/Capabilities.php @@ -11,15 +11,10 @@ use OCP\Capabilities\ICapability; use OCP\IConfig; class Capabilities implements ICapability { - private IConfig $config; - private IAppManager $appManager; - public function __construct( - IConfig $config, - IAppManager $appManager, + private IConfig $config, + private IAppManager $appManager, ) { - $this->config = $config; - $this->appManager = $appManager; } /** diff --git a/apps/files_versions/lib/Controller/PreviewController.php b/apps/files_versions/lib/Controller/PreviewController.php index 4cda69beb96..e1d87b4b9f5 100644 --- a/apps/files_versions/lib/Controller/PreviewController.php +++ b/apps/files_versions/lib/Controller/PreviewController.php @@ -20,32 +20,15 @@ use OCP\IUserSession; class PreviewController extends Controller { - /** @var IRootFolder */ - private $rootFolder; - - /** @var IUserSession */ - private $userSession; - - /** @var IVersionManager */ - private $versionManager; - - /** @var IPreview */ - private $previewManager; - public function __construct( string $appName, IRequest $request, - IRootFolder $rootFolder, - IUserSession $userSession, - IVersionManager $versionManager, - IPreview $previewManager, + private IRootFolder $rootFolder, + private IUserSession $userSession, + private IVersionManager $versionManager, + private IPreview $previewManager, ) { parent::__construct($appName, $request); - - $this->rootFolder = $rootFolder; - $this->userSession = $userSession; - $this->versionManager = $versionManager; - $this->previewManager = $previewManager; } /** diff --git a/apps/files_versions/lib/Events/CreateVersionEvent.php b/apps/files_versions/lib/Events/CreateVersionEvent.php index ea372ba8a05..1399cdbb988 100644 --- a/apps/files_versions/lib/Events/CreateVersionEvent.php +++ b/apps/files_versions/lib/Events/CreateVersionEvent.php @@ -21,17 +21,15 @@ class CreateVersionEvent extends Event { /** @var bool */ private $createVersion; - /** @var Node */ - private $node; - /** * CreateVersionEvent constructor. * * @param Node $node */ - public function __construct(Node $node) { + public function __construct( + private Node $node, + ) { $this->createVersion = true; - $this->node = $node; } /** diff --git a/apps/files_versions/lib/Expiration.php b/apps/files_versions/lib/Expiration.php index 26088aa9838..b84756212e4 100644 --- a/apps/files_versions/lib/Expiration.php +++ b/apps/files_versions/lib/Expiration.php @@ -15,9 +15,6 @@ class Expiration { // how long do we keep files a version if no other value is defined in the config file (unit: days) public const NO_OBLIGATION = -1; - /** @var ITimeFactory */ - private $timeFactory; - /** @var string */ private $retentionObligation; @@ -30,12 +27,11 @@ class Expiration { /** @var bool */ private $canPurgeToSaveSpace; - /** @var LoggerInterface */ - private $logger; - - public function __construct(IConfig $config, ITimeFactory $timeFactory, LoggerInterface $logger) { - $this->timeFactory = $timeFactory; - $this->logger = $logger; + public function __construct( + IConfig $config, + private ITimeFactory $timeFactory, + private LoggerInterface $logger, + ) { $this->retentionObligation = $config->getSystemValue('versions_retention_obligation', 'auto'); if ($this->retentionObligation !== 'disabled') { diff --git a/apps/files_versions/lib/Sabre/RootCollection.php b/apps/files_versions/lib/Sabre/RootCollection.php index 2d59acdada0..ded4f3dda7b 100644 --- a/apps/files_versions/lib/Sabre/RootCollection.php +++ b/apps/files_versions/lib/Sabre/RootCollection.php @@ -16,33 +16,16 @@ use Sabre\DAVACL\PrincipalBackend; class RootCollection extends AbstractPrincipalCollection { - /** @var IRootFolder */ - private $rootFolder; - - /** @var IUserManager */ - private $userManager; - - /** @var IVersionManager */ - private $versionManager; - - /** @var IUserSession */ - private $userSession; - public function __construct( PrincipalBackend\BackendInterface $principalBackend, - IRootFolder $rootFolder, + private IRootFolder $rootFolder, IConfig $config, - IUserManager $userManager, - IVersionManager $versionManager, - IUserSession $userSession, + private IUserManager $userManager, + private IVersionManager $versionManager, + private IUserSession $userSession, ) { parent::__construct($principalBackend, 'principals/users'); - $this->rootFolder = $rootFolder; - $this->userManager = $userManager; - $this->versionManager = $versionManager; - $this->userSession = $userSession; - $this->disableListing = !$config->getSystemValue('debug', false); } diff --git a/apps/files_versions/lib/Sabre/VersionCollection.php b/apps/files_versions/lib/Sabre/VersionCollection.php index 57510b72ff6..375d5cf99f2 100644 --- a/apps/files_versions/lib/Sabre/VersionCollection.php +++ b/apps/files_versions/lib/Sabre/VersionCollection.php @@ -18,19 +18,11 @@ use Sabre\DAV\ICollection; class VersionCollection implements ICollection { - /** @var File */ - private $file; - - /** @var IUser */ - private $user; - - /** @var IVersionManager */ - private $versionManager; - - public function __construct(File $file, IUser $user, IVersionManager $versionManager) { - $this->file = $file; - $this->user = $user; - $this->versionManager = $versionManager; + public function __construct( + private File $file, + private IUser $user, + private IVersionManager $versionManager, + ) { } public function createFile($name, $data = null) { diff --git a/apps/files_versions/lib/Sabre/VersionHome.php b/apps/files_versions/lib/Sabre/VersionHome.php index d89291a8cf8..7f182958d94 100644 --- a/apps/files_versions/lib/Sabre/VersionHome.php +++ b/apps/files_versions/lib/Sabre/VersionHome.php @@ -14,23 +14,12 @@ use Sabre\DAV\ICollection; class VersionHome implements ICollection { - /** @var array */ - private $principalInfo; - - /** @var IRootFolder */ - private $rootFolder; - - /** @var IUserManager */ - private $userManager; - - /** @var IVersionManager */ - private $versionManager; - - public function __construct(array $principalInfo, IRootFolder $rootFolder, IUserManager $userManager, IVersionManager $versionManager) { - $this->principalInfo = $principalInfo; - $this->rootFolder = $rootFolder; - $this->userManager = $userManager; - $this->versionManager = $versionManager; + public function __construct( + private array $principalInfo, + private IRootFolder $rootFolder, + private IUserManager $userManager, + private IVersionManager $versionManager, + ) { } private function getUser() { diff --git a/apps/files_versions/lib/Sabre/VersionRoot.php b/apps/files_versions/lib/Sabre/VersionRoot.php index 014f06069ab..7f7014fbee3 100644 --- a/apps/files_versions/lib/Sabre/VersionRoot.php +++ b/apps/files_versions/lib/Sabre/VersionRoot.php @@ -18,19 +18,11 @@ use Sabre\DAV\ICollection; class VersionRoot implements ICollection { - /** @var IUser */ - private $user; - - /** @var IRootFolder */ - private $rootFolder; - - /** @var IVersionManager */ - private $versionManager; - - public function __construct(IUser $user, IRootFolder $rootFolder, IVersionManager $versionManager) { - $this->user = $user; - $this->rootFolder = $rootFolder; - $this->versionManager = $versionManager; + public function __construct( + private IUser $user, + private IRootFolder $rootFolder, + private IVersionManager $versionManager, + ) { } public function delete() { diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index e5849bf936d..813b5267be2 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -80,7 +80,7 @@ class Storage { * * @param string $filename * @return array - * @throws \OC\User\NoUserException + * @throws NoUserException */ public static function getUidAndFilename($filename) { $uid = Filesystem::getOwner($filename); diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index e20fbc623dc..20a0a783ecc 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -37,7 +37,7 @@ class VersioningTest extends \Test\TestCase { public const USERS_VERSIONS_ROOT = '/test-versions-user/files_versions'; /** - * @var \OC\Files\View + * @var View */ private $rootView; /** @@ -934,7 +934,7 @@ class VersioningTest extends \Test\TestCase { } /** - * @param \OC\Files\View $view + * @param View $view * @param string $path */ private function createAndCheckVersions(View $view, $path) { diff --git a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php index fd2a76b4773..1b0ca0fa576 100644 --- a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php +++ b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php @@ -19,11 +19,7 @@ use OCP\IUser; use OCP\IUserManager; class RetryJob extends Job { - private IClientService $clientService; private string $lookupServer; - private IConfig $config; - private IUserManager $userManager; - private IAccountManager $accountManager; private Signer $signer; protected int $retries = 0; protected bool $retainJob = false; @@ -36,20 +32,18 @@ class RetryJob extends Job { * @param IAccountManager $accountManager * @param Signer $signer */ - public function __construct(ITimeFactory $time, - IClientService $clientService, - IConfig $config, - IUserManager $userManager, - IAccountManager $accountManager, - Signer $signer) { + public function __construct( + ITimeFactory $time, + private IClientService $clientService, + private IConfig $config, + private IUserManager $userManager, + private IAccountManager $accountManager, + Signer $signer, + ) { parent::__construct($time); - $this->clientService = $clientService; - $this->config = $config; - $this->userManager = $userManager; - $this->accountManager = $accountManager; $this->signer = $signer; - $this->lookupServer = $config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com'); + $this->lookupServer = $this->config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com'); if (!empty($this->lookupServer)) { $this->lookupServer = rtrim($this->lookupServer, '/'); $this->lookupServer .= '/users'; diff --git a/apps/lookup_server_connector/lib/UpdateLookupServer.php b/apps/lookup_server_connector/lib/UpdateLookupServer.php index 9ccf149e12c..c689cea1fe0 100644 --- a/apps/lookup_server_connector/lib/UpdateLookupServer.php +++ b/apps/lookup_server_connector/lib/UpdateLookupServer.php @@ -19,19 +19,14 @@ use OCP\IUser; * @package OCA\LookupServerConnector */ class UpdateLookupServer { - /** @var IConfig */ - private $config; - /** @var IJobList */ - private $jobList; - /** * @param IJobList $jobList * @param IConfig $config */ - public function __construct(IJobList $jobList, - IConfig $config) { - $this->config = $config; - $this->jobList = $jobList; + public function __construct( + private IJobList $jobList, + private IConfig $config, + ) { } /** diff --git a/apps/oauth2/lib/Controller/LoginRedirectorController.php b/apps/oauth2/lib/Controller/LoginRedirectorController.php index d9a9ed5c5d0..ca2255d96d7 100644 --- a/apps/oauth2/lib/Controller/LoginRedirectorController.php +++ b/apps/oauth2/lib/Controller/LoginRedirectorController.php @@ -23,15 +23,6 @@ use OCP\ISession; use OCP\IURLGenerator; class LoginRedirectorController extends Controller { - /** @var IURLGenerator */ - private $urlGenerator; - /** @var ClientMapper */ - private $clientMapper; - /** @var ISession */ - private $session; - /** @var IL10N */ - private $l; - /** * @param string $appName * @param IRequest $request @@ -40,17 +31,15 @@ class LoginRedirectorController extends Controller { * @param ISession $session * @param IL10N $l */ - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - IURLGenerator $urlGenerator, - ClientMapper $clientMapper, - ISession $session, - IL10N $l) { + private IURLGenerator $urlGenerator, + private ClientMapper $clientMapper, + private ISession $session, + private IL10N $l, + ) { parent::__construct($appName, $request); - $this->urlGenerator = $urlGenerator; - $this->clientMapper = $clientMapper; - $this->session = $session; - $this->l = $l; } /** diff --git a/apps/oauth2/lib/Migration/SetTokenExpiration.php b/apps/oauth2/lib/Migration/SetTokenExpiration.php index 51b1061ae11..dc925e26bb2 100644 --- a/apps/oauth2/lib/Migration/SetTokenExpiration.php +++ b/apps/oauth2/lib/Migration/SetTokenExpiration.php @@ -18,15 +18,11 @@ use OCP\Migration\IRepairStep; class SetTokenExpiration implements IRepairStep { - /** @var ITimeFactory */ - private $time; - public function __construct( private IDBConnection $connection, - ITimeFactory $timeFactory, + private ITimeFactory $time, private TokenProvider $tokenProvider, ) { - $this->time = $timeFactory; } public function getName(): string { diff --git a/apps/provisioning_api/lib/Capabilities.php b/apps/provisioning_api/lib/Capabilities.php index 4c8b1ce3ec7..1c2a7b867fa 100644 --- a/apps/provisioning_api/lib/Capabilities.php +++ b/apps/provisioning_api/lib/Capabilities.php @@ -11,11 +11,9 @@ use OCP\Capabilities\ICapability; class Capabilities implements ICapability { - /** @var IAppManager */ - private $appManager; - - public function __construct(IAppManager $appManager) { - $this->appManager = $appManager; + public function __construct( + private IAppManager $appManager, + ) { } /** diff --git a/apps/provisioning_api/lib/Controller/AppsController.php b/apps/provisioning_api/lib/Controller/AppsController.php index 955c2bc39ab..ae08a9cade0 100644 --- a/apps/provisioning_api/lib/Controller/AppsController.php +++ b/apps/provisioning_api/lib/Controller/AppsController.php @@ -19,17 +19,12 @@ use OCP\AppFramework\OCSController; use OCP\IRequest; class AppsController extends OCSController { - /** @var IAppManager */ - private $appManager; - public function __construct( string $appName, IRequest $request, - IAppManager $appManager, + private IAppManager $appManager, ) { parent::__construct($appName, $request); - - $this->appManager = $appManager; } /** diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php index f0712d12261..0b16c319f1d 100644 --- a/apps/provisioning_api/lib/Controller/GroupsController.php +++ b/apps/provisioning_api/lib/Controller/GroupsController.php @@ -38,10 +38,8 @@ use Psr\Log\LoggerInterface; */ class GroupsController extends AUserData { - /** @var LoggerInterface */ - private $logger; - - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, IUserManager $userManager, IConfig $config, @@ -50,7 +48,8 @@ class GroupsController extends AUserData { IAccountManager $accountManager, ISubAdmin $subAdminManager, IFactory $l10nFactory, - LoggerInterface $logger) { + private LoggerInterface $logger, + ) { parent::__construct($appName, $request, $userManager, @@ -61,8 +60,6 @@ class GroupsController extends AUserData { $subAdminManager, $l10nFactory ); - - $this->logger = $logger; } /** diff --git a/apps/provisioning_api/lib/Controller/PreferencesController.php b/apps/provisioning_api/lib/Controller/PreferencesController.php index f230d1d781f..672aec7756c 100644 --- a/apps/provisioning_api/lib/Controller/PreferencesController.php +++ b/apps/provisioning_api/lib/Controller/PreferencesController.php @@ -22,21 +22,14 @@ use OCP\IUserSession; class PreferencesController extends OCSController { - private IConfig $config; - private IUserSession $userSession; - private IEventDispatcher $eventDispatcher; - public function __construct( string $appName, IRequest $request, - IConfig $config, - IUserSession $userSession, - IEventDispatcher $eventDispatcher, + private IConfig $config, + private IUserSession $userSession, + private IEventDispatcher $eventDispatcher, ) { parent::__construct($appName, $request); - $this->config = $config; - $this->userSession = $userSession; - $this->eventDispatcher = $eventDispatcher; } /** diff --git a/apps/provisioning_api/lib/Controller/VerificationController.php b/apps/provisioning_api/lib/Controller/VerificationController.php index 33b5bb0020f..70535c4906c 100644 --- a/apps/provisioning_api/lib/Controller/VerificationController.php +++ b/apps/provisioning_api/lib/Controller/VerificationController.php @@ -28,35 +28,20 @@ use OCP\Security\VerificationToken\IVerificationToken; #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)] class VerificationController extends Controller { - /** @var IVerificationToken */ - private $verificationToken; - /** @var IUserManager */ - private $userManager; - /** @var IL10N */ - private $l10n; - /** @var IUserSession */ - private $userSession; - /** @var IAccountManager */ - private $accountManager; /** @var Crypto */ private $crypto; public function __construct( string $appName, IRequest $request, - IVerificationToken $verificationToken, - IUserManager $userManager, - IL10N $l10n, - IUserSession $userSession, - IAccountManager $accountManager, + private IVerificationToken $verificationToken, + private IUserManager $userManager, + private IL10N $l10n, + private IUserSession $userSession, + private IAccountManager $accountManager, Crypto $crypto, ) { parent::__construct($appName, $request); - $this->verificationToken = $verificationToken; - $this->userManager = $userManager; - $this->l10n = $l10n; - $this->userSession = $userSession; - $this->accountManager = $accountManager; $this->crypto = $crypto; } diff --git a/apps/provisioning_api/lib/FederatedShareProviderFactory.php b/apps/provisioning_api/lib/FederatedShareProviderFactory.php index 5e78b0fb361..3da76102c4a 100644 --- a/apps/provisioning_api/lib/FederatedShareProviderFactory.php +++ b/apps/provisioning_api/lib/FederatedShareProviderFactory.php @@ -13,11 +13,9 @@ use OCP\IServerContainer; class FederatedShareProviderFactory { - /** @var IServerContainer */ - private $serverContainer; - - public function __construct(IServerContainer $serverContainer) { - $this->serverContainer = $serverContainer; + public function __construct( + private IServerContainer $serverContainer, + ) { } public function get(): FederatedShareProvider { diff --git a/apps/provisioning_api/lib/Middleware/ProvisioningApiMiddleware.php b/apps/provisioning_api/lib/Middleware/ProvisioningApiMiddleware.php index a9ad7430ce0..1989ef5d4c1 100644 --- a/apps/provisioning_api/lib/Middleware/ProvisioningApiMiddleware.php +++ b/apps/provisioning_api/lib/Middleware/ProvisioningApiMiddleware.php @@ -18,15 +18,6 @@ use OCP\AppFramework\Utility\IControllerMethodReflector; class ProvisioningApiMiddleware extends Middleware { - /** @var IControllerMethodReflector */ - private $reflector; - - /** @var bool */ - private $isAdmin; - - /** @var bool */ - private $isSubAdmin; - /** * ProvisioningApiMiddleware constructor. * @@ -35,12 +26,10 @@ class ProvisioningApiMiddleware extends Middleware { * @param bool $isSubAdmin */ public function __construct( - IControllerMethodReflector $reflector, - bool $isAdmin, - bool $isSubAdmin) { - $this->reflector = $reflector; - $this->isAdmin = $isAdmin; - $this->isSubAdmin = $isSubAdmin; + private IControllerMethodReflector $reflector, + private bool $isAdmin, + private bool $isSubAdmin, + ) { } /** diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index dc5e96b3ef0..b1a708b9aa2 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -14,6 +14,7 @@ use OCP\Accounts\IAccountManager; use OCP\AppFramework\OCS\OCSException; use OCP\Group\ISubAdmin; use OCP\IConfig; +use OCP\IGroup; use OCP\IRequest; use OCP\IUser; use OCP\IUserManager; @@ -82,7 +83,7 @@ class GroupsControllerTest extends \Test\TestCase { /** * @param string $gid - * @return \OCP\IGroup|\PHPUnit\Framework\MockObject\MockObject + * @return IGroup|\PHPUnit\Framework\MockObject\MockObject */ private function createGroup($gid) { $group = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); @@ -110,7 +111,7 @@ class GroupsControllerTest extends \Test\TestCase { /** * @param string $uid - * @return \OCP\IUser|\PHPUnit\Framework\MockObject\MockObject + * @return IUser|\PHPUnit\Framework\MockObject\MockObject */ private function createUser($uid) { $user = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); diff --git a/apps/settings/lib/Activity/GroupProvider.php b/apps/settings/lib/Activity/GroupProvider.php index abf3e5613c0..72c9ca0d719 100644 --- a/apps/settings/lib/Activity/GroupProvider.php +++ b/apps/settings/lib/Activity/GroupProvider.php @@ -19,31 +19,17 @@ class GroupProvider implements IProvider { public const ADDED_TO_GROUP = 'group_added'; public const REMOVED_FROM_GROUP = 'group_removed'; - /** @var L10nFactory */ - private $l10n; - /** @var IURLGenerator */ - private $urlGenerator; - /** @var IManager */ - private $activityManager; - /** @var IUserManager */ - protected $userManager; - /** @var IGroupManager */ - protected $groupManager; - /** @var string[] */ protected $groupDisplayNames = []; - public function __construct(L10nFactory $l10n, - IURLGenerator $urlGenerator, - IManager $activityManager, - IUserManager $userManager, - IGroupManager $groupManager) { - $this->urlGenerator = $urlGenerator; - $this->l10n = $l10n; - $this->activityManager = $activityManager; - $this->userManager = $userManager; - $this->groupManager = $groupManager; + public function __construct( + private L10nFactory $l10n, + private IURLGenerator $urlGenerator, + private IManager $activityManager, + protected IUserManager $userManager, + protected IGroupManager $groupManager, + ) { } public function parse($language, IEvent $event, ?IEvent $previousEvent = null) { diff --git a/apps/settings/lib/Activity/GroupSetting.php b/apps/settings/lib/Activity/GroupSetting.php index 30a4b6a6aeb..9433bdb25d2 100644 --- a/apps/settings/lib/Activity/GroupSetting.php +++ b/apps/settings/lib/Activity/GroupSetting.php @@ -10,14 +10,12 @@ use OCP\IL10N; class GroupSetting implements ISetting { - /** @var IL10N */ - protected $l; - /** - * @param IL10N $l10n + * @param IL10N $l */ - public function __construct(IL10N $l10n) { - $this->l = $l10n; + public function __construct( + protected IL10N $l, + ) { } /** diff --git a/apps/settings/lib/Activity/Provider.php b/apps/settings/lib/Activity/Provider.php index e1de18554d9..fb95423a4c1 100644 --- a/apps/settings/lib/Activity/Provider.php +++ b/apps/settings/lib/Activity/Provider.php @@ -31,29 +31,15 @@ class Provider implements IProvider { public const APP_TOKEN_FILESYSTEM_GRANTED = 'app_token_filesystem_granted'; public const APP_TOKEN_FILESYSTEM_REVOKED = 'app_token_filesystem_revoked'; - /** @var IFactory */ - protected $languageFactory; - /** @var IL10N */ protected $l; - /** @var IURLGenerator */ - protected $url; - - /** @var IUserManager */ - protected $userManager; - - /** @var IManager */ - private $activityManager; - - public function __construct(IFactory $languageFactory, - IURLGenerator $url, - IUserManager $userManager, - IManager $activityManager) { - $this->languageFactory = $languageFactory; - $this->url = $url; - $this->userManager = $userManager; - $this->activityManager = $activityManager; + public function __construct( + protected IFactory $languageFactory, + protected IURLGenerator $url, + protected IUserManager $userManager, + private IManager $activityManager, + ) { } /** diff --git a/apps/settings/lib/Activity/SecurityFilter.php b/apps/settings/lib/Activity/SecurityFilter.php index 61d657193fd..5ff6685f449 100644 --- a/apps/settings/lib/Activity/SecurityFilter.php +++ b/apps/settings/lib/Activity/SecurityFilter.php @@ -11,15 +11,10 @@ use OCP\IURLGenerator; class SecurityFilter implements IFilter { - /** @var IURLGenerator */ - private $urlGenerator; - - /** @var IL10N */ - private $l10n; - - public function __construct(IURLGenerator $urlGenerator, IL10N $l10n) { - $this->urlGenerator = $urlGenerator; - $this->l10n = $l10n; + public function __construct( + private IURLGenerator $urlGenerator, + private IL10N $l10n, + ) { } public function allowedApps() { diff --git a/apps/settings/lib/Activity/SecurityProvider.php b/apps/settings/lib/Activity/SecurityProvider.php index 8e2b4f8f45a..658e2e7b949 100644 --- a/apps/settings/lib/Activity/SecurityProvider.php +++ b/apps/settings/lib/Activity/SecurityProvider.php @@ -17,19 +17,11 @@ use OCP\L10N\IFactory as L10nFactory; class SecurityProvider implements IProvider { - /** @var L10nFactory */ - private $l10n; - - /** @var IURLGenerator */ - private $urlGenerator; - - /** @var IManager */ - private $activityManager; - - public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IManager $activityManager) { - $this->urlGenerator = $urlGenerator; - $this->l10n = $l10n; - $this->activityManager = $activityManager; + public function __construct( + private L10nFactory $l10n, + private IURLGenerator $urlGenerator, + private IManager $activityManager, + ) { } public function parse($language, IEvent $event, ?IEvent $previousEvent = null) { diff --git a/apps/settings/lib/Activity/SecuritySetting.php b/apps/settings/lib/Activity/SecuritySetting.php index 3253640aca3..997e63a97b1 100644 --- a/apps/settings/lib/Activity/SecuritySetting.php +++ b/apps/settings/lib/Activity/SecuritySetting.php @@ -10,11 +10,9 @@ use OCP\IL10N; class SecuritySetting implements ISetting { - /** @var IL10N */ - private $l10n; - - public function __construct(IL10N $l10n) { - $this->l10n = $l10n; + public function __construct( + private IL10N $l10n, + ) { } public function canChangeMail() { diff --git a/apps/settings/lib/Activity/Setting.php b/apps/settings/lib/Activity/Setting.php index ace10546f82..621dadda11d 100644 --- a/apps/settings/lib/Activity/Setting.php +++ b/apps/settings/lib/Activity/Setting.php @@ -10,14 +10,12 @@ use OCP\IL10N; class Setting implements ISetting { - /** @var IL10N */ - protected $l; - /** - * @param IL10N $l10n + * @param IL10N $l */ - public function __construct(IL10N $l10n) { - $this->l = $l10n; + public function __construct( + protected IL10N $l, + ) { } /** diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index bd06483fa63..d3d12a6c53d 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -80,6 +80,7 @@ use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\IAppContainer; +use OCP\AppFramework\QueryException; use OCP\Defaults; use OCP\Group\Events\GroupDeletedEvent; use OCP\Group\Events\UserAddedEvent; @@ -221,7 +222,7 @@ class Application extends App implements IBootstrap { * @throws \InvalidArgumentException * @throws \BadMethodCallException * @throws \Exception - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ public function onChangePassword(array $parameters) { /** @var Hooks $hooks */ @@ -234,7 +235,7 @@ class Application extends App implements IBootstrap { * @throws \InvalidArgumentException * @throws \BadMethodCallException * @throws \Exception - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ public function onChangeInfo(array $parameters) { if ($parameters['feature'] !== 'eMailAddress') { diff --git a/apps/settings/lib/Controller/AuthSettingsController.php b/apps/settings/lib/Controller/AuthSettingsController.php index 4b126e879d2..8652a49fb1d 100644 --- a/apps/settings/lib/Controller/AuthSettingsController.php +++ b/apps/settings/lib/Controller/AuthSettingsController.php @@ -35,27 +35,9 @@ class AuthSettingsController extends Controller { /** @var IProvider */ private $tokenProvider; - /** @var ISession */ - private $session; - - /** @var IUserSession */ - private $userSession; - - /** @var string */ - private $uid; - - /** @var ISecureRandom */ - private $random; - - /** @var IManager */ - private $activityManager; - /** @var RemoteWipe */ private $remoteWipe; - /** @var LoggerInterface */ - private $logger; - /** * @param string $appName * @param IRequest $request @@ -68,25 +50,21 @@ class AuthSettingsController extends Controller { * @param RemoteWipe $remoteWipe * @param LoggerInterface $logger */ - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, IProvider $tokenProvider, - ISession $session, - ISecureRandom $random, - ?string $userId, - IUserSession $userSession, - IManager $activityManager, + private ISession $session, + private ISecureRandom $random, + private ?string $userId, + private IUserSession $userSession, + private IManager $activityManager, RemoteWipe $remoteWipe, - LoggerInterface $logger) { + private LoggerInterface $logger, + ) { parent::__construct($appName, $request); $this->tokenProvider = $tokenProvider; - $this->uid = $userId; - $this->userSession = $userSession; - $this->session = $session; - $this->random = $random; - $this->activityManager = $activityManager; $this->remoteWipe = $remoteWipe; - $this->logger = $logger; } /** @@ -128,7 +106,7 @@ class AuthSettingsController extends Controller { } $token = $this->generateRandomDeviceToken(); - $deviceToken = $this->tokenProvider->generateToken($token, $this->uid, $loginName, $password, $name, IToken::PERMANENT_TOKEN); + $deviceToken = $this->tokenProvider->generateToken($token, $this->userId, $loginName, $password, $name, IToken::PERMANENT_TOKEN); $tokenData = $deviceToken->jsonSerialize(); $tokenData['canDelete'] = true; $tokenData['canRename'] = true; @@ -191,7 +169,7 @@ class AuthSettingsController extends Controller { return new JSONResponse([], Http::STATUS_NOT_FOUND); } - $this->tokenProvider->invalidateTokenById($this->uid, $token->getId()); + $this->tokenProvider->invalidateTokenById($this->userId, $token->getId()); $this->publishActivity(Provider::APP_TOKEN_DELETED, $token->getId(), ['name' => $token->getName()]); return []; } @@ -245,8 +223,8 @@ class AuthSettingsController extends Controller { $event = $this->activityManager->generateEvent(); $event->setApp('settings') ->setType('security') - ->setAffectedUser($this->uid) - ->setAuthor($this->uid) + ->setAffectedUser($this->userId) + ->setAuthor($this->userId) ->setSubject($subject, $parameters) ->setObject('app_token', $id, 'App Password'); @@ -270,7 +248,7 @@ class AuthSettingsController extends Controller { } catch (ExpiredTokenException $e) { $token = $e->getToken(); } - if ($token->getUID() !== $this->uid) { + if ($token->getUID() !== $this->userId) { /** @psalm-suppress DeprecatedClass We have to throw the OC version so both OC and OCP catches catch it */ throw new OcInvalidTokenException('This token does not belong to you!'); } diff --git a/apps/settings/lib/Controller/AuthorizedGroupController.php b/apps/settings/lib/Controller/AuthorizedGroupController.php index f4a018b0555..ad01b590440 100644 --- a/apps/settings/lib/Controller/AuthorizedGroupController.php +++ b/apps/settings/lib/Controller/AuthorizedGroupController.php @@ -15,12 +15,12 @@ use OCP\DB\Exception; use OCP\IRequest; class AuthorizedGroupController extends Controller { - /** @var AuthorizedGroupService $authorizedGroupService */ - private $authorizedGroupService; - - public function __construct(string $AppName, IRequest $request, AuthorizedGroupService $authorizedGroupService) { + public function __construct( + string $AppName, + IRequest $request, + private AuthorizedGroupService $authorizedGroupService, + ) { parent::__construct($AppName, $request); - $this->authorizedGroupService = $authorizedGroupService; } /** diff --git a/apps/settings/lib/Controller/ChangePasswordController.php b/apps/settings/lib/Controller/ChangePasswordController.php index 13a83e17549..2154a9ab11b 100644 --- a/apps/settings/lib/Controller/ChangePasswordController.php +++ b/apps/settings/lib/Controller/ChangePasswordController.php @@ -20,7 +20,6 @@ use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\HintException; -use OCP\IGroupManager; use OCP\IL10N; use OCP\IRequest; use OCP\IUser; @@ -29,29 +28,20 @@ use OCP\IUserSession; use OCP\Server; class ChangePasswordController extends Controller { - private ?string $userId; - private IUserManager $userManager; - private IL10N $l; - private GroupManager $groupManager; private Session $userSession; - private IAppManager $appManager; - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - ?string $userId, - IUserManager $userManager, + private ?string $userId, + private IUserManager $userManager, IUserSession $userSession, - IGroupManager $groupManager, - IAppManager $appManager, - IL10N $l) { + private GroupManager $groupManager, + private IAppManager $appManager, + private IL10N $l, + ) { parent::__construct($appName, $request); - - $this->userId = $userId; - $this->userManager = $userManager; $this->userSession = $userSession; - $this->groupManager = $groupManager; - $this->appManager = $appManager; - $this->l = $l; } /** diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index a8db2a0e297..2a189a37ce6 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -27,34 +27,21 @@ use Psr\Log\LoggerInterface; #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)] class CheckSetupController extends Controller { - /** @var IConfig */ - private $config; - /** @var IURLGenerator */ - private $urlGenerator; - /** @var IL10N */ - private $l10n; /** @var Checker */ private $checker; - /** @var LoggerInterface */ - private $logger; - private ISetupCheckManager $setupCheckManager; - public function __construct($AppName, + public function __construct( + $AppName, IRequest $request, - IConfig $config, - IURLGenerator $urlGenerator, - IL10N $l10n, + private IConfig $config, + private IURLGenerator $urlGenerator, + private IL10N $l10n, Checker $checker, - LoggerInterface $logger, - ISetupCheckManager $setupCheckManager, + private LoggerInterface $logger, + private ISetupCheckManager $setupCheckManager, ) { parent::__construct($AppName, $request); - $this->config = $config; - $this->urlGenerator = $urlGenerator; - $this->l10n = $l10n; $this->checker = $checker; - $this->logger = $logger; - $this->setupCheckManager = $setupCheckManager; } /** diff --git a/apps/settings/lib/Controller/CommonSettingsTrait.php b/apps/settings/lib/Controller/CommonSettingsTrait.php index 26cbadd76a1..56760c10f81 100644 --- a/apps/settings/lib/Controller/CommonSettingsTrait.php +++ b/apps/settings/lib/Controller/CommonSettingsTrait.php @@ -109,7 +109,7 @@ trait CommonSettingsTrait { } /** - * @param list<\OCP\Settings\ISettings> $settings + * @param list<ISettings> $settings * @param list<DeclarativeSettingsFormSchemaWithValues> $declarativeSettings * @return array{content: string} */ diff --git a/apps/settings/lib/Controller/HelpController.php b/apps/settings/lib/Controller/HelpController.php index 9fdab414d30..05bff158ee6 100644 --- a/apps/settings/lib/Controller/HelpController.php +++ b/apps/settings/lib/Controller/HelpController.php @@ -25,43 +25,19 @@ use OCP\IURLGenerator; #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)] class HelpController extends Controller { - /** @var INavigationManager */ - private $navigationManager; - /** @var IURLGenerator */ - private $urlGenerator; - /** @var IGroupManager */ - private $groupManager; - /** @var IL10N */ - private $l10n; - - /** @var string */ - private $userId; - - /** @var IConfig */ - private $config; - - /** @var IAppConfig */ - private $appConfig; - public function __construct( string $appName, IRequest $request, - INavigationManager $navigationManager, - IURLGenerator $urlGenerator, - ?string $userId, - IGroupManager $groupManager, - IL10N $l10n, - IConfig $config, - IAppConfig $appConfig, + private INavigationManager $navigationManager, + private IURLGenerator $urlGenerator, + /** @var string */ + private ?string $userId, + private IGroupManager $groupManager, + private IL10N $l10n, + private IConfig $config, + private IAppConfig $appConfig, ) { parent::__construct($appName, $request); - $this->navigationManager = $navigationManager; - $this->urlGenerator = $urlGenerator; - $this->userId = $userId; - $this->groupManager = $groupManager; - $this->l10n = $l10n; - $this->config = $config; - $this->appConfig = $appConfig; } /** diff --git a/apps/settings/lib/Controller/MailSettingsController.php b/apps/settings/lib/Controller/MailSettingsController.php index f6b86c7970e..ca037f409b3 100644 --- a/apps/settings/lib/Controller/MailSettingsController.php +++ b/apps/settings/lib/Controller/MailSettingsController.php @@ -21,17 +21,6 @@ use OCP\Mail\IMailer; class MailSettingsController extends Controller { - /** @var IL10N */ - private $l10n; - /** @var IConfig */ - private $config; - /** @var IUserSession */ - private $userSession; - /** @var IMailer */ - private $mailer; - /** @var IURLGenerator */ - private $urlGenerator; - /** * @param string $appName * @param IRequest $request @@ -41,19 +30,16 @@ class MailSettingsController extends Controller { * @param IURLGenerator $urlGenerator, * @param IMailer $mailer */ - public function __construct($appName, + public function __construct( + $appName, IRequest $request, - IL10N $l10n, - IConfig $config, - IUserSession $userSession, - IURLGenerator $urlGenerator, - IMailer $mailer) { + private IL10N $l10n, + private IConfig $config, + private IUserSession $userSession, + private IURLGenerator $urlGenerator, + private IMailer $mailer, + ) { parent::__construct($appName, $request); - $this->l10n = $l10n; - $this->config = $config; - $this->userSession = $userSession; - $this->urlGenerator = $urlGenerator; - $this->mailer = $mailer; } /** diff --git a/apps/settings/lib/Hooks.php b/apps/settings/lib/Hooks.php index eb77b676914..8a68aed106e 100644 --- a/apps/settings/lib/Hooks.php +++ b/apps/settings/lib/Hooks.php @@ -19,43 +19,17 @@ use OCP\Mail\IMailer; class Hooks { - /** @var IActivityManager */ - protected $activityManager; - /** @var IGroupManager|\OC\Group\Manager */ - protected $groupManager; - /** @var IUserManager */ - protected $userManager; - /** @var IUserSession */ - protected $userSession; - /** @var IURLGenerator */ - protected $urlGenerator; - /** @var IMailer */ - protected $mailer; - /** @var IConfig */ - protected $config; - /** @var IFactory */ - protected $languageFactory; - /** @var Defaults */ - protected $defaults; - - public function __construct(IActivityManager $activityManager, - IGroupManager $groupManager, - IUserManager $userManager, - IUserSession $userSession, - IURLGenerator $urlGenerator, - IMailer $mailer, - IConfig $config, - IFactory $languageFactory, - Defaults $defaults) { - $this->activityManager = $activityManager; - $this->groupManager = $groupManager; - $this->userManager = $userManager; - $this->userSession = $userSession; - $this->urlGenerator = $urlGenerator; - $this->mailer = $mailer; - $this->config = $config; - $this->languageFactory = $languageFactory; - $this->defaults = $defaults; + public function __construct( + protected IActivityManager $activityManager, + protected IGroupManager $groupManager, + protected IUserManager $userManager, + protected IUserSession $userSession, + protected IURLGenerator $urlGenerator, + protected IMailer $mailer, + protected IConfig $config, + protected IFactory $languageFactory, + protected Defaults $defaults, + ) { } /** diff --git a/apps/settings/lib/Listener/AppPasswordCreatedActivityListener.php b/apps/settings/lib/Listener/AppPasswordCreatedActivityListener.php index 8bc045a38fb..a51eee1a799 100644 --- a/apps/settings/lib/Listener/AppPasswordCreatedActivityListener.php +++ b/apps/settings/lib/Listener/AppPasswordCreatedActivityListener.php @@ -21,21 +21,11 @@ use Psr\Log\LoggerInterface; * @template-implements IEventListener<\OC\Authentication\Events\AppPasswordCreatedEvent> */ class AppPasswordCreatedActivityListener implements IEventListener { - /** @var IActivityManager */ - private $activityManager; - - /** @var IUserSession */ - private $userSession; - - /** @var LoggerInterface */ - private $logger; - - public function __construct(IActivityManager $activityManager, - IUserSession $userSession, - LoggerInterface $logger) { - $this->activityManager = $activityManager; - $this->userSession = $userSession; - $this->logger = $logger; + public function __construct( + private IActivityManager $activityManager, + private IUserSession $userSession, + private LoggerInterface $logger, + ) { } public function handle(Event $event): void { diff --git a/apps/settings/lib/Listener/GroupRemovedListener.php b/apps/settings/lib/Listener/GroupRemovedListener.php index 8375433f15a..c1b3f888ea8 100644 --- a/apps/settings/lib/Listener/GroupRemovedListener.php +++ b/apps/settings/lib/Listener/GroupRemovedListener.php @@ -14,11 +14,9 @@ use OCP\Group\Events\GroupDeletedEvent; /** @template-implements IEventListener<GroupDeletedEvent> */ class GroupRemovedListener implements IEventListener { - /** @var AuthorizedGroupService $authorizedGroupService */ - private $authorizedGroupService; - - public function __construct(AuthorizedGroupService $authorizedGroupService) { - $this->authorizedGroupService = $authorizedGroupService; + public function __construct( + private AuthorizedGroupService $authorizedGroupService, + ) { } /** diff --git a/apps/settings/lib/Listener/UserAddedToGroupActivityListener.php b/apps/settings/lib/Listener/UserAddedToGroupActivityListener.php index 36feeaa1035..87cd66efdbc 100644 --- a/apps/settings/lib/Listener/UserAddedToGroupActivityListener.php +++ b/apps/settings/lib/Listener/UserAddedToGroupActivityListener.php @@ -20,23 +20,11 @@ use OCP\IUserSession; /** @template-implements IEventListener<UserAddedEvent> */ class UserAddedToGroupActivityListener implements IEventListener { - /** @var Manager */ - private $groupManager; - - /** @var IManager */ - private $activityManager; - - /** @var IUserSession */ - private $userSession; - public function __construct( - Manager $groupManager, - IManager $activityManager, - IUserSession $userSession, + private Manager $groupManager, + private IManager $activityManager, + private IUserSession $userSession, ) { - $this->groupManager = $groupManager; - $this->activityManager = $activityManager; - $this->userSession = $userSession; } public function handle(Event $event): void { diff --git a/apps/settings/lib/Listener/UserRemovedFromGroupActivityListener.php b/apps/settings/lib/Listener/UserRemovedFromGroupActivityListener.php index 82302f748ec..803d86d555d 100644 --- a/apps/settings/lib/Listener/UserRemovedFromGroupActivityListener.php +++ b/apps/settings/lib/Listener/UserRemovedFromGroupActivityListener.php @@ -20,23 +20,11 @@ use OCP\IUserSession; /** @template-implements IEventListener<UserRemovedEvent> */ class UserRemovedFromGroupActivityListener implements IEventListener { - /** @var Manager */ - private $groupManager; - - /** @var IManager */ - private $activityManager; - - /** @var IUserSession */ - private $userSession; - public function __construct( - Manager $groupManager, - IManager $activityManager, - IUserSession $userSession, + private Manager $groupManager, + private IManager $activityManager, + private IUserSession $userSession, ) { - $this->groupManager = $groupManager; - $this->activityManager = $activityManager; - $this->userSession = $userSession; } public function handle(Event $event): void { diff --git a/apps/settings/lib/Mailer/NewUserMailHelper.php b/apps/settings/lib/Mailer/NewUserMailHelper.php index 737da8d7b9a..bd4de2b2087 100644 --- a/apps/settings/lib/Mailer/NewUserMailHelper.php +++ b/apps/settings/lib/Mailer/NewUserMailHelper.php @@ -18,25 +18,6 @@ use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; class NewUserMailHelper { - /** @var Defaults */ - private $themingDefaults; - /** @var IURLGenerator */ - private $urlGenerator; - /** @var IFactory */ - private $l10nFactory; - /** @var IMailer */ - private $mailer; - /** @var ISecureRandom */ - private $secureRandom; - /** @var ITimeFactory */ - private $timeFactory; - /** @var IConfig */ - private $config; - /** @var ICrypto */ - private $crypto; - /** @var string */ - private $fromAddress; - /** * @param Defaults $themingDefaults * @param IURLGenerator $urlGenerator @@ -48,24 +29,17 @@ class NewUserMailHelper { * @param ICrypto $crypto * @param string $fromAddress */ - public function __construct(Defaults $themingDefaults, - IURLGenerator $urlGenerator, - IFactory $l10nFactory, - IMailer $mailer, - ISecureRandom $secureRandom, - ITimeFactory $timeFactory, - IConfig $config, - ICrypto $crypto, - $fromAddress) { - $this->themingDefaults = $themingDefaults; - $this->urlGenerator = $urlGenerator; - $this->l10nFactory = $l10nFactory; - $this->mailer = $mailer; - $this->secureRandom = $secureRandom; - $this->timeFactory = $timeFactory; - $this->config = $config; - $this->crypto = $crypto; - $this->fromAddress = $fromAddress; + public function __construct( + private Defaults $themingDefaults, + private IURLGenerator $urlGenerator, + private IFactory $l10nFactory, + private IMailer $mailer, + private ISecureRandom $secureRandom, + private ITimeFactory $timeFactory, + private IConfig $config, + private ICrypto $crypto, + private $fromAddress, + ) { } /** diff --git a/apps/settings/lib/Middleware/SubadminMiddleware.php b/apps/settings/lib/Middleware/SubadminMiddleware.php index f985cdf278c..fe92661d24e 100644 --- a/apps/settings/lib/Middleware/SubadminMiddleware.php +++ b/apps/settings/lib/Middleware/SubadminMiddleware.php @@ -19,24 +19,20 @@ use OCP\IL10N; * To bypass use the `@NoSubAdminRequired` annotation */ class SubadminMiddleware extends Middleware { - /** @var bool */ - protected $isSubAdmin; /** @var ControllerMethodReflector */ protected $reflector; - /** @var IL10N */ - private $l10n; /** * @param ControllerMethodReflector $reflector * @param bool $isSubAdmin * @param IL10N $l10n */ - public function __construct(ControllerMethodReflector $reflector, - $isSubAdmin, - IL10N $l10n) { + public function __construct( + ControllerMethodReflector $reflector, + protected $isSubAdmin, + private IL10N $l10n, + ) { $this->reflector = $reflector; - $this->isSubAdmin = $isSubAdmin; - $this->l10n = $l10n; } /** diff --git a/apps/settings/lib/Search/SectionSearch.php b/apps/settings/lib/Search/SectionSearch.php index 15d98fbd1b9..08a6f9f76b0 100644 --- a/apps/settings/lib/Search/SectionSearch.php +++ b/apps/settings/lib/Search/SectionSearch.php @@ -21,26 +21,12 @@ use OCP\Settings\IManager; class SectionSearch implements IProvider { - /** @var IManager */ - protected $settingsManager; - - /** @var IGroupManager */ - protected $groupManager; - - /** @var IURLGenerator */ - protected $urlGenerator; - - /** @var IL10N */ - protected $l; - - public function __construct(IManager $settingsManager, - IGroupManager $groupManager, - IURLGenerator $urlGenerator, - IL10N $l) { - $this->settingsManager = $settingsManager; - $this->groupManager = $groupManager; - $this->urlGenerator = $urlGenerator; - $this->l = $l; + public function __construct( + protected IManager $settingsManager, + protected IGroupManager $groupManager, + protected IURLGenerator $urlGenerator, + protected IL10N $l, + ) { } /** diff --git a/apps/settings/lib/Sections/Admin/Additional.php b/apps/settings/lib/Sections/Admin/Additional.php index 19ae2b43f95..0d83a98bbe5 100644 --- a/apps/settings/lib/Sections/Admin/Additional.php +++ b/apps/settings/lib/Sections/Admin/Additional.php @@ -14,15 +14,10 @@ use OCP\Settings\IIconSection; class Additional implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon(): string { diff --git a/apps/settings/lib/Sections/Admin/ArtificialIntelligence.php b/apps/settings/lib/Sections/Admin/ArtificialIntelligence.php index adfcc08c4d4..ab43dfd2eef 100644 --- a/apps/settings/lib/Sections/Admin/ArtificialIntelligence.php +++ b/apps/settings/lib/Sections/Admin/ArtificialIntelligence.php @@ -14,15 +14,10 @@ use OCP\Settings\IIconSection; class ArtificialIntelligence implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon(): string { diff --git a/apps/settings/lib/Sections/Admin/Delegation.php b/apps/settings/lib/Sections/Admin/Delegation.php index cc8aa3e3e84..2a455f1e549 100644 --- a/apps/settings/lib/Sections/Admin/Delegation.php +++ b/apps/settings/lib/Sections/Admin/Delegation.php @@ -11,18 +11,14 @@ use OCP\IURLGenerator; use OCP\Settings\IIconSection; class Delegation implements IIconSection { - /** @var IL10N */ - private $l; - /** @var IURLGenerator */ - private $url; - /** * @param IURLGenerator $url * @param IL10N $l */ - public function __construct(IURLGenerator $url, IL10N $l) { - $this->url = $url; - $this->l = $l; + public function __construct( + private IURLGenerator $url, + private IL10N $l, + ) { } /** diff --git a/apps/settings/lib/Sections/Admin/Groupware.php b/apps/settings/lib/Sections/Admin/Groupware.php index ed790f00fe5..57d92b9cc72 100644 --- a/apps/settings/lib/Sections/Admin/Groupware.php +++ b/apps/settings/lib/Sections/Admin/Groupware.php @@ -14,15 +14,10 @@ use OCP\Settings\IIconSection; class Groupware implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon(): string { diff --git a/apps/settings/lib/Sections/Admin/Overview.php b/apps/settings/lib/Sections/Admin/Overview.php index 518042b4380..0145a2eca93 100644 --- a/apps/settings/lib/Sections/Admin/Overview.php +++ b/apps/settings/lib/Sections/Admin/Overview.php @@ -14,15 +14,10 @@ use OCP\Settings\IIconSection; class Overview implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon(): string { diff --git a/apps/settings/lib/Sections/Admin/Security.php b/apps/settings/lib/Sections/Admin/Security.php index 2eb1dd73715..10027be32fb 100644 --- a/apps/settings/lib/Sections/Admin/Security.php +++ b/apps/settings/lib/Sections/Admin/Security.php @@ -14,15 +14,10 @@ use OCP\Settings\IIconSection; class Security implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon(): string { diff --git a/apps/settings/lib/Sections/Admin/Server.php b/apps/settings/lib/Sections/Admin/Server.php index 9eb3d103b74..c6a02efa4e3 100644 --- a/apps/settings/lib/Sections/Admin/Server.php +++ b/apps/settings/lib/Sections/Admin/Server.php @@ -14,15 +14,10 @@ use OCP\Settings\IIconSection; class Server implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon(): string { diff --git a/apps/settings/lib/Sections/Admin/Sharing.php b/apps/settings/lib/Sections/Admin/Sharing.php index c15a0ff43a3..c7598bb1157 100644 --- a/apps/settings/lib/Sections/Admin/Sharing.php +++ b/apps/settings/lib/Sections/Admin/Sharing.php @@ -14,15 +14,10 @@ use OCP\Settings\IIconSection; class Sharing implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon(): string { diff --git a/apps/settings/lib/Sections/Personal/Availability.php b/apps/settings/lib/Sections/Personal/Availability.php index a6b8878733e..e12e41ea800 100644 --- a/apps/settings/lib/Sections/Personal/Availability.php +++ b/apps/settings/lib/Sections/Personal/Availability.php @@ -15,15 +15,10 @@ use OCP\Settings\IIconSection; class Availability implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon(): string { diff --git a/apps/settings/lib/Sections/Personal/Calendar.php b/apps/settings/lib/Sections/Personal/Calendar.php index 32c99ad9c7b..602b7598f15 100644 --- a/apps/settings/lib/Sections/Personal/Calendar.php +++ b/apps/settings/lib/Sections/Personal/Calendar.php @@ -15,12 +15,10 @@ use OCP\Settings\IIconSection; class Calendar implements IIconSection { - private IL10N $l; - private IURLGenerator $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon(): string { diff --git a/apps/settings/lib/Sections/Personal/PersonalInfo.php b/apps/settings/lib/Sections/Personal/PersonalInfo.php index 9729e1ffa38..35c3e6d2926 100644 --- a/apps/settings/lib/Sections/Personal/PersonalInfo.php +++ b/apps/settings/lib/Sections/Personal/PersonalInfo.php @@ -14,15 +14,10 @@ use OCP\Settings\IIconSection; class PersonalInfo implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon() { diff --git a/apps/settings/lib/Sections/Personal/Security.php b/apps/settings/lib/Sections/Personal/Security.php index 7b9423c5602..d7eb65724ec 100644 --- a/apps/settings/lib/Sections/Personal/Security.php +++ b/apps/settings/lib/Sections/Personal/Security.php @@ -14,15 +14,10 @@ use OCP\Settings\IIconSection; class Security implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon() { diff --git a/apps/settings/lib/Sections/Personal/SyncClients.php b/apps/settings/lib/Sections/Personal/SyncClients.php index 5e55c6a3b6b..3f221956f0c 100644 --- a/apps/settings/lib/Sections/Personal/SyncClients.php +++ b/apps/settings/lib/Sections/Personal/SyncClients.php @@ -14,15 +14,10 @@ use OCP\Settings\IIconSection; class SyncClients implements IIconSection { - /** @var IL10N */ - private $l; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { - $this->l = $l; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IL10N $l, + private IURLGenerator $urlGenerator, + ) { } public function getIcon() { diff --git a/apps/settings/lib/Service/AuthorizedGroupService.php b/apps/settings/lib/Service/AuthorizedGroupService.php index 31ffc765f32..20966446d61 100644 --- a/apps/settings/lib/Service/AuthorizedGroupService.php +++ b/apps/settings/lib/Service/AuthorizedGroupService.php @@ -16,11 +16,9 @@ use OCP\IGroup; class AuthorizedGroupService { - /** @var AuthorizedGroupMapper $mapper */ - private $mapper; - - public function __construct(AuthorizedGroupMapper $mapper) { - $this->mapper = $mapper; + public function __construct( + private AuthorizedGroupMapper $mapper, + ) { } /** diff --git a/apps/settings/lib/Settings/Admin/Delegation.php b/apps/settings/lib/Settings/Admin/Delegation.php index 72798a30673..59a26d1ac04 100644 --- a/apps/settings/lib/Settings/Admin/Delegation.php +++ b/apps/settings/lib/Settings/Admin/Delegation.php @@ -17,24 +17,13 @@ use OCP\Settings\IManager; use OCP\Settings\ISettings; class Delegation implements ISettings { - private IManager $settingManager; - private IInitialState $initialStateService; - private IGroupManager $groupManager; - private AuthorizedGroupService $authorizedGroupService; - private IURLGenerator $urlGenerator; - public function __construct( - IManager $settingManager, - IInitialState $initialStateService, - IGroupManager $groupManager, - AuthorizedGroupService $authorizedGroupService, - IURLGenerator $urlGenerator, + private IManager $settingManager, + private IInitialState $initialStateService, + private IGroupManager $groupManager, + private AuthorizedGroupService $authorizedGroupService, + private IURLGenerator $urlGenerator, ) { - $this->settingManager = $settingManager; - $this->initialStateService = $initialStateService; - $this->groupManager = $groupManager; - $this->authorizedGroupService = $authorizedGroupService; - $this->urlGenerator = $urlGenerator; } /** diff --git a/apps/settings/lib/Settings/Admin/Mail.php b/apps/settings/lib/Settings/Admin/Mail.php index 3614c637f41..ca0f4ef33ad 100644 --- a/apps/settings/lib/Settings/Admin/Mail.php +++ b/apps/settings/lib/Settings/Admin/Mail.php @@ -13,19 +13,14 @@ use OCP\Server; use OCP\Settings\IDelegatedSettings; class Mail implements IDelegatedSettings { - /** @var IConfig */ - private $config; - - /** @var IL10N $l */ - private $l; - /** * @param IConfig $config * @param IL10N $l */ - public function __construct(IConfig $config, IL10N $l) { - $this->config = $config; - $this->l = $l; + public function __construct( + private IConfig $config, + private IL10N $l, + ) { } /** diff --git a/apps/settings/lib/Settings/Admin/Security.php b/apps/settings/lib/Settings/Admin/Security.php index 8f01626789f..72485b8f8f3 100644 --- a/apps/settings/lib/Settings/Admin/Security.php +++ b/apps/settings/lib/Settings/Admin/Security.php @@ -14,22 +14,16 @@ use OCP\IUserManager; use OCP\Settings\ISettings; class Security implements ISettings { - private IManager $manager; - private IUserManager $userManager; private MandatoryTwoFactor $mandatoryTwoFactor; - private IInitialState $initialState; - private IURLGenerator $urlGenerator; - public function __construct(IManager $manager, - IUserManager $userManager, + public function __construct( + private IManager $manager, + private IUserManager $userManager, MandatoryTwoFactor $mandatoryTwoFactor, - IInitialState $initialState, - IURLGenerator $urlGenerator) { - $this->manager = $manager; - $this->userManager = $userManager; + private IInitialState $initialState, + private IURLGenerator $urlGenerator, + ) { $this->mandatoryTwoFactor = $mandatoryTwoFactor; - $this->initialState = $initialState; - $this->urlGenerator = $urlGenerator; } /** diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php index 9aa0f9ee807..6a1f7e97e4a 100644 --- a/apps/settings/lib/Settings/Personal/PersonalInfo.php +++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php @@ -31,58 +31,22 @@ use OCP\Settings\ISettings; class PersonalInfo implements ISettings { - /** @var IConfig */ - private $config; - - /** @var IUserManager */ - private $userManager; - - /** @var IAccountManager */ - private $accountManager; - /** @var ProfileManager */ private $profileManager; - /** @var IGroupManager */ - private $groupManager; - - /** @var IAppManager */ - private $appManager; - - /** @var IFactory */ - private $l10nFactory; - - /** @var IL10N */ - private $l; - - /** @var IInitialState */ - private $initialStateService; - - /** @var IManager */ - private $manager; - public function __construct( - IConfig $config, - IUserManager $userManager, - IGroupManager $groupManager, - IAccountManager $accountManager, + private IConfig $config, + private IUserManager $userManager, + private IGroupManager $groupManager, + private IAccountManager $accountManager, ProfileManager $profileManager, - IAppManager $appManager, - IFactory $l10nFactory, - IL10N $l, - IInitialState $initialStateService, - IManager $manager, + private IAppManager $appManager, + private IFactory $l10nFactory, + private IL10N $l, + private IInitialState $initialStateService, + private IManager $manager, ) { - $this->config = $config; - $this->userManager = $userManager; - $this->accountManager = $accountManager; $this->profileManager = $profileManager; - $this->groupManager = $groupManager; - $this->appManager = $appManager; - $this->l10nFactory = $l10nFactory; - $this->l = $l; - $this->initialStateService = $initialStateService; - $this->manager = $manager; } public function getForm(): TemplateResponse { diff --git a/apps/settings/lib/Settings/Personal/Security/Authtokens.php b/apps/settings/lib/Settings/Personal/Security/Authtokens.php index 90f6e23cbb7..147a4687f66 100644 --- a/apps/settings/lib/Settings/Personal/Security/Authtokens.php +++ b/apps/settings/lib/Settings/Personal/Security/Authtokens.php @@ -22,31 +22,13 @@ use function array_map; class Authtokens implements ISettings { - /** @var IAuthTokenProvider */ - private $tokenProvider; - - /** @var ISession */ - private $session; - - /** @var IInitialState */ - private $initialState; - - /** @var string|null */ - private $uid; - - /** @var IUserSession */ - private $userSession; - - public function __construct(IAuthTokenProvider $tokenProvider, - ISession $session, - IUserSession $userSession, - IInitialState $initialState, - ?string $UserId) { - $this->tokenProvider = $tokenProvider; - $this->session = $session; - $this->initialState = $initialState; - $this->uid = $UserId; - $this->userSession = $userSession; + public function __construct( + private IAuthTokenProvider $tokenProvider, + private ISession $session, + private IUserSession $userSession, + private IInitialState $initialState, + private ?string $uid, + ) { } public function getForm(): TemplateResponse { diff --git a/apps/settings/lib/Settings/Personal/Security/Password.php b/apps/settings/lib/Settings/Personal/Security/Password.php index 753dacf3bdb..82e56fe5a21 100644 --- a/apps/settings/lib/Settings/Personal/Security/Password.php +++ b/apps/settings/lib/Settings/Personal/Security/Password.php @@ -14,16 +14,10 @@ use OCP\Settings\ISettings; class Password implements ISettings { - /** @var IUserManager */ - private $userManager; - - /** @var string|null */ - private $uid; - - public function __construct(IUserManager $userManager, - ?string $UserId) { - $this->userManager = $userManager; - $this->uid = $UserId; + public function __construct( + private IUserManager $userManager, + private ?string $uid, + ) { } public function getForm(): TemplateResponse { diff --git a/apps/settings/lib/Settings/Personal/Security/TwoFactor.php b/apps/settings/lib/Settings/Personal/Security/TwoFactor.php index 63b647f7c44..486b79ae0cb 100644 --- a/apps/settings/lib/Settings/Personal/Security/TwoFactor.php +++ b/apps/settings/lib/Settings/Personal/Security/TwoFactor.php @@ -30,25 +30,15 @@ class TwoFactor implements ISettings { /** @var MandatoryTwoFactor */ private $mandatoryTwoFactor; - /** @var IUserSession */ - private $userSession; - - /** @var string|null */ - private $uid; - - /** @var IConfig */ - private $config; - - public function __construct(ProviderLoader $providerLoader, + public function __construct( + ProviderLoader $providerLoader, MandatoryTwoFactor $mandatoryTwoFactor, - IUserSession $userSession, - IConfig $config, - ?string $UserId) { + private IUserSession $userSession, + private IConfig $config, + private ?string $uid, + ) { $this->providerLoader = $providerLoader; $this->mandatoryTwoFactor = $mandatoryTwoFactor; - $this->userSession = $userSession; - $this->uid = $UserId; - $this->config = $config; } public function getForm(): TemplateResponse { diff --git a/apps/settings/lib/Settings/Personal/Security/WebAuthn.php b/apps/settings/lib/Settings/Personal/Security/WebAuthn.php index e65004e7dd3..cfb29e4d493 100644 --- a/apps/settings/lib/Settings/Personal/Security/WebAuthn.php +++ b/apps/settings/lib/Settings/Personal/Security/WebAuthn.php @@ -20,22 +20,16 @@ class WebAuthn implements ISettings { /** @var PublicKeyCredentialMapper */ private $mapper; - /** @var string */ - private $uid; - - /** @var IInitialStateService */ - private $initialStateService; - /** @var Manager */ private $manager; - public function __construct(PublicKeyCredentialMapper $mapper, - string $UserId, - IInitialStateService $initialStateService, - Manager $manager) { + public function __construct( + PublicKeyCredentialMapper $mapper, + private string $uid, + private IInitialStateService $initialStateService, + Manager $manager, + ) { $this->mapper = $mapper; - $this->uid = $UserId; - $this->initialStateService = $initialStateService; $this->manager = $manager; } diff --git a/apps/settings/lib/Settings/Personal/ServerDevNotice.php b/apps/settings/lib/Settings/Personal/ServerDevNotice.php index 5a2901e4af9..71c83740b92 100644 --- a/apps/settings/lib/Settings/Personal/ServerDevNotice.php +++ b/apps/settings/lib/Settings/Personal/ServerDevNotice.php @@ -18,36 +18,14 @@ use OCP\Util; class ServerDevNotice implements ISettings { - /** @var IRegistry */ - private $registry; - - /** @var IEventDispatcher */ - private $eventDispatcher; - - /** @var IRootFolder */ - private $rootFolder; - - /** @var IUserSession */ - private $userSession; - - /** @var IInitialState */ - private $initialState; - - /** @var IURLGenerator */ - private $urlGenerator; - - public function __construct(IRegistry $registry, - IEventDispatcher $eventDispatcher, - IRootFolder $rootFolder, - IUserSession $userSession, - IInitialState $initialState, - IURLGenerator $urlGenerator) { - $this->registry = $registry; - $this->eventDispatcher = $eventDispatcher; - $this->rootFolder = $rootFolder; - $this->userSession = $userSession; - $this->initialState = $initialState; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IRegistry $registry, + private IEventDispatcher $eventDispatcher, + private IRootFolder $rootFolder, + private IUserSession $userSession, + private IInitialState $initialState, + private IURLGenerator $urlGenerator, + ) { } /** diff --git a/apps/settings/lib/UserMigration/AccountMigrator.php b/apps/settings/lib/UserMigration/AccountMigrator.php index 4306c63560e..15ac06687b6 100644 --- a/apps/settings/lib/UserMigration/AccountMigrator.php +++ b/apps/settings/lib/UserMigration/AccountMigrator.php @@ -33,16 +33,10 @@ class AccountMigrator implements IMigrator, ISizeEstimationMigrator { use TAccountsHelper; - private IAccountManager $accountManager; - - private IAvatarManager $avatarManager; - private ProfileManager $profileManager; private ProfileConfigMapper $configMapper; - private IL10N $l10n; - private const PATH_ROOT = Application::APP_ID . '/'; private const PATH_ACCOUNT_FILE = AccountMigrator::PATH_ROOT . 'account.json'; @@ -52,17 +46,14 @@ class AccountMigrator implements IMigrator, ISizeEstimationMigrator { private const PATH_CONFIG_FILE = AccountMigrator::PATH_ROOT . 'config.json'; public function __construct( - IAccountManager $accountManager, - IAvatarManager $avatarManager, + private IAccountManager $accountManager, + private IAvatarManager $avatarManager, ProfileManager $profileManager, ProfileConfigMapper $configMapper, - IL10N $l10n, + private IL10N $l10n, ) { - $this->accountManager = $accountManager; - $this->avatarManager = $avatarManager; $this->profileManager = $profileManager; $this->configMapper = $configMapper; - $this->l10n = $l10n; } /** diff --git a/apps/settings/lib/WellKnown/ChangePasswordHandler.php b/apps/settings/lib/WellKnown/ChangePasswordHandler.php index 0057a7ff330..9609579ef0a 100644 --- a/apps/settings/lib/WellKnown/ChangePasswordHandler.php +++ b/apps/settings/lib/WellKnown/ChangePasswordHandler.php @@ -18,10 +18,9 @@ use OCP\IURLGenerator; class ChangePasswordHandler implements IHandler { - private IURLGenerator $urlGenerator; - - public function __construct(IURLGenerator $urlGenerator) { - $this->urlGenerator = $urlGenerator; + public function __construct( + private IURLGenerator $urlGenerator, + ) { } public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse { diff --git a/apps/sharebymail/lib/Activity.php b/apps/sharebymail/lib/Activity.php index be9deeb7290..ae3407c1e2b 100644 --- a/apps/sharebymail/lib/Activity.php +++ b/apps/sharebymail/lib/Activity.php @@ -16,23 +16,9 @@ use OCP\IUserManager; use OCP\L10N\IFactory; class Activity implements IProvider { - /** @var IFactory */ - protected $languageFactory; - /** @var IL10N */ protected $l; - /** @var IURLGenerator */ - protected $url; - - /** @var IManager */ - protected $activityManager; - - /** @var IUserManager */ - protected $userManager; - /** @var IContactsManager */ - protected $contactsManager; - /** @var array */ protected $contactNames = []; @@ -50,12 +36,13 @@ class Activity implements IProvider { * @param IUserManager $userManager * @param IContactsManager $contactsManager */ - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IContactsManager $contactsManager) { - $this->languageFactory = $languageFactory; - $this->url = $url; - $this->activityManager = $activityManager; - $this->userManager = $userManager; - $this->contactsManager = $contactsManager; + public function __construct( + protected IFactory $languageFactory, + protected IURLGenerator $url, + protected IManager $activityManager, + protected IUserManager $userManager, + protected IContactsManager $contactsManager, + ) { } /** diff --git a/apps/sharebymail/lib/Capabilities.php b/apps/sharebymail/lib/Capabilities.php index ff6f634747b..5b489b7d790 100644 --- a/apps/sharebymail/lib/Capabilities.php +++ b/apps/sharebymail/lib/Capabilities.php @@ -15,21 +15,11 @@ use OCP\Share\IManager; class Capabilities implements ICapability { - /** @var IManager */ - private $manager; - - /** @var SettingsManager */ - private $settingsManager; - - /** @var IAppManager */ - private $appManager; - - public function __construct(IManager $manager, - SettingsManager $settingsManager, - IAppManager $appManager) { - $this->manager = $manager; - $this->settingsManager = $settingsManager; - $this->appManager = $appManager; + public function __construct( + private IManager $manager, + private SettingsManager $settingsManager, + private IAppManager $appManager, + ) { } /** diff --git a/apps/sharebymail/lib/Settings/Admin.php b/apps/sharebymail/lib/Settings/Admin.php index 5fdf633bea1..2bd58f7307f 100644 --- a/apps/sharebymail/lib/Settings/Admin.php +++ b/apps/sharebymail/lib/Settings/Admin.php @@ -11,14 +11,11 @@ use OCP\IL10N; use OCP\Settings\IDelegatedSettings; class Admin implements IDelegatedSettings { - private SettingsManager $settingsManager; - private IL10N $l; - private IInitialState $initialState; - - public function __construct(SettingsManager $settingsManager, IL10N $l, IInitialState $initialState) { - $this->settingsManager = $settingsManager; - $this->l = $l; - $this->initialState = $initialState; + public function __construct( + private SettingsManager $settingsManager, + private IL10N $l, + private IInitialState $initialState, + ) { } /** diff --git a/apps/sharebymail/lib/Settings/SettingsManager.php b/apps/sharebymail/lib/Settings/SettingsManager.php index c58f4950e91..d487bd2ac43 100644 --- a/apps/sharebymail/lib/Settings/SettingsManager.php +++ b/apps/sharebymail/lib/Settings/SettingsManager.php @@ -12,15 +12,13 @@ use OCP\IConfig; class SettingsManager { - /** @var IConfig */ - private $config; - private $sendPasswordByMailDefault = 'yes'; private $replyToInitiatorDefault = 'yes'; - public function __construct(IConfig $config) { - $this->config = $config; + public function __construct( + private IConfig $config, + ) { } /** diff --git a/apps/systemtags/lib/Activity/Listener.php b/apps/systemtags/lib/Activity/Listener.php index 7ab00787a76..d255ef2b91f 100644 --- a/apps/systemtags/lib/Activity/Listener.php +++ b/apps/systemtags/lib/Activity/Listener.php @@ -25,25 +25,6 @@ use OCP\SystemTag\MapperEvent; use OCP\SystemTag\TagNotFoundException; class Listener { - /** @var IGroupManager */ - protected $groupManager; - /** @var IManager */ - protected $activityManager; - /** @var IUserSession */ - protected $session; - /** @var IConfig */ - protected $config; - /** @var \OCP\SystemTag\ISystemTagManager */ - protected $tagManager; - /** @var \OCP\App\IAppManager */ - protected $appManager; - /** @var \OCP\Files\Config\IMountProviderCollection */ - protected $mountCollection; - /** @var \OCP\Files\IRootFolder */ - protected $rootFolder; - /** @var IShareHelper */ - protected $shareHelper; - /** * Listener constructor. * @@ -57,24 +38,17 @@ class Listener { * @param IRootFolder $rootFolder * @param IShareHelper $shareHelper */ - public function __construct(IGroupManager $groupManager, - IManager $activityManager, - IUserSession $session, - IConfig $config, - ISystemTagManager $tagManager, - IAppManager $appManager, - IMountProviderCollection $mountCollection, - IRootFolder $rootFolder, - IShareHelper $shareHelper) { - $this->groupManager = $groupManager; - $this->activityManager = $activityManager; - $this->session = $session; - $this->config = $config; - $this->tagManager = $tagManager; - $this->appManager = $appManager; - $this->mountCollection = $mountCollection; - $this->rootFolder = $rootFolder; - $this->shareHelper = $shareHelper; + public function __construct( + protected IGroupManager $groupManager, + protected IManager $activityManager, + protected IUserSession $session, + protected IConfig $config, + protected ISystemTagManager $tagManager, + protected IAppManager $appManager, + protected IMountProviderCollection $mountCollection, + protected IRootFolder $rootFolder, + protected IShareHelper $shareHelper, + ) { } /** diff --git a/apps/systemtags/lib/Activity/Provider.php b/apps/systemtags/lib/Activity/Provider.php index 05c19fe81cc..e2abebab208 100644 --- a/apps/systemtags/lib/Activity/Provider.php +++ b/apps/systemtags/lib/Activity/Provider.php @@ -22,32 +22,21 @@ class Provider implements IProvider { public const ASSIGN_TAG = 'assign_tag'; public const UNASSIGN_TAG = 'unassign_tag'; - /** @var IFactory */ - protected $languageFactory; - /** @var IL10N */ protected $l; - /** @var IURLGenerator */ - protected $url; - - /** @var IManager */ - protected $activityManager; - - /** @var IUserManager */ - protected $userManager; - /** * @param IFactory $languageFactory * @param IURLGenerator $url * @param IManager $activityManager * @param IUserManager $userManager */ - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager) { - $this->languageFactory = $languageFactory; - $this->url = $url; - $this->activityManager = $activityManager; - $this->userManager = $userManager; + public function __construct( + protected IFactory $languageFactory, + protected IURLGenerator $url, + protected IManager $activityManager, + protected IUserManager $userManager, + ) { } /** diff --git a/apps/systemtags/lib/Controller/LastUsedController.php b/apps/systemtags/lib/Controller/LastUsedController.php index ccdeddd9270..c1919290de0 100644 --- a/apps/systemtags/lib/Controller/LastUsedController.php +++ b/apps/systemtags/lib/Controller/LastUsedController.php @@ -14,22 +14,19 @@ use OCP\IUserSession; class LastUsedController extends Controller { - /** @var IConfig */ - protected $config; - - /** @var IUserSession */ - protected $userSession; - /** * @param string $appName * @param IRequest $request * @param IConfig $config * @param IUserSession $userSession */ - public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) { + public function __construct( + $appName, + IRequest $request, + protected IConfig $config, + protected IUserSession $userSession, + ) { parent::__construct($appName, $request); - $this->config = $config; - $this->userSession = $userSession; } #[NoAdminRequired] diff --git a/apps/systemtags/lib/Search/TagSearchProvider.php b/apps/systemtags/lib/Search/TagSearchProvider.php index d09befd194e..56b8e4028b0 100644 --- a/apps/systemtags/lib/Search/TagSearchProvider.php +++ b/apps/systemtags/lib/Search/TagSearchProvider.php @@ -32,34 +32,14 @@ use RecursiveIteratorIterator; class TagSearchProvider implements IProvider { - /** @var IL10N */ - private $l10n; - - /** @var IURLGenerator */ - private $urlGenerator; - - /** @var IMimeTypeDetector */ - private $mimeTypeDetector; - - /** @var IRootFolder */ - private $rootFolder; - private ISystemTagObjectMapper $objectMapper; - private ISystemTagManager $tagManager; - public function __construct( - IL10N $l10n, - IURLGenerator $urlGenerator, - IMimeTypeDetector $mimeTypeDetector, - IRootFolder $rootFolder, - ISystemTagObjectMapper $objectMapper, - ISystemTagManager $tagManager, + private IL10N $l10n, + private IURLGenerator $urlGenerator, + private IMimeTypeDetector $mimeTypeDetector, + private IRootFolder $rootFolder, + private ISystemTagObjectMapper $objectMapper, + private ISystemTagManager $tagManager, ) { - $this->l10n = $l10n; - $this->urlGenerator = $urlGenerator; - $this->mimeTypeDetector = $mimeTypeDetector; - $this->rootFolder = $rootFolder; - $this->objectMapper = $objectMapper; - $this->tagManager = $tagManager; } /** diff --git a/apps/testing/lib/Controller/ConfigController.php b/apps/testing/lib/Controller/ConfigController.php index 7cd27b7ab58..36cc4fff9aa 100644 --- a/apps/testing/lib/Controller/ConfigController.php +++ b/apps/testing/lib/Controller/ConfigController.php @@ -13,19 +13,17 @@ use OCP\IRequest; class ConfigController extends OCSController { - /** @var IConfig */ - private $config; - /** * @param string $appName * @param IRequest $request * @param IConfig $config */ - public function __construct($appName, + public function __construct( + $appName, IRequest $request, - IConfig $config) { + private IConfig $config, + ) { parent::__construct($appName, $request); - $this->config = $config; } /** diff --git a/apps/testing/lib/Controller/LockingController.php b/apps/testing/lib/Controller/LockingController.php index 14135a4929d..e226126630f 100644 --- a/apps/testing/lib/Controller/LockingController.php +++ b/apps/testing/lib/Controller/LockingController.php @@ -23,21 +23,6 @@ use OCP\Lock\LockedException; class LockingController extends OCSController { - /** @var ILockingProvider */ - protected $lockingProvider; - - /** @var FakeDBLockingProvider */ - protected $fakeDBLockingProvider; - - /** @var IDBConnection */ - protected $connection; - - /** @var IConfig */ - protected $config; - - /** @var IRootFolder */ - protected $rootFolder; - /** * @param string $appName * @param IRequest $request @@ -47,20 +32,16 @@ class LockingController extends OCSController { * @param IConfig $config * @param IRootFolder $rootFolder */ - public function __construct($appName, + public function __construct( + $appName, IRequest $request, - ILockingProvider $lockingProvider, - FakeDBLockingProvider $fakeDBLockingProvider, - IDBConnection $connection, - IConfig $config, - IRootFolder $rootFolder) { + protected ILockingProvider $lockingProvider, + protected FakeDBLockingProvider $fakeDBLockingProvider, + protected IDBConnection $connection, + protected IConfig $config, + protected IRootFolder $rootFolder, + ) { parent::__construct($appName, $request); - - $this->lockingProvider = $lockingProvider; - $this->fakeDBLockingProvider = $fakeDBLockingProvider; - $this->connection = $connection; - $this->config = $config; - $this->rootFolder = $rootFolder; } /** diff --git a/apps/theming/lib/Capabilities.php b/apps/theming/lib/Capabilities.php index bd3dd45741d..b6145298d95 100644 --- a/apps/theming/lib/Capabilities.php +++ b/apps/theming/lib/Capabilities.php @@ -20,32 +20,19 @@ use OCP\IUserSession; */ class Capabilities implements IPublicCapability { - /** @var ThemingDefaults */ - protected $theming; - - /** @var Util */ - protected $util; - - /** @var IURLGenerator */ - protected $url; - - /** @var IConfig */ - protected $config; - - protected IUserSession $userSession; - /** * @param ThemingDefaults $theming * @param Util $util * @param IURLGenerator $url * @param IConfig $config */ - public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator $url, IConfig $config, IUserSession $userSession) { - $this->theming = $theming; - $this->util = $util; - $this->url = $url; - $this->config = $config; - $this->userSession = $userSession; + public function __construct( + protected ThemingDefaults $theming, + protected Util $util, + protected IURLGenerator $url, + protected IConfig $config, + protected IUserSession $userSession, + ) { } /** diff --git a/apps/theming/lib/Command/UpdateConfig.php b/apps/theming/lib/Command/UpdateConfig.php index 3a3f3f0c767..89e47688372 100644 --- a/apps/theming/lib/Command/UpdateConfig.php +++ b/apps/theming/lib/Command/UpdateConfig.php @@ -19,16 +19,12 @@ class UpdateConfig extends Command { 'name', 'url', 'imprintUrl', 'privacyUrl', 'slogan', 'color', 'primary_color', 'disable-user-theming' ]; - private $themingDefaults; - private $imageManager; - private $config; - - public function __construct(ThemingDefaults $themingDefaults, ImageManager $imageManager, IConfig $config) { + public function __construct( + private ThemingDefaults $themingDefaults, + private ImageManager $imageManager, + private IConfig $config, + ) { parent::__construct(); - - $this->themingDefaults = $themingDefaults; - $this->imageManager = $imageManager; - $this->config = $config; } protected function configure() { diff --git a/apps/theming/lib/Controller/IconController.php b/apps/theming/lib/Controller/IconController.php index 7ba9e801d9b..acb59c9a86f 100644 --- a/apps/theming/lib/Controller/IconController.php +++ b/apps/theming/lib/Controller/IconController.php @@ -22,33 +22,20 @@ use OCP\Files\NotFoundException; use OCP\IRequest; class IconController extends Controller { - /** @var ThemingDefaults */ - private $themingDefaults; - /** @var IconBuilder */ - private $iconBuilder; - /** @var ImageManager */ - private $imageManager; /** @var FileAccessHelper */ private $fileAccessHelper; - /** @var IAppManager */ - private $appManager; public function __construct( $appName, IRequest $request, - ThemingDefaults $themingDefaults, - IconBuilder $iconBuilder, - ImageManager $imageManager, + private ThemingDefaults $themingDefaults, + private IconBuilder $iconBuilder, + private ImageManager $imageManager, FileAccessHelper $fileAccessHelper, - IAppManager $appManager, + private IAppManager $appManager, ) { parent::__construct($appName, $request); - - $this->themingDefaults = $themingDefaults; - $this->iconBuilder = $iconBuilder; - $this->imageManager = $imageManager; $this->fileAccessHelper = $fileAccessHelper; - $this->appManager = $appManager; } /** diff --git a/apps/theming/lib/Controller/UserThemeController.php b/apps/theming/lib/Controller/UserThemeController.php index f75c46de85c..9bcf32daa9c 100644 --- a/apps/theming/lib/Controller/UserThemeController.php +++ b/apps/theming/lib/Controller/UserThemeController.php @@ -37,23 +37,16 @@ class UserThemeController extends OCSController { protected ?string $userId = null; - private IConfig $config; - private ThemesService $themesService; - private ThemingDefaults $themingDefaults; - private BackgroundService $backgroundService; - - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - IConfig $config, + private IConfig $config, IUserSession $userSession, - ThemesService $themesService, - ThemingDefaults $themingDefaults, - BackgroundService $backgroundService) { + private ThemesService $themesService, + private ThemingDefaults $themingDefaults, + private BackgroundService $backgroundService, + ) { parent::__construct($appName, $request); - $this->config = $config; - $this->themesService = $themesService; - $this->themingDefaults = $themingDefaults; - $this->backgroundService = $backgroundService; $user = $userSession->getUser(); if ($user !== null) { diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php index 5e8754dec83..4ab9857e2ce 100644 --- a/apps/theming/lib/IconBuilder.php +++ b/apps/theming/lib/IconBuilder.php @@ -10,13 +10,6 @@ use ImagickPixel; use OCP\Files\SimpleFS\ISimpleFile; class IconBuilder { - /** @var ThemingDefaults */ - private $themingDefaults; - /** @var Util */ - private $util; - /** @var ImageManager */ - private $imageManager; - /** * IconBuilder constructor. * @@ -25,13 +18,10 @@ class IconBuilder { * @param ImageManager $imageManager */ public function __construct( - ThemingDefaults $themingDefaults, - Util $util, - ImageManager $imageManager, + private ThemingDefaults $themingDefaults, + private Util $util, + private ImageManager $imageManager, ) { - $this->themingDefaults = $themingDefaults; - $this->util = $util; - $this->imageManager = $imageManager; } /** diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php index 4afdedf5189..83828130425 100644 --- a/apps/theming/lib/ImageManager.php +++ b/apps/theming/lib/ImageManager.php @@ -152,7 +152,7 @@ class ImageManager { * * @param string $filename * @throws NotFoundException - * @return \OCP\Files\SimpleFS\ISimpleFile + * @return ISimpleFile * @throws NotPermittedException */ public function getCachedImage(string $filename): ISimpleFile { @@ -165,7 +165,7 @@ class ImageManager { * * @param string $filename * @param string $data - * @return \OCP\Files\SimpleFS\ISimpleFile + * @return ISimpleFile * @throws NotFoundException * @throws NotPermittedException */ diff --git a/apps/theming/lib/Jobs/MigrateBackgroundImages.php b/apps/theming/lib/Jobs/MigrateBackgroundImages.php index 6bf1dd4e5bc..62e58f5e722 100644 --- a/apps/theming/lib/Jobs/MigrateBackgroundImages.php +++ b/apps/theming/lib/Jobs/MigrateBackgroundImages.php @@ -30,26 +30,15 @@ class MigrateBackgroundImages extends QueuedJob { // will be saved in appdata/theming/global/ protected const STATE_FILE_NAME = '25_dashboard_to_theming_migration_users.json'; - private IAppDataFactory $appDataFactory; - private IJobList $jobList; - private IDBConnection $dbc; - private IAppData $appData; - private LoggerInterface $logger; - public function __construct( ITimeFactory $time, - IAppDataFactory $appDataFactory, - IJobList $jobList, - IDBConnection $dbc, - IAppData $appData, - LoggerInterface $logger, + private IAppDataFactory $appDataFactory, + private IJobList $jobList, + private IDBConnection $dbc, + private IAppData $appData, + private LoggerInterface $logger, ) { parent::__construct($time); - $this->appDataFactory = $appDataFactory; - $this->jobList = $jobList; - $this->dbc = $dbc; - $this->appData = $appData; - $this->logger = $logger; } protected function run(mixed $argument): void { diff --git a/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php b/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php index 3aae9417458..18ab9392b97 100644 --- a/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php +++ b/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php @@ -25,24 +25,13 @@ use Psr\Container\ContainerInterface; /** @template-implements IEventListener<BeforeTemplateRenderedEvent|BeforeLoginTemplateRenderedEvent> */ class BeforeTemplateRenderedListener implements IEventListener { - private IInitialState $initialState; - private ContainerInterface $container; - private ThemeInjectionService $themeInjectionService; - private IUserSession $userSession; - private IConfig $config; - public function __construct( - IInitialState $initialState, - ContainerInterface $container, - ThemeInjectionService $themeInjectionService, - IUserSession $userSession, - IConfig $config, + private IInitialState $initialState, + private ContainerInterface $container, + private ThemeInjectionService $themeInjectionService, + private IUserSession $userSession, + private IConfig $config, ) { - $this->initialState = $initialState; - $this->container = $container; - $this->themeInjectionService = $themeInjectionService; - $this->userSession = $userSession; - $this->config = $config; } public function handle(Event $event): void { diff --git a/apps/theming/lib/Migration/InitBackgroundImagesMigration.php b/apps/theming/lib/Migration/InitBackgroundImagesMigration.php index 0f0a019a490..dea1bb3aa83 100644 --- a/apps/theming/lib/Migration/InitBackgroundImagesMigration.php +++ b/apps/theming/lib/Migration/InitBackgroundImagesMigration.php @@ -16,10 +16,9 @@ use OCP\Migration\IRepairStep; class InitBackgroundImagesMigration implements IRepairStep { - private IJobList $jobList; - - public function __construct(IJobList $jobList) { - $this->jobList = $jobList; + public function __construct( + private IJobList $jobList, + ) { } public function getName() { diff --git a/apps/theming/lib/Service/ThemeInjectionService.php b/apps/theming/lib/Service/ThemeInjectionService.php index 3c7bf1ce544..f780f5484bd 100644 --- a/apps/theming/lib/Service/ThemeInjectionService.php +++ b/apps/theming/lib/Service/ThemeInjectionService.php @@ -14,25 +14,16 @@ use OCP\IUserSession; class ThemeInjectionService { - private IURLGenerator $urlGenerator; - private ThemesService $themesService; - private DefaultTheme $defaultTheme; - private Util $util; - private IConfig $config; private ?string $userId; - public function __construct(IURLGenerator $urlGenerator, - ThemesService $themesService, - DefaultTheme $defaultTheme, - Util $util, - IConfig $config, - IUserSession $userSession) { - $this->urlGenerator = $urlGenerator; - $this->themesService = $themesService; - $this->defaultTheme = $defaultTheme; - $this->util = $util; - $this->config = $config; - + public function __construct( + private IURLGenerator $urlGenerator, + private ThemesService $themesService, + private DefaultTheme $defaultTheme, + private Util $util, + private IConfig $config, + IUserSession $userSession, + ) { if ($userSession->getUser() !== null) { $this->userId = $userSession->getUser()->getUID(); } else { diff --git a/apps/theming/lib/Settings/AdminSection.php b/apps/theming/lib/Settings/AdminSection.php index 696c62672b9..a659204e722 100644 --- a/apps/theming/lib/Settings/AdminSection.php +++ b/apps/theming/lib/Settings/AdminSection.php @@ -10,14 +10,11 @@ use OCP\IURLGenerator; use OCP\Settings\IIconSection; class AdminSection implements IIconSection { - private string $appName; - private IL10N $l; - private IURLGenerator $url; - - public function __construct(string $appName, IURLGenerator $url, IL10N $l) { - $this->appName = $appName; - $this->url = $url; - $this->l = $l; + public function __construct( + private string $appName, + private IURLGenerator $url, + private IL10N $l, + ) { } /** diff --git a/apps/theming/lib/Settings/PersonalSection.php b/apps/theming/lib/Settings/PersonalSection.php index 91121b32a6e..851f122eed1 100644 --- a/apps/theming/lib/Settings/PersonalSection.php +++ b/apps/theming/lib/Settings/PersonalSection.php @@ -11,15 +11,6 @@ use OCP\Settings\IIconSection; class PersonalSection implements IIconSection { - /** @var string */ - protected $appName; - - /** @var IURLGenerator */ - private $urlGenerator; - - /** @var IL10N */ - private $l; - /** * Personal Section constructor. * @@ -27,12 +18,11 @@ class PersonalSection implements IIconSection { * @param IURLGenerator $urlGenerator * @param IL10N $l */ - public function __construct(string $appName, - IURLGenerator $urlGenerator, - IL10N $l) { - $this->appName = $appName; - $this->urlGenerator = $urlGenerator; - $this->l = $l; + public function __construct( + protected string $appName, + private IURLGenerator $urlGenerator, + private IL10N $l, + ) { } /** diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php index 18fa7de1cc8..42e841e9a0f 100644 --- a/apps/theming/tests/Controller/IconControllerTest.php +++ b/apps/theming/tests/Controller/IconControllerTest.php @@ -26,7 +26,7 @@ class IconControllerTest extends TestCase { private $request; /** @var ThemingDefaults|\PHPUnit\Framework\MockObject\MockObject */ private $themingDefaults; - /** @var \OCP\AppFramework\Utility\ITimeFactory */ + /** @var ITimeFactory */ private $timeFactory; /** @var IconController|\PHPUnit\Framework\MockObject\MockObject */ private $iconController; diff --git a/apps/theming/tests/ServicesTest.php b/apps/theming/tests/ServicesTest.php index 3223de0a489..516a1fca776 100644 --- a/apps/theming/tests/ServicesTest.php +++ b/apps/theming/tests/ServicesTest.php @@ -12,6 +12,7 @@ use OCA\Theming\Settings\PersonalSection; use OCA\Theming\ThemingDefaults; use OCA\Theming\Util; use OCP\AppFramework\App; +use OCP\AppFramework\IAppContainer; use OCP\Capabilities\ICapability; use OCP\IL10N; use OCP\Settings\IIconSection; @@ -28,7 +29,7 @@ class ServicesTest extends TestCase { /** @var \OCA\Activity\AppInfo\Application */ protected $app; - /** @var \OCP\AppFramework\IAppContainer */ + /** @var IAppContainer */ protected $container; protected function setUp(): void { diff --git a/apps/twofactor_backupcodes/lib/Activity/Provider.php b/apps/twofactor_backupcodes/lib/Activity/Provider.php index 7bf0db04e77..eba38147bd7 100644 --- a/apps/twofactor_backupcodes/lib/Activity/Provider.php +++ b/apps/twofactor_backupcodes/lib/Activity/Provider.php @@ -17,24 +17,16 @@ use OCP\L10N\IFactory as L10nFactory; class Provider implements IProvider { - /** @var L10nFactory */ - private $l10n; - - /** @var IURLGenerator */ - private $urlGenerator; - - /** @var IManager */ - private $activityManager; - /** * @param L10nFactory $l10n * @param IURLGenerator $urlGenerator * @param IManager $activityManager */ - public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IManager $activityManager) { - $this->urlGenerator = $urlGenerator; - $this->activityManager = $activityManager; - $this->l10n = $l10n; + public function __construct( + private L10nFactory $l10n, + private IURLGenerator $urlGenerator, + private IManager $activityManager, + ) { } public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent { diff --git a/apps/twofactor_backupcodes/lib/BackgroundJob/CheckBackupCodes.php b/apps/twofactor_backupcodes/lib/BackgroundJob/CheckBackupCodes.php index 68965583c1b..bc26cb260f4 100644 --- a/apps/twofactor_backupcodes/lib/BackgroundJob/CheckBackupCodes.php +++ b/apps/twofactor_backupcodes/lib/BackgroundJob/CheckBackupCodes.php @@ -18,24 +18,18 @@ use OCP\IUserManager; class CheckBackupCodes extends QueuedJob { - /** @var IUserManager */ - private $userManager; - - /** @var IJobList */ - private $jobList; - - /** @var IRegistry */ - private $registry; - /** @var Manager */ private $twofactorManager; - public function __construct(ITimeFactory $timeFactory, IUserManager $userManager, IJobList $jobList, Manager $twofactorManager, IRegistry $registry) { + public function __construct( + ITimeFactory $timeFactory, + private IUserManager $userManager, + private IJobList $jobList, + Manager $twofactorManager, + private IRegistry $registry, + ) { parent::__construct($timeFactory); - $this->userManager = $userManager; - $this->jobList = $jobList; $this->twofactorManager = $twofactorManager; - $this->registry = $registry; } protected function run($argument) { diff --git a/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php b/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php index 61b93803a0d..5e853479f0a 100644 --- a/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php +++ b/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php @@ -17,29 +17,15 @@ use OCP\Notification\IManager; class RememberBackupCodesJob extends TimedJob { - /** @var IRegistry */ - private $registry; - - /** @var IUserManager */ - private $userManager; - - /** @var IManager */ - private $notificationManager; - - /** @var IJobList */ - private $jobList; - - public function __construct(IRegistry $registry, - IUserManager $userManager, + public function __construct( + private IRegistry $registry, + private IUserManager $userManager, ITimeFactory $timeFactory, - IManager $notificationManager, - IJobList $jobList) { + private IManager $notificationManager, + private IJobList $jobList, + ) { parent::__construct($timeFactory); - $this->registry = $registry; - $this->userManager = $userManager; $this->time = $timeFactory; - $this->notificationManager = $notificationManager; - $this->jobList = $jobList; $this->setInterval(60 * 60 * 24 * 14); $this->setTimeSensitivity(self::TIME_INSENSITIVE); diff --git a/apps/twofactor_backupcodes/lib/Controller/SettingsController.php b/apps/twofactor_backupcodes/lib/Controller/SettingsController.php index 7982ce382c4..effc058e05c 100644 --- a/apps/twofactor_backupcodes/lib/Controller/SettingsController.php +++ b/apps/twofactor_backupcodes/lib/Controller/SettingsController.php @@ -18,22 +18,19 @@ use OCP\IUserSession; class SettingsController extends Controller { - /** @var BackupCodeStorage */ - private $storage; - - /** @var IUserSession */ - private $userSession; - /** * @param string $appName * @param IRequest $request * @param BackupCodeStorage $storage * @param IUserSession $userSession */ - public function __construct($appName, IRequest $request, BackupCodeStorage $storage, IUserSession $userSession) { + public function __construct( + $appName, + IRequest $request, + private BackupCodeStorage $storage, + private IUserSession $userSession, + ) { parent::__construct($appName, $request); - $this->userSession = $userSession; - $this->storage = $storage; } /** diff --git a/apps/twofactor_backupcodes/lib/Event/CodesGenerated.php b/apps/twofactor_backupcodes/lib/Event/CodesGenerated.php index a9bc0ec3a02..90dc6206f71 100644 --- a/apps/twofactor_backupcodes/lib/Event/CodesGenerated.php +++ b/apps/twofactor_backupcodes/lib/Event/CodesGenerated.php @@ -13,12 +13,10 @@ use OCP\IUser; class CodesGenerated extends Event { - /** @var IUser */ - private $user; - - public function __construct(IUser $user) { + public function __construct( + private IUser $user, + ) { parent::__construct(); - $this->user = $user; } /** diff --git a/apps/twofactor_backupcodes/lib/Listener/ClearNotifications.php b/apps/twofactor_backupcodes/lib/Listener/ClearNotifications.php index d3206cbcbcc..46bb1583004 100644 --- a/apps/twofactor_backupcodes/lib/Listener/ClearNotifications.php +++ b/apps/twofactor_backupcodes/lib/Listener/ClearNotifications.php @@ -16,11 +16,9 @@ use OCP\Notification\IManager; /** @template-implements IEventListener<CodesGenerated> */ class ClearNotifications implements IEventListener { - /** @var IManager */ - private $manager; - - public function __construct(IManager $manager) { - $this->manager = $manager; + public function __construct( + private IManager $manager, + ) { } public function handle(Event $event): void { diff --git a/apps/twofactor_backupcodes/lib/Listener/ProviderDisabled.php b/apps/twofactor_backupcodes/lib/Listener/ProviderDisabled.php index 7218bbf1ba8..a8d51e55c1b 100644 --- a/apps/twofactor_backupcodes/lib/Listener/ProviderDisabled.php +++ b/apps/twofactor_backupcodes/lib/Listener/ProviderDisabled.php @@ -18,16 +18,10 @@ use OCP\EventDispatcher\IEventListener; /** @template-implements IEventListener<TwoFactorProviderForUserUnregistered> */ class ProviderDisabled implements IEventListener { - /** @var IRegistry */ - private $registry; - - /** @var IJobList */ - private $jobList; - - public function __construct(IRegistry $registry, - IJobList $jobList) { - $this->registry = $registry; - $this->jobList = $jobList; + public function __construct( + private IRegistry $registry, + private IJobList $jobList, + ) { } public function handle(Event $event): void { diff --git a/apps/twofactor_backupcodes/lib/Listener/ProviderEnabled.php b/apps/twofactor_backupcodes/lib/Listener/ProviderEnabled.php index e65794b98a5..4ec510e7194 100644 --- a/apps/twofactor_backupcodes/lib/Listener/ProviderEnabled.php +++ b/apps/twofactor_backupcodes/lib/Listener/ProviderEnabled.php @@ -18,16 +18,10 @@ use OCP\EventDispatcher\IEventListener; /** @template-implements IEventListener<TwoFactorProviderForUserRegistered> */ class ProviderEnabled implements IEventListener { - /** @var IRegistry */ - private $registry; - - /** @var IJobList */ - private $jobList; - - public function __construct(IRegistry $registry, - IJobList $jobList) { - $this->registry = $registry; - $this->jobList = $jobList; + public function __construct( + private IRegistry $registry, + private IJobList $jobList, + ) { } public function handle(Event $event): void { diff --git a/apps/twofactor_backupcodes/lib/Listener/RegistryUpdater.php b/apps/twofactor_backupcodes/lib/Listener/RegistryUpdater.php index 11c2371a655..1cb07bd9805 100644 --- a/apps/twofactor_backupcodes/lib/Listener/RegistryUpdater.php +++ b/apps/twofactor_backupcodes/lib/Listener/RegistryUpdater.php @@ -17,15 +17,10 @@ use OCP\EventDispatcher\IEventListener; /** @template-implements IEventListener<CodesGenerated> */ class RegistryUpdater implements IEventListener { - /** @var IRegistry */ - private $registry; - - /** @var BackupCodesProvider */ - private $provider; - - public function __construct(IRegistry $registry, BackupCodesProvider $provider) { - $this->registry = $registry; - $this->provider = $provider; + public function __construct( + private IRegistry $registry, + private BackupCodesProvider $provider, + ) { } public function handle(Event $event): void { diff --git a/apps/twofactor_backupcodes/lib/Listener/UserDeleted.php b/apps/twofactor_backupcodes/lib/Listener/UserDeleted.php index 22aeda1a45e..72fd504b338 100644 --- a/apps/twofactor_backupcodes/lib/Listener/UserDeleted.php +++ b/apps/twofactor_backupcodes/lib/Listener/UserDeleted.php @@ -16,11 +16,9 @@ use OCP\User\Events\UserDeletedEvent; /** @template-implements IEventListener<UserDeletedEvent> */ class UserDeleted implements IEventListener { - /** @var BackupCodeMapper */ - private $backupCodeMapper; - - public function __construct(BackupCodeMapper $backupCodeMapper) { - $this->backupCodeMapper = $backupCodeMapper; + public function __construct( + private BackupCodeMapper $backupCodeMapper, + ) { } public function handle(Event $event): void { diff --git a/apps/twofactor_backupcodes/lib/Migration/CheckBackupCodes.php b/apps/twofactor_backupcodes/lib/Migration/CheckBackupCodes.php index 1011f4486dc..9c0c676134b 100644 --- a/apps/twofactor_backupcodes/lib/Migration/CheckBackupCodes.php +++ b/apps/twofactor_backupcodes/lib/Migration/CheckBackupCodes.php @@ -14,11 +14,9 @@ use OCP\Migration\IRepairStep; class CheckBackupCodes implements IRepairStep { - /** @var IJobList */ - private $jobList; - - public function __construct(IJobList $jobList) { - $this->jobList = $jobList; + public function __construct( + private IJobList $jobList, + ) { } public function getName(): string { diff --git a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php index c76fc548cd9..bed733cd413 100644 --- a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php +++ b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php @@ -16,14 +16,12 @@ use OCP\Migration\SimpleMigrationStep; class Version1002Date20170607113030 extends SimpleMigrationStep { - /** @var IDBConnection */ - protected $connection; - /** * @param IDBConnection $connection */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; + public function __construct( + protected IDBConnection $connection, + ) { } /** diff --git a/apps/twofactor_backupcodes/lib/Notifications/Notifier.php b/apps/twofactor_backupcodes/lib/Notifications/Notifier.php index ec24a59641f..e8144f52a56 100644 --- a/apps/twofactor_backupcodes/lib/Notifications/Notifier.php +++ b/apps/twofactor_backupcodes/lib/Notifications/Notifier.php @@ -16,15 +16,10 @@ use OCP\Notification\UnknownNotificationException; class Notifier implements INotifier { - /** @var IFactory */ - private $factory; - - /** @var IURLGenerator */ - private $url; - - public function __construct(IFactory $factory, IURLGenerator $url) { - $this->factory = $factory; - $this->url = $url; + public function __construct( + private IFactory $factory, + private IURLGenerator $url, + ) { } /** diff --git a/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php b/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php index dc47cf0b323..8bb044448c1 100644 --- a/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php +++ b/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php @@ -21,19 +21,8 @@ use OCP\Template; class BackupCodesProvider implements IDeactivatableByAdmin, IProvidesPersonalSettings { - /** @var string */ - private $appName; - - /** @var BackupCodeStorage */ - private $storage; - - /** @var IL10N */ - private $l10n; - /** @var AppManager */ private $appManager; - /** @var IInitialStateService */ - private $initialStateService; /** * @param string $appName @@ -41,16 +30,14 @@ class BackupCodesProvider implements IDeactivatableByAdmin, IProvidesPersonalSet * @param IL10N $l10n * @param AppManager $appManager */ - public function __construct(string $appName, - BackupCodeStorage $storage, - IL10N $l10n, + public function __construct( + private string $appName, + private BackupCodeStorage $storage, + private IL10N $l10n, AppManager $appManager, - IInitialStateService $initialStateService) { - $this->appName = $appName; - $this->l10n = $l10n; - $this->storage = $storage; + private IInitialStateService $initialStateService, + ) { $this->appManager = $appManager; - $this->initialStateService = $initialStateService; } /** diff --git a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php index ef6c21d8e0b..7dd6b3949e2 100644 --- a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php +++ b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php @@ -19,26 +19,12 @@ use OCP\Security\ISecureRandom; class BackupCodeStorage { private static $CODE_LENGTH = 16; - /** @var BackupCodeMapper */ - private $mapper; - - /** @var IHasher */ - private $hasher; - - /** @var ISecureRandom */ - private $random; - - /** @var IEventDispatcher */ - private $eventDispatcher; - - public function __construct(BackupCodeMapper $mapper, - ISecureRandom $random, - IHasher $hasher, - IEventDispatcher $eventDispatcher) { - $this->mapper = $mapper; - $this->hasher = $hasher; - $this->random = $random; - $this->eventDispatcher = $eventDispatcher; + public function __construct( + private BackupCodeMapper $mapper, + private ISecureRandom $random, + private IHasher $hasher, + private IEventDispatcher $eventDispatcher, + ) { } /** diff --git a/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php b/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php index dc42c8c0bdc..cbda9dd868b 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php @@ -80,7 +80,7 @@ class NotifierTest extends TestCase { } public function testPrepare(): void { - /** @var \OCP\Notification\INotification|\PHPUnit\Framework\MockObject\MockObject $notification */ + /** @var INotification|\PHPUnit\Framework\MockObject\MockObject $notification */ $notification = $this->createMock(INotification::class); $notification->expects($this->once()) diff --git a/apps/updatenotification/lib/Command/Check.php b/apps/updatenotification/lib/Command/Check.php index a66e729e8a7..233492eb73e 100644 --- a/apps/updatenotification/lib/Command/Check.php +++ b/apps/updatenotification/lib/Command/Check.php @@ -27,16 +27,14 @@ class Check extends Command { */ private $appManager; - /** - * @var UpdateChecker $updateChecker - */ - private $updateChecker; - - public function __construct(AppManager $appManager, UpdateChecker $updateChecker, Installer $installer) { + public function __construct( + AppManager $appManager, + private UpdateChecker $updateChecker, + Installer $installer, + ) { parent::__construct(); $this->installer = $installer; $this->appManager = $appManager; - $this->updateChecker = $updateChecker; } protected function configure(): void { diff --git a/apps/updatenotification/lib/Notification/Notifier.php b/apps/updatenotification/lib/Notification/Notifier.php index 7b270547bbb..8cee44144b2 100644 --- a/apps/updatenotification/lib/Notification/Notifier.php +++ b/apps/updatenotification/lib/Notification/Notifier.php @@ -24,24 +24,6 @@ use OCP\Server; use OCP\Util; class Notifier implements INotifier { - /** @var IURLGenerator */ - protected $url; - - /** @var IConfig */ - protected $config; - - /** @var IManager */ - protected $notificationManager; - - /** @var IFactory */ - protected $l10NFactory; - - /** @var IUserSession */ - protected $userSession; - - /** @var IGroupManager */ - protected $groupManager; - /** @var string[] */ protected $appVersions; @@ -55,13 +37,14 @@ class Notifier implements INotifier { * @param IUserSession $userSession * @param IGroupManager $groupManager */ - public function __construct(IURLGenerator $url, IConfig $config, IManager $notificationManager, IFactory $l10NFactory, IUserSession $userSession, IGroupManager $groupManager) { - $this->url = $url; - $this->notificationManager = $notificationManager; - $this->config = $config; - $this->l10NFactory = $l10NFactory; - $this->userSession = $userSession; - $this->groupManager = $groupManager; + public function __construct( + protected IURLGenerator $url, + protected IConfig $config, + protected IManager $notificationManager, + protected IFactory $l10NFactory, + protected IUserSession $userSession, + protected IGroupManager $groupManager, + ) { $this->appVersions = $this->getAppVersions(); } diff --git a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php index a30a5116dcf..b8d428899fd 100644 --- a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php +++ b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php @@ -452,7 +452,7 @@ class UpdateAvailableNotificationsTest extends TestCase { /** * @param string $gid - * @return \OCP\IGroup|MockObject + * @return IGroup|MockObject */ protected function getGroup(string $gid) { $group = $this->createMock(IGroup::class); diff --git a/apps/user_ldap/lib/BackendUtility.php b/apps/user_ldap/lib/BackendUtility.php index 0e797abb8dc..88d7311cde0 100644 --- a/apps/user_ldap/lib/BackendUtility.php +++ b/apps/user_ldap/lib/BackendUtility.php @@ -8,13 +8,12 @@ namespace OCA\User_LDAP; abstract class BackendUtility { - protected $access; - /** * constructor, make sure the subclasses call this one! * @param Access $access an instance of Access for LDAP interaction */ - public function __construct(Access $access) { - $this->access = $access; + public function __construct( + protected Access $access, + ) { } } diff --git a/apps/user_ldap/lib/Command/CheckUser.php b/apps/user_ldap/lib/Command/CheckUser.php index d5bd0235b2c..8bb26ce3d0e 100644 --- a/apps/user_ldap/lib/Command/CheckUser.php +++ b/apps/user_ldap/lib/Command/CheckUser.php @@ -18,15 +18,12 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class CheckUser extends Command { - protected User_Proxy $backend; - public function __construct( - User_Proxy $uBackend, + protected User_Proxy $backend, protected Helper $helper, protected DeletedUsersIndex $dui, protected UserMapping $mapping, ) { - $this->backend = $uBackend; parent::__construct(); } diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php index 658ade62f5d..77f8ed0575f 100644 --- a/apps/user_ldap/lib/Configuration.php +++ b/apps/user_ldap/lib/Configuration.php @@ -92,11 +92,6 @@ class Configuration { public const LDAP_SERVER_FEATURE_UNKNOWN = 'unknown'; public const LDAP_SERVER_FEATURE_AVAILABLE = 'available'; public const LDAP_SERVER_FEATURE_UNAVAILABLE = 'unavailable'; - - /** - * @var string - */ - protected $configPrefix; /** * @var bool */ @@ -185,8 +180,10 @@ class Configuration { 'ldapAttributePronouns' => null, ]; - public function __construct(string $configPrefix, bool $autoRead = true) { - $this->configPrefix = $configPrefix; + public function __construct( + protected string $configPrefix, + bool $autoRead = true, + ) { if ($autoRead) { $this->readConfiguration(); } diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 757ba2d8e8a..f0b1fa17ee6 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -8,6 +8,7 @@ namespace OCA\User_LDAP; use OC\ServerNotAvailableException; +use OCP\ICache; use Psr\Log\LoggerInterface; /** @@ -89,8 +90,6 @@ use Psr\Log\LoggerInterface; */ class Connection extends LDAPUtility { private ?\LDAP\Connection $ldapConnectionRes = null; - private string $configPrefix; - private ?string $configID; private bool $configured = false; /** @@ -109,7 +108,7 @@ class Connection extends LDAPUtility { public $hasGidNumber = true; /** - * @var \OCP\ICache|null + * @var ICache|null */ protected $cache = null; @@ -139,11 +138,13 @@ class Connection extends LDAPUtility { * @param string $configPrefix a string with the prefix for the configkey column (appconfig table) * @param string|null $configID a string with the value for the appid column (appconfig table) or null for on-the-fly connections */ - public function __construct(ILDAPWrapper $ldap, string $configPrefix = '', ?string $configID = 'user_ldap') { + public function __construct( + ILDAPWrapper $ldap, + private string $configPrefix = '', + private ?string $configID = 'user_ldap', + ) { parent::__construct($ldap); - $this->configPrefix = $configPrefix; - $this->configID = $configID; - $this->configuration = new Configuration($configPrefix, !is_null($configID)); + $this->configuration = new Configuration($this->configPrefix, !is_null($this->configID)); $memcache = \OC::$server->getMemCacheFactory(); if ($memcache->isAvailable()) { $this->cache = $memcache->createDistributed(); diff --git a/apps/user_ldap/lib/ConnectionFactory.php b/apps/user_ldap/lib/ConnectionFactory.php index 1e86699c427..fbc30f6b73f 100644 --- a/apps/user_ldap/lib/ConnectionFactory.php +++ b/apps/user_ldap/lib/ConnectionFactory.php @@ -6,11 +6,9 @@ namespace OCA\User_LDAP; class ConnectionFactory { - /** @var ILDAPWrapper */ - private $ldap; - - public function __construct(ILDAPWrapper $ldap) { - $this->ldap = $ldap; + public function __construct( + private ILDAPWrapper $ldap, + ) { } public function get($prefix) { diff --git a/apps/user_ldap/lib/Controller/RenewPasswordController.php b/apps/user_ldap/lib/Controller/RenewPasswordController.php index 2b76858d127..275e2671bf7 100644 --- a/apps/user_ldap/lib/Controller/RenewPasswordController.php +++ b/apps/user_ldap/lib/Controller/RenewPasswordController.php @@ -23,17 +23,6 @@ use OCP\IUserManager; #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)] class RenewPasswordController extends Controller { - /** @var IUserManager */ - private $userManager; - /** @var IConfig */ - private $config; - /** @var IL10N */ - protected $l10n; - /** @var ISession */ - private $session; - /** @var IURLGenerator */ - private $urlGenerator; - /** * @param string $appName * @param IRequest $request @@ -41,14 +30,16 @@ class RenewPasswordController extends Controller { * @param IConfig $config * @param IURLGenerator $urlGenerator */ - public function __construct($appName, IRequest $request, IUserManager $userManager, - IConfig $config, IL10N $l10n, ISession $session, IURLGenerator $urlGenerator) { + public function __construct( + $appName, + IRequest $request, + private IUserManager $userManager, + private IConfig $config, + protected IL10N $l10n, + private ISession $session, + private IURLGenerator $urlGenerator, + ) { parent::__construct($appName, $request); - $this->userManager = $userManager; - $this->config = $config; - $this->l10n = $l10n; - $this->session = $session; - $this->urlGenerator = $urlGenerator; } /** diff --git a/apps/user_ldap/lib/Events/GroupBackendRegistered.php b/apps/user_ldap/lib/Events/GroupBackendRegistered.php index 273b668946b..a94c239c1b3 100644 --- a/apps/user_ldap/lib/Events/GroupBackendRegistered.php +++ b/apps/user_ldap/lib/Events/GroupBackendRegistered.php @@ -19,14 +19,10 @@ use OCP\EventDispatcher\Event; */ class GroupBackendRegistered extends Event { - /** @var GroupPluginManager */ - private $pluginManager; - /** @var IGroupLDAP */ - private $backend; - - public function __construct(IGroupLDAP $backend, GroupPluginManager $pluginManager) { - $this->pluginManager = $pluginManager; - $this->backend = $backend; + public function __construct( + private IGroupLDAP $backend, + private GroupPluginManager $pluginManager, + ) { } public function getBackend(): IGroupLDAP { diff --git a/apps/user_ldap/lib/Events/UserBackendRegistered.php b/apps/user_ldap/lib/Events/UserBackendRegistered.php index ba824d80d22..a26e23f8f83 100644 --- a/apps/user_ldap/lib/Events/UserBackendRegistered.php +++ b/apps/user_ldap/lib/Events/UserBackendRegistered.php @@ -19,14 +19,10 @@ use OCP\EventDispatcher\Event; */ class UserBackendRegistered extends Event { - /** @var IUserLDAP */ - private $backend; - /** @var UserPluginManager */ - private $pluginManager; - - public function __construct(IUserLDAP $backend, UserPluginManager $pluginManager) { - $this->backend = $backend; - $this->pluginManager = $pluginManager; + public function __construct( + private IUserLDAP $backend, + private UserPluginManager $pluginManager, + ) { } public function getBackend(): IUserLDAP { diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index 5fe5abf4c13..2c99fadfcc9 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -31,24 +31,19 @@ class Group_LDAP extends ABackend implements GroupInterface, IGroupLDAP, IGetDis protected CappedMemoryCache $cachedGroupsByMember; /** @var CappedMemoryCache<string[]> $cachedNestedGroups array of groups with gid (DN) as key */ protected CappedMemoryCache $cachedNestedGroups; - protected GroupPluginManager $groupPluginManager; protected LoggerInterface $logger; - protected Access $access; /** * @var string $ldapGroupMemberAssocAttr contains the LDAP setting (in lower case) with the same name */ protected string $ldapGroupMemberAssocAttr; - private IConfig $config; - private IUserManager $ncUserManager; public function __construct( - Access $access, - GroupPluginManager $groupPluginManager, - IConfig $config, - IUserManager $ncUserManager, + protected Access $access, + protected GroupPluginManager $groupPluginManager, + private IConfig $config, + private IUserManager $ncUserManager, ) { - $this->access = $access; $filter = $this->access->connection->ldapGroupFilter; $gAssoc = $this->access->connection->ldapGroupMemberAssocAttr; if (!empty($filter) && !empty($gAssoc)) { @@ -58,11 +53,8 @@ class Group_LDAP extends ABackend implements GroupInterface, IGroupLDAP, IGetDis $this->cachedGroupMembers = new CappedMemoryCache(); $this->cachedGroupsByMember = new CappedMemoryCache(); $this->cachedNestedGroups = new CappedMemoryCache(); - $this->groupPluginManager = $groupPluginManager; $this->logger = Server::get(LoggerInterface::class); $this->ldapGroupMemberAssocAttr = strtolower((string)$gAssoc); - $this->config = $config; - $this->ncUserManager = $ncUserManager; } /** diff --git a/apps/user_ldap/lib/Group_Proxy.php b/apps/user_ldap/lib/Group_Proxy.php index 931ad7d181a..11b7498fbed 100644 --- a/apps/user_ldap/lib/Group_Proxy.php +++ b/apps/user_ldap/lib/Group_Proxy.php @@ -21,25 +21,17 @@ use OCP\IUserManager; class Group_Proxy extends Proxy implements GroupInterface, IGroupLDAP, IGetDisplayNameBackend, INamedBackend, IDeleteGroupBackend, IBatchMethodsBackend, IIsAdminBackend { private $backends = []; private ?Group_LDAP $refBackend = null; - private Helper $helper; - private GroupPluginManager $groupPluginManager; private bool $isSetUp = false; - private IConfig $config; - private IUserManager $ncUserManager; public function __construct( - Helper $helper, + private Helper $helper, ILDAPWrapper $ldap, AccessFactory $accessFactory, - GroupPluginManager $groupPluginManager, - IConfig $config, - IUserManager $ncUserManager, + private GroupPluginManager $groupPluginManager, + private IConfig $config, + private IUserManager $ncUserManager, ) { parent::__construct($ldap, $accessFactory); - $this->helper = $helper; - $this->groupPluginManager = $groupPluginManager; - $this->config = $config; - $this->ncUserManager = $ncUserManager; } protected function setup(): void { diff --git a/apps/user_ldap/lib/Helper.php b/apps/user_ldap/lib/Helper.php index 9bca3eec26b..09be9e081e5 100644 --- a/apps/user_ldap/lib/Helper.php +++ b/apps/user_ldap/lib/Helper.php @@ -13,15 +13,13 @@ use OCP\IConfig; use OCP\IDBConnection; class Helper { - private IConfig $config; - private IDBConnection $connection; /** @var CappedMemoryCache<string> */ protected CappedMemoryCache $sanitizeDnCache; - public function __construct(IConfig $config, - IDBConnection $connection) { - $this->config = $config; - $this->connection = $connection; + public function __construct( + private IConfig $config, + private IDBConnection $connection, + ) { $this->sanitizeDnCache = new CappedMemoryCache(10000); } diff --git a/apps/user_ldap/lib/Jobs/CleanUp.php b/apps/user_ldap/lib/Jobs/CleanUp.php index 12dcc1673d6..6e624419424 100644 --- a/apps/user_ldap/lib/Jobs/CleanUp.php +++ b/apps/user_ldap/lib/Jobs/CleanUp.php @@ -10,10 +10,11 @@ namespace OCA\User_LDAP\Jobs; use OCA\User_LDAP\Helper; use OCA\User_LDAP\Mapping\UserMapping; use OCA\User_LDAP\User\DeletedUsersIndex; -use OCA\User_LDAP\User_LDAP; use OCA\User_LDAP\User_Proxy; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\TimedJob; +use OCP\IConfig; +use OCP\IDBConnection; use OCP\Server; /** @@ -30,13 +31,10 @@ class CleanUp extends TimedJob { /** @var int $defaultIntervalMin default interval in minutes */ protected $defaultIntervalMin = 60; - /** @var User_LDAP|User_Proxy $userBackend */ - protected $userBackend; - - /** @var \OCP\IConfig $ocConfig */ + /** @var IConfig $ocConfig */ protected $ocConfig; - /** @var \OCP\IDBConnection $db */ + /** @var IDBConnection $db */ protected $db; /** @var Helper $ldapHelper */ @@ -45,20 +43,15 @@ class CleanUp extends TimedJob { /** @var UserMapping */ protected $mapping; - /** @var DeletedUsersIndex */ - protected $dui; - public function __construct( ITimeFactory $timeFactory, - User_Proxy $userBackend, - DeletedUsersIndex $dui, + protected User_Proxy $userBackend, + protected DeletedUsersIndex $dui, ) { parent::__construct($timeFactory); $minutes = \OC::$server->getConfig()->getSystemValue( 'ldapUserCleanupInterval', (string)$this->defaultIntervalMin); $this->setInterval((int)$minutes * 60); - $this->userBackend = $userBackend; - $this->dui = $dui; } /** diff --git a/apps/user_ldap/lib/LDAP.php b/apps/user_ldap/lib/LDAP.php index 5e801dec720..44d8493b925 100644 --- a/apps/user_ldap/lib/LDAP.php +++ b/apps/user_ldap/lib/LDAP.php @@ -16,15 +16,14 @@ use OCP\Server; use Psr\Log\LoggerInterface; class LDAP implements ILDAPWrapper { - protected string $logFile = ''; protected array $curArgs = []; protected LoggerInterface $logger; private ?LdapDataCollector $dataCollector = null; - public function __construct(string $logFile = '') { - $this->logFile = $logFile; - + public function __construct( + protected string $logFile = '', + ) { /** @var IProfiler $profiler */ $profiler = \OC::$server->get(IProfiler::class); if ($profiler->isEnabled()) { diff --git a/apps/user_ldap/lib/LDAPProvider.php b/apps/user_ldap/lib/LDAPProvider.php index e7c507a265f..c1aa9a5ac5c 100644 --- a/apps/user_ldap/lib/LDAPProvider.php +++ b/apps/user_ldap/lib/LDAPProvider.php @@ -20,20 +20,20 @@ class LDAPProvider implements ILDAPProvider, IDeletionFlagSupport { private $userBackend; private $groupBackend; private $logger; - private $helper; - private $deletedUsersIndex; /** * Create new LDAPProvider - * @param \OCP\IServerContainer $serverContainer + * @param IServerContainer $serverContainer * @param Helper $helper * @param DeletedUsersIndex $deletedUsersIndex * @throws \Exception if user_ldap app was not enabled */ - public function __construct(IServerContainer $serverContainer, Helper $helper, DeletedUsersIndex $deletedUsersIndex) { + public function __construct( + IServerContainer $serverContainer, + private Helper $helper, + private DeletedUsersIndex $deletedUsersIndex, + ) { $this->logger = $serverContainer->get(LoggerInterface::class); - $this->helper = $helper; - $this->deletedUsersIndex = $deletedUsersIndex; $userBackendFound = false; $groupBackendFound = false; foreach ($serverContainer->getUserManager()->getBackends() as $backend) { diff --git a/apps/user_ldap/lib/LDAPProviderFactory.php b/apps/user_ldap/lib/LDAPProviderFactory.php index cf76233c412..8fad9d52206 100644 --- a/apps/user_ldap/lib/LDAPProviderFactory.php +++ b/apps/user_ldap/lib/LDAPProviderFactory.php @@ -12,11 +12,10 @@ use OCP\LDAP\ILDAPProvider; use OCP\LDAP\ILDAPProviderFactory; class LDAPProviderFactory implements ILDAPProviderFactory { - /** * @var IServerContainer */ - private $serverContainer; - - public function __construct(IServerContainer $serverContainer) { - $this->serverContainer = $serverContainer; + public function __construct( + /** * @var IServerContainer */ + private IServerContainer $serverContainer, + ) { } public function getLDAPProvider(): ILDAPProvider { diff --git a/apps/user_ldap/lib/LDAPUtility.php b/apps/user_ldap/lib/LDAPUtility.php index bca6ec37ecf..39b517528e2 100644 --- a/apps/user_ldap/lib/LDAPUtility.php +++ b/apps/user_ldap/lib/LDAPUtility.php @@ -8,13 +8,12 @@ namespace OCA\User_LDAP; abstract class LDAPUtility { - protected ILDAPWrapper $ldap; - /** * constructor, make sure the subclasses call this one! - * @param ILDAPWrapper $ldapWrapper an instance of an ILDAPWrapper + * @param ILDAPWrapper $ldap an instance of an ILDAPWrapper */ - public function __construct(ILDAPWrapper $ldapWrapper) { - $this->ldap = $ldapWrapper; + public function __construct( + protected ILDAPWrapper $ldap, + ) { } } diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php index 673789f946b..fa10312a915 100644 --- a/apps/user_ldap/lib/Mapping/AbstractMapping.php +++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php @@ -21,11 +21,6 @@ use Psr\Log\LoggerInterface; */ abstract class AbstractMapping { /** - * @var \OCP\IDBConnection $dbc - */ - protected $dbc; - - /** * returns the DB table name which holds the mappings * * @return string @@ -33,10 +28,11 @@ abstract class AbstractMapping { abstract protected function getTableName(bool $includePrefix = true); /** - * @param \OCP\IDBConnection $dbc + * @param IDBConnection $dbc */ - public function __construct(IDBConnection $dbc) { - $this->dbc = $dbc; + public function __construct( + protected IDBConnection $dbc, + ) { } /** @var array caches Names (value) by DN (key) */ diff --git a/apps/user_ldap/lib/Mapping/UserMapping.php b/apps/user_ldap/lib/Mapping/UserMapping.php index 0eeaaef12fd..a030cd0ab52 100644 --- a/apps/user_ldap/lib/Mapping/UserMapping.php +++ b/apps/user_ldap/lib/Mapping/UserMapping.php @@ -20,11 +20,12 @@ use OCP\Support\Subscription\IAssertion; */ class UserMapping extends AbstractMapping { - private IAssertion $assertion; protected const PROV_API_REGEX = '/\/ocs\/v[1-9].php\/cloud\/(groups|users)/'; - public function __construct(IDBConnection $dbc, IAssertion $assertion) { - $this->assertion = $assertion; + public function __construct( + IDBConnection $dbc, + private IAssertion $assertion, + ) { parent::__construct($dbc); } diff --git a/apps/user_ldap/lib/Migration/GroupMappingMigration.php b/apps/user_ldap/lib/Migration/GroupMappingMigration.php index 437bb202bba..7dfb8705770 100644 --- a/apps/user_ldap/lib/Migration/GroupMappingMigration.php +++ b/apps/user_ldap/lib/Migration/GroupMappingMigration.php @@ -14,11 +14,9 @@ use OCP\Migration\SimpleMigrationStep; abstract class GroupMappingMigration extends SimpleMigrationStep { - /** @var IDBConnection */ - private $dbc; - - public function __construct(IDBConnection $dbc) { - $this->dbc = $dbc; + public function __construct( + private IDBConnection $dbc, + ) { } protected function copyGroupMappingData(string $sourceTable, string $destinationTable): void { diff --git a/apps/user_ldap/lib/Migration/SetDefaultProvider.php b/apps/user_ldap/lib/Migration/SetDefaultProvider.php index b4d6b5650fb..0bb04438a1d 100644 --- a/apps/user_ldap/lib/Migration/SetDefaultProvider.php +++ b/apps/user_ldap/lib/Migration/SetDefaultProvider.php @@ -16,16 +16,10 @@ use OCP\Migration\IRepairStep; class SetDefaultProvider implements IRepairStep { - /** @var IConfig */ - private $config; - - /** @var Helper */ - private $helper; - - public function __construct(IConfig $config, - Helper $helper) { - $this->config = $config; - $this->helper = $helper; + public function __construct( + private IConfig $config, + private Helper $helper, + ) { } public function getName(): string { diff --git a/apps/user_ldap/lib/Migration/UUIDFixInsert.php b/apps/user_ldap/lib/Migration/UUIDFixInsert.php index 52c52190654..de777f6f010 100644 --- a/apps/user_ldap/lib/Migration/UUIDFixInsert.php +++ b/apps/user_ldap/lib/Migration/UUIDFixInsert.php @@ -14,23 +14,12 @@ use OCP\Migration\IRepairStep; class UUIDFixInsert implements IRepairStep { - /** @var IConfig */ - protected $config; - - /** @var UserMapping */ - protected $userMapper; - - /** @var GroupMapping */ - protected $groupMapper; - - /** @var IJobList */ - protected $jobList; - - public function __construct(IConfig $config, UserMapping $userMapper, GroupMapping $groupMapper, IJobList $jobList) { - $this->config = $config; - $this->userMapper = $userMapper; - $this->groupMapper = $groupMapper; - $this->jobList = $jobList; + public function __construct( + protected IConfig $config, + protected UserMapping $userMapper, + protected GroupMapping $groupMapper, + protected IJobList $jobList, + ) { } /** diff --git a/apps/user_ldap/lib/Migration/UnsetDefaultProvider.php b/apps/user_ldap/lib/Migration/UnsetDefaultProvider.php index 2b368f5d2c9..025415cf712 100644 --- a/apps/user_ldap/lib/Migration/UnsetDefaultProvider.php +++ b/apps/user_ldap/lib/Migration/UnsetDefaultProvider.php @@ -15,11 +15,9 @@ use OCP\Migration\IRepairStep; class UnsetDefaultProvider implements IRepairStep { - /** @var IConfig */ - private $config; - - public function __construct(IConfig $config) { - $this->config = $config; + public function __construct( + private IConfig $config, + ) { } public function getName(): string { diff --git a/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php b/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php index 9b6ebbfc5de..dc3823bf771 100644 --- a/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php +++ b/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php @@ -22,17 +22,11 @@ use Psr\Log\LoggerInterface; class Version1120Date20210917155206 extends SimpleMigrationStep { - /** @var IDBConnection */ - private $dbc; - /** @var IUserManager */ - private $userManager; - /** @var LoggerInterface */ - private $logger; - - public function __construct(IDBConnection $dbc, IUserManager $userManager, LoggerInterface $logger) { - $this->dbc = $dbc; - $this->userManager = $userManager; - $this->logger = $logger; + public function __construct( + private IDBConnection $dbc, + private IUserManager $userManager, + private LoggerInterface $logger, + ) { } public function getName() { diff --git a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php index ff8b113d3e9..2457acd840d 100644 --- a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php +++ b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php @@ -22,16 +22,13 @@ use Psr\Log\LoggerInterface; class Version1130Date20211102154716 extends SimpleMigrationStep { - /** @var IDBConnection */ - private $dbc; - /** @var LoggerInterface */ - private $logger; /** @var string[] */ private $hashColumnAddedToTables = []; - public function __construct(IDBConnection $dbc, LoggerInterface $logger) { - $this->dbc = $dbc; - $this->logger = $logger; + public function __construct( + private IDBConnection $dbc, + private LoggerInterface $logger, + ) { } public function getName() { diff --git a/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php b/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php index 86f10a26c3e..ecedbf1de20 100644 --- a/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php +++ b/apps/user_ldap/lib/Migration/Version1141Date20220323143801.php @@ -18,10 +18,9 @@ use OCP\Migration\SimpleMigrationStep; class Version1141Date20220323143801 extends SimpleMigrationStep { - private IDBConnection $dbc; - - public function __construct(IDBConnection $dbc) { - $this->dbc = $dbc; + public function __construct( + private IDBConnection $dbc, + ) { } /** diff --git a/apps/user_ldap/lib/Notification/Notifier.php b/apps/user_ldap/lib/Notification/Notifier.php index 8858bc33f80..8d8bc8be5a3 100644 --- a/apps/user_ldap/lib/Notification/Notifier.php +++ b/apps/user_ldap/lib/Notification/Notifier.php @@ -12,14 +12,12 @@ use OCP\Notification\UnknownNotificationException; class Notifier implements INotifier { - /** @var IFactory */ - protected $l10nFactory; - /** * @param IFactory $l10nFactory */ - public function __construct(IFactory $l10nFactory) { - $this->l10nFactory = $l10nFactory; + public function __construct( + protected IFactory $l10nFactory, + ) { } /** diff --git a/apps/user_ldap/lib/Proxy.php b/apps/user_ldap/lib/Proxy.php index 88a55f6462d..ab8b9f451f0 100644 --- a/apps/user_ldap/lib/Proxy.php +++ b/apps/user_ldap/lib/Proxy.php @@ -15,17 +15,13 @@ use OCP\Server; abstract class Proxy { /** @var array<string,Access> */ private static array $accesses = []; - private ILDAPWrapper $ldap; private ?bool $isSingleBackend = null; private ?ICache $cache = null; - private AccessFactory $accessFactory; public function __construct( - ILDAPWrapper $ldap, - AccessFactory $accessFactory, + private ILDAPWrapper $ldap, + private AccessFactory $accessFactory, ) { - $this->ldap = $ldap; - $this->accessFactory = $accessFactory; $memcache = \OC::$server->getMemCacheFactory(); if ($memcache->isAvailable()) { $this->cache = $memcache->createDistributed(); diff --git a/apps/user_ldap/lib/Settings/Admin.php b/apps/user_ldap/lib/Settings/Admin.php index 8fc0915c6fe..80d1e6437f7 100644 --- a/apps/user_ldap/lib/Settings/Admin.php +++ b/apps/user_ldap/lib/Settings/Admin.php @@ -13,14 +13,12 @@ use OCP\Settings\IDelegatedSettings; use OCP\Template; class Admin implements IDelegatedSettings { - /** @var IL10N */ - private $l; - /** * @param IL10N $l */ - public function __construct(IL10N $l) { - $this->l = $l; + public function __construct( + private IL10N $l, + ) { } /** diff --git a/apps/user_ldap/lib/Settings/Section.php b/apps/user_ldap/lib/Settings/Section.php index e26d85d8771..6e342279f46 100644 --- a/apps/user_ldap/lib/Settings/Section.php +++ b/apps/user_ldap/lib/Settings/Section.php @@ -10,18 +10,14 @@ use OCP\IURLGenerator; use OCP\Settings\IIconSection; class Section implements IIconSection { - /** @var IL10N */ - private $l; - /** @var IURLGenerator */ - private $url; - /** * @param IURLGenerator $url * @param IL10N $l */ - public function __construct(IURLGenerator $url, IL10N $l) { - $this->url = $url; - $this->l = $l; + public function __construct( + private IURLGenerator $url, + private IL10N $l, + ) { } /** diff --git a/apps/user_ldap/lib/User/DeletedUsersIndex.php b/apps/user_ldap/lib/User/DeletedUsersIndex.php index 515233b3825..9ce78f15d8b 100644 --- a/apps/user_ldap/lib/User/DeletedUsersIndex.php +++ b/apps/user_ldap/lib/User/DeletedUsersIndex.php @@ -7,6 +7,7 @@ namespace OCA\User_LDAP\User; use OCA\User_LDAP\Mapping\UserMapping; use OCP\IConfig; +use OCP\PreConditionNotMetException; use OCP\Share\IManager; /** @@ -14,19 +15,13 @@ use OCP\Share\IManager; * @package OCA\User_LDAP */ class DeletedUsersIndex { - protected IConfig $config; - protected UserMapping $mapping; protected ?array $deletedUsers = null; - private IManager $shareManager; public function __construct( - IConfig $config, - UserMapping $mapping, - IManager $shareManager, + protected IConfig $config, + protected UserMapping $mapping, + private IManager $shareManager, ) { - $this->config = $config; - $this->mapping = $mapping; - $this->shareManager = $shareManager; } /** @@ -74,7 +69,7 @@ class DeletedUsersIndex { /** * marks a user as deleted * - * @throws \OCP\PreConditionNotMetException + * @throws PreConditionNotMetException */ public function markUser(string $ocName): void { if ($this->isUserMarked($ocName)) { diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php index 7b03483200d..2b09d425721 100644 --- a/apps/user_ldap/lib/User/Manager.php +++ b/apps/user_ldap/lib/User/Manager.php @@ -27,40 +27,24 @@ use Psr\Log\LoggerInterface; */ class Manager { protected ?Access $access = null; - protected IConfig $ocConfig; protected IDBConnection $db; - protected IUserManager $userManager; - protected INotificationManager $notificationManager; - protected FilesystemHelper $ocFilesystem; - protected LoggerInterface $logger; - protected Image $image; - protected IAvatarManager $avatarManager; /** @var CappedMemoryCache<User> $usersByDN */ protected CappedMemoryCache $usersByDN; /** @var CappedMemoryCache<User> $usersByUid */ protected CappedMemoryCache $usersByUid; - private IManager $shareManager; public function __construct( - IConfig $ocConfig, - FilesystemHelper $ocFilesystem, - LoggerInterface $logger, - IAvatarManager $avatarManager, - Image $image, - IUserManager $userManager, - INotificationManager $notificationManager, - IManager $shareManager, + protected IConfig $ocConfig, + protected FilesystemHelper $ocFilesystem, + protected LoggerInterface $logger, + protected IAvatarManager $avatarManager, + protected Image $image, + protected IUserManager $userManager, + protected INotificationManager $notificationManager, + private IManager $shareManager, ) { - $this->ocConfig = $ocConfig; - $this->ocFilesystem = $ocFilesystem; - $this->logger = $logger; - $this->avatarManager = $avatarManager; - $this->image = $image; - $this->userManager = $userManager; - $this->notificationManager = $notificationManager; $this->usersByDN = new CappedMemoryCache(); $this->usersByUid = new CappedMemoryCache(); - $this->shareManager = $shareManager; } /** diff --git a/apps/user_ldap/lib/User/OfflineUser.php b/apps/user_ldap/lib/User/OfflineUser.php index 873bd597df8..ecaab7188ba 100644 --- a/apps/user_ldap/lib/User/OfflineUser.php +++ b/apps/user_ldap/lib/User/OfflineUser.php @@ -15,10 +15,6 @@ use OCP\Share\IShare; class OfflineUser { /** - * @var string $ocName - */ - protected $ocName; - /** * @var string $dn */ protected $dn; @@ -52,30 +48,19 @@ class OfflineUser { */ protected $hasActiveShares; /** - * @var IConfig $config - */ - protected $config; - /** * @var IDBConnection $db */ protected $db; + /** - * @var UserMapping + * @param string $ocName */ - protected $mapping; - /** @var IManager */ - private $shareManager; - public function __construct( - $ocName, - IConfig $config, - UserMapping $mapping, - IManager $shareManager, + protected $ocName, + protected IConfig $config, + protected UserMapping $mapping, + private IManager $shareManager, ) { - $this->ocName = $ocName; - $this->config = $config; - $this->mapping = $mapping; - $this->shareManager = $shareManager; } /** diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index 0a310f57012..7ef36ff1512 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -22,6 +22,7 @@ use OCP\Image; use OCP\IUser; use OCP\IUserManager; use OCP\Notification\IManager as INotificationManager; +use OCP\PreConditionNotMetException; use OCP\Server; use OCP\Util; use Psr\Log\LoggerInterface; @@ -33,42 +34,14 @@ use Psr\Log\LoggerInterface; */ class User { /** - * @var Access - */ - protected $access; - /** * @var Connection */ protected $connection; /** - * @var IConfig - */ - protected $config; - /** - * @var FilesystemHelper - */ - protected $fs; - /** - * @var Image - */ - protected $image; - /** * @var LoggerInterface */ protected $logger; /** - * @var IAvatarManager - */ - protected $avatarManager; - /** - * @var IUserManager - */ - protected $userManager; - /** - * @var INotificationManager - */ - protected $notificationManager; - /** * @var string */ protected $dn; @@ -97,10 +70,18 @@ class User { * @param string $username the internal username * @param string $dn the LDAP DN */ - public function __construct($username, $dn, Access $access, - IConfig $config, FilesystemHelper $fs, Image $image, - LoggerInterface $logger, IAvatarManager $avatarManager, IUserManager $userManager, - INotificationManager $notificationManager) { + public function __construct( + $username, + $dn, + protected Access $access, + protected IConfig $config, + protected FilesystemHelper $fs, + protected Image $image, + LoggerInterface $logger, + protected IAvatarManager $avatarManager, + protected IUserManager $userManager, + protected INotificationManager $notificationManager, + ) { if ($username === null) { $logger->error("uid for '$dn' must not be null!", ['app' => 'user_ldap']); throw new \InvalidArgumentException('uid must not be null!'); @@ -108,18 +89,10 @@ class User { $logger->error("uid for '$dn' must not be an empty string", ['app' => 'user_ldap']); throw new \InvalidArgumentException('uid must not be an empty string!'); } - - $this->access = $access; - $this->connection = $access->getConnection(); - $this->config = $config; - $this->fs = $fs; + $this->connection = $this->access->getConnection(); $this->dn = $dn; $this->uid = $username; - $this->image = $image; $this->logger = $logger; - $this->avatarManager = $avatarManager; - $this->userManager = $userManager; - $this->notificationManager = $notificationManager; $this->birthdateParser = new BirthdateParserService(); Util::connectHook('OC_User', 'post_login', $this, 'handlePasswordExpiry'); @@ -128,7 +101,7 @@ class User { /** * marks a user as deleted * - * @throws \OCP\PreConditionNotMetException + * @throws PreConditionNotMetException */ public function markUser() { $curValue = $this->config->getUserValue($this->getUsername(), 'user_ldap', 'isDeleted', '0'); @@ -765,7 +738,7 @@ class User { /** * @throws AttributeNotSet * @throws \OC\ServerNotAvailableException - * @throws \OCP\PreConditionNotMetException + * @throws PreConditionNotMetException */ public function getExtStorageHome():string { $value = $this->config->getUserValue($this->getUsername(), 'user_ldap', 'extStorageHome', ''); @@ -784,7 +757,7 @@ class User { } /** - * @throws \OCP\PreConditionNotMetException + * @throws PreConditionNotMetException * @throws \OC\ServerNotAvailableException */ public function updateExtStorageHome(?string $valueFromLDAP = null):string { diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index 85ed69195b6..6970a52d3d7 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -23,23 +23,14 @@ use OCP\UserInterface; use Psr\Log\LoggerInterface; class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, IUserLDAP, ICountUsersBackend, ICountMappedUsersBackend, IProvideEnabledStateBackend { - protected INotificationManager $notificationManager; - protected UserPluginManager $userPluginManager; - protected LoggerInterface $logger; - protected DeletedUsersIndex $deletedUsersIndex; - public function __construct( Access $access, - INotificationManager $notificationManager, - UserPluginManager $userPluginManager, - LoggerInterface $logger, - DeletedUsersIndex $deletedUsersIndex, + protected INotificationManager $notificationManager, + protected UserPluginManager $userPluginManager, + protected LoggerInterface $logger, + protected DeletedUsersIndex $deletedUsersIndex, ) { parent::__construct($access); - $this->notificationManager = $notificationManager; - $this->userPluginManager = $userPluginManager; - $this->logger = $logger; - $this->deletedUsersIndex = $deletedUsersIndex; } /** diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php index 3abaae741d8..7786b8f0497 100644 --- a/apps/user_ldap/lib/User_Proxy.php +++ b/apps/user_ldap/lib/User_Proxy.php @@ -24,27 +24,17 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP private ?User_LDAP $refBackend = null; private bool $isSetUp = false; - private Helper $helper; - private INotificationManager $notificationManager; - private UserPluginManager $userPluginManager; - private LoggerInterface $logger; - private DeletedUsersIndex $deletedUsersIndex; public function __construct( - Helper $helper, + private Helper $helper, ILDAPWrapper $ldap, AccessFactory $accessFactory, - INotificationManager $notificationManager, - UserPluginManager $userPluginManager, - LoggerInterface $logger, - DeletedUsersIndex $deletedUsersIndex, + private INotificationManager $notificationManager, + private UserPluginManager $userPluginManager, + private LoggerInterface $logger, + private DeletedUsersIndex $deletedUsersIndex, ) { parent::__construct($ldap, $accessFactory); - $this->helper = $helper; - $this->notificationManager = $notificationManager; - $this->userPluginManager = $userPluginManager; - $this->logger = $logger; - $this->deletedUsersIndex = $deletedUsersIndex; } protected function setup(): void { diff --git a/apps/user_ldap/lib/Wizard.php b/apps/user_ldap/lib/Wizard.php index 262777c5022..6df5aba4cac 100644 --- a/apps/user_ldap/lib/Wizard.php +++ b/apps/user_ldap/lib/Wizard.php @@ -16,9 +16,7 @@ use Psr\Log\LoggerInterface; class Wizard extends LDAPUtility { protected static ?IL10N $l = null; - protected Access $access; protected ?\LDAP\Connection $cr = null; - protected Configuration $configuration; protected WizardResult $result; protected LoggerInterface $logger; @@ -36,16 +34,14 @@ class Wizard extends LDAPUtility { public const LDAP_NW_TIMEOUT = 4; public function __construct( - Configuration $configuration, + protected Configuration $configuration, ILDAPWrapper $ldap, - Access $access, + protected Access $access, ) { parent::__construct($ldap); - $this->configuration = $configuration; if (is_null(static::$l)) { static::$l = \OC::$server->get(IL10NFactory::class)->get('user_ldap'); } - $this->access = $access; $this->result = new WizardResult(); $this->logger = \OC::$server->get(LoggerInterface::class); } diff --git a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php index 30b3e573cd4..726342a88f7 100644 --- a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php +++ b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php @@ -37,14 +37,19 @@ abstract class AbstractIntegrationTest { /** @var Helper */ protected $helper; - /** @var string */ - protected $base; - /** @var string[] */ protected $server; - public function __construct($host, $port, $bind, $pwd, $base) { - $this->base = $base; + /** + * @param string $base + */ + public function __construct( + $host, + $port, + $bind, + $pwd, + protected $base, + ) { $this->server = [ 'host' => $host, 'port' => $port, diff --git a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php index 2beab95b71f..78f6df9d7bc 100644 --- a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php +++ b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php @@ -22,21 +22,6 @@ use OCA\User_LDAP\LDAP; */ class ExceptionOnLostConnection { /** @var string */ - private $toxiProxyHost; - - /** @var string */ - private $toxiProxyName; - - /** @var string */ - private $ldapBase; - - /** @var string|null */ - private $ldapBindDN; - - /** @var string|null */ - private $ldapBindPwd; - - /** @var string */ private $ldapHost; /** @var LDAP */ @@ -46,19 +31,19 @@ class ExceptionOnLostConnection { private $originalProxyState; /** - * @param string $proxyHost host of toxiproxy as url, like http://localhost:8474 - * @param string $proxyName name of the LDAP proxy service as configured in toxiProxy + * @param string $toxiProxyHost host of toxiproxy as url, like http://localhost:8474 + * @param string $toxiProxyName name of the LDAP proxy service as configured in toxiProxy * @param string $ldapBase any valid LDAP base DN - * @param null $bindDN optional, bind DN if anonymous bind is not possible - * @param null $bindPwd optional + * @param null $ldapBindDN optional, bind DN if anonymous bind is not possible + * @param null $ldapBindPwd optional */ - public function __construct($proxyHost, $proxyName, $ldapBase, $bindDN = null, $bindPwd = null) { - $this->toxiProxyHost = $proxyHost; - $this->toxiProxyName = $proxyName; - $this->ldapBase = $ldapBase; - $this->ldapBindDN = $bindDN; - $this->ldapBindPwd = $bindPwd; - + public function __construct( + private $toxiProxyHost, + private $toxiProxyName, + private $ldapBase, + private $ldapBindDN = null, + private $ldapBindPwd = null, + ) { $this->setUp(); } diff --git a/apps/user_status/lib/BackgroundJob/ClearOldStatusesBackgroundJob.php b/apps/user_status/lib/BackgroundJob/ClearOldStatusesBackgroundJob.php index edf3b657724..331d88de747 100644 --- a/apps/user_status/lib/BackgroundJob/ClearOldStatusesBackgroundJob.php +++ b/apps/user_status/lib/BackgroundJob/ClearOldStatusesBackgroundJob.php @@ -20,19 +20,17 @@ use OCP\BackgroundJob\TimedJob; */ class ClearOldStatusesBackgroundJob extends TimedJob { - /** @var UserStatusMapper */ - private $mapper; - /** * ClearOldStatusesBackgroundJob constructor. * * @param ITimeFactory $time * @param UserStatusMapper $mapper */ - public function __construct(ITimeFactory $time, - UserStatusMapper $mapper) { + public function __construct( + ITimeFactory $time, + private UserStatusMapper $mapper, + ) { parent::__construct($time); - $this->mapper = $mapper; // Run every time the cron is run $this->setInterval(0); diff --git a/apps/user_status/lib/Capabilities.php b/apps/user_status/lib/Capabilities.php index 9a1ac4b47ab..0c5dc4e03d2 100644 --- a/apps/user_status/lib/Capabilities.php +++ b/apps/user_status/lib/Capabilities.php @@ -17,10 +17,9 @@ use OCP\IEmojiHelper; * @package OCA\UserStatus */ class Capabilities implements ICapability { - private IEmojiHelper $emojiHelper; - - public function __construct(IEmojiHelper $emojiHelper) { - $this->emojiHelper = $emojiHelper; + public function __construct( + private IEmojiHelper $emojiHelper, + ) { } /** diff --git a/apps/user_status/lib/Connector/UserStatus.php b/apps/user_status/lib/Connector/UserStatus.php index 7fbfd62f223..04467a99e5e 100644 --- a/apps/user_status/lib/Connector/UserStatus.php +++ b/apps/user_status/lib/Connector/UserStatus.php @@ -29,21 +29,19 @@ class UserStatus implements IUserStatus { /** @var DateTimeImmutable|null */ private $clearAt; - /** @var Db\UserStatus */ - private $internalStatus; - - public function __construct(Db\UserStatus $status) { - $this->internalStatus = $status; - $this->userId = $status->getUserId(); - $this->status = $status->getStatus(); - $this->message = $status->getCustomMessage(); - $this->icon = $status->getCustomIcon(); - - if ($status->getStatus() === IUserStatus::INVISIBLE) { + public function __construct( + private Db\UserStatus $internalStatus, + ) { + $this->userId = $this->internalStatus->getUserId(); + $this->status = $this->internalStatus->getStatus(); + $this->message = $this->internalStatus->getCustomMessage(); + $this->icon = $this->internalStatus->getCustomIcon(); + + if ($this->internalStatus->getStatus() === IUserStatus::INVISIBLE) { $this->status = IUserStatus::OFFLINE; } - if ($status->getClearAt() !== null) { - $this->clearAt = DateTimeImmutable::createFromFormat('U', (string)$status->getClearAt()); + if ($this->internalStatus->getClearAt() !== null) { + $this->clearAt = DateTimeImmutable::createFromFormat('U', (string)$this->internalStatus->getClearAt()); } } diff --git a/apps/user_status/lib/Connector/UserStatusProvider.php b/apps/user_status/lib/Connector/UserStatusProvider.php index a85223dcf2a..e84d69d1eb2 100644 --- a/apps/user_status/lib/Connector/UserStatusProvider.php +++ b/apps/user_status/lib/Connector/UserStatusProvider.php @@ -14,16 +14,14 @@ use OCP\UserStatus\IProvider; class UserStatusProvider implements IProvider, ISettableProvider { - /** @var StatusService */ - private $service; - /** * UserStatusProvider constructor. * * @param StatusService $service */ - public function __construct(StatusService $service) { - $this->service = $service; + public function __construct( + private StatusService $service, + ) { } /** diff --git a/apps/user_status/lib/Controller/HeartbeatController.php b/apps/user_status/lib/Controller/HeartbeatController.php index 11170f39b25..d1da035329e 100644 --- a/apps/user_status/lib/Controller/HeartbeatController.php +++ b/apps/user_status/lib/Controller/HeartbeatController.php @@ -28,29 +28,15 @@ use OCP\UserStatus\IUserStatus; */ class HeartbeatController extends OCSController { - /** @var IEventDispatcher */ - private $eventDispatcher; - - /** @var IUserSession */ - private $userSession; - - /** @var ITimeFactory */ - private $timeFactory; - - /** @var StatusService */ - private $service; - - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - IEventDispatcher $eventDispatcher, - IUserSession $userSession, - ITimeFactory $timeFactory, - StatusService $service) { + private IEventDispatcher $eventDispatcher, + private IUserSession $userSession, + private ITimeFactory $timeFactory, + private StatusService $service, + ) { parent::__construct($appName, $request); - $this->eventDispatcher = $eventDispatcher; - $this->userSession = $userSession; - $this->timeFactory = $timeFactory; - $this->service = $service; } /** diff --git a/apps/user_status/lib/Controller/PredefinedStatusController.php b/apps/user_status/lib/Controller/PredefinedStatusController.php index 54a5a3e7eef..14300360880 100644 --- a/apps/user_status/lib/Controller/PredefinedStatusController.php +++ b/apps/user_status/lib/Controller/PredefinedStatusController.php @@ -24,9 +24,6 @@ use OCP\IRequest; */ class PredefinedStatusController extends OCSController { - /** @var PredefinedStatusService */ - private $predefinedStatusService; - /** * AStatusController constructor. * @@ -34,11 +31,12 @@ class PredefinedStatusController extends OCSController { * @param IRequest $request * @param PredefinedStatusService $predefinedStatusService */ - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - PredefinedStatusService $predefinedStatusService) { + private PredefinedStatusService $predefinedStatusService, + ) { parent::__construct($appName, $request); - $this->predefinedStatusService = $predefinedStatusService; } /** diff --git a/apps/user_status/lib/Controller/StatusesController.php b/apps/user_status/lib/Controller/StatusesController.php index 08b2878e297..f9c64c075bf 100644 --- a/apps/user_status/lib/Controller/StatusesController.php +++ b/apps/user_status/lib/Controller/StatusesController.php @@ -27,9 +27,6 @@ use OCP\UserStatus\IUserStatus; */ class StatusesController extends OCSController { - /** @var StatusService */ - private $service; - /** * StatusesController constructor. * @@ -37,11 +34,12 @@ class StatusesController extends OCSController { * @param IRequest $request * @param StatusService $service */ - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - StatusService $service) { + private StatusService $service, + ) { parent::__construct($appName, $request); - $this->service = $service; } /** diff --git a/apps/user_status/lib/Dashboard/UserStatusWidget.php b/apps/user_status/lib/Dashboard/UserStatusWidget.php index cc1ce887e83..9dce2b1412a 100644 --- a/apps/user_status/lib/Dashboard/UserStatusWidget.php +++ b/apps/user_status/lib/Dashboard/UserStatusWidget.php @@ -32,14 +32,6 @@ use OCP\UserStatus\IUserStatus; * @package OCA\UserStatus */ class UserStatusWidget implements IAPIWidget, IAPIWidgetV2, IIconWidget, IOptionWidget { - private IL10N $l10n; - private IDateTimeFormatter $dateTimeFormatter; - private IURLGenerator $urlGenerator; - private IInitialState $initialStateService; - private IUserManager $userManager; - private IUserSession $userSession; - private StatusService $service; - /** * UserStatusWidget constructor * @@ -51,20 +43,15 @@ class UserStatusWidget implements IAPIWidget, IAPIWidgetV2, IIconWidget, IOption * @param IUserSession $userSession * @param StatusService $service */ - public function __construct(IL10N $l10n, - IDateTimeFormatter $dateTimeFormatter, - IURLGenerator $urlGenerator, - IInitialState $initialStateService, - IUserManager $userManager, - IUserSession $userSession, - StatusService $service) { - $this->l10n = $l10n; - $this->dateTimeFormatter = $dateTimeFormatter; - $this->urlGenerator = $urlGenerator; - $this->initialStateService = $initialStateService; - $this->userManager = $userManager; - $this->userSession = $userSession; - $this->service = $service; + public function __construct( + private IL10N $l10n, + private IDateTimeFormatter $dateTimeFormatter, + private IURLGenerator $urlGenerator, + private IInitialState $initialStateService, + private IUserManager $userManager, + private IUserSession $userSession, + private StatusService $service, + ) { } /** diff --git a/apps/user_status/lib/Db/UserStatusMapper.php b/apps/user_status/lib/Db/UserStatusMapper.php index feeb2904fb5..15982d44fd8 100644 --- a/apps/user_status/lib/Db/UserStatusMapper.php +++ b/apps/user_status/lib/Db/UserStatusMapper.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace OCA\UserStatus\Db; +use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; @@ -83,7 +84,7 @@ class UserStatusMapper extends QBMapper { /** * @param string $userId * @return UserStatus - * @throws \OCP\AppFramework\Db\DoesNotExistException + * @throws DoesNotExistException */ public function findByUserId(string $userId, bool $isBackup = false): UserStatus { $qb = $this->db->getQueryBuilder(); diff --git a/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php b/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php index 031ad4f9126..ab3a1e62beb 100644 --- a/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php +++ b/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php @@ -26,15 +26,6 @@ class BeforeTemplateRenderedListener implements IEventListener { /** @var ProfileManager */ private $profileManager; - /** @var IUserSession */ - private $userSession; - - /** @var IInitialStateService */ - private $initialState; - - /** @var JSDataService */ - private $jsDataService; - /** * BeforeTemplateRenderedListener constructor. * @@ -45,14 +36,11 @@ class BeforeTemplateRenderedListener implements IEventListener { */ public function __construct( ProfileManager $profileManager, - IUserSession $userSession, - IInitialStateService $initialState, - JSDataService $jsDataService, + private IUserSession $userSession, + private IInitialStateService $initialState, + private JSDataService $jsDataService, ) { $this->profileManager = $profileManager; - $this->userSession = $userSession; - $this->initialState = $initialState; - $this->jsDataService = $jsDataService; } /** diff --git a/apps/user_status/lib/Listener/UserDeletedListener.php b/apps/user_status/lib/Listener/UserDeletedListener.php index 55ec5fe13ff..bf021635156 100644 --- a/apps/user_status/lib/Listener/UserDeletedListener.php +++ b/apps/user_status/lib/Listener/UserDeletedListener.php @@ -21,16 +21,14 @@ use OCP\User\Events\UserDeletedEvent; */ class UserDeletedListener implements IEventListener { - /** @var StatusService */ - private $service; - /** * UserDeletedListener constructor. * * @param StatusService $service */ - public function __construct(StatusService $service) { - $this->service = $service; + public function __construct( + private StatusService $service, + ) { } diff --git a/apps/user_status/lib/Listener/UserLiveStatusListener.php b/apps/user_status/lib/Listener/UserLiveStatusListener.php index 79305a99b05..aad0943b8d0 100644 --- a/apps/user_status/lib/Listener/UserLiveStatusListener.php +++ b/apps/user_status/lib/Listener/UserLiveStatusListener.php @@ -29,20 +29,13 @@ use Psr\Log\LoggerInterface; * @template-implements IEventListener<UserLiveStatusEvent> */ class UserLiveStatusListener implements IEventListener { - private UserStatusMapper $mapper; - private StatusService $statusService; - private ITimeFactory $timeFactory; - public function __construct( - UserStatusMapper $mapper, - StatusService $statusService, - ITimeFactory $timeFactory, + private UserStatusMapper $mapper, + private StatusService $statusService, + private ITimeFactory $timeFactory, private CalendarStatusService $calendarStatusService, private LoggerInterface $logger, ) { - $this->mapper = $mapper; - $this->statusService = $statusService; - $this->timeFactory = $timeFactory; } /** diff --git a/apps/user_status/lib/Service/JSDataService.php b/apps/user_status/lib/Service/JSDataService.php index a6b9b0b4056..a777e97fe57 100644 --- a/apps/user_status/lib/Service/JSDataService.php +++ b/apps/user_status/lib/Service/JSDataService.php @@ -14,22 +14,16 @@ use OCP\UserStatus\IUserStatus; class JSDataService implements \JsonSerializable { - /** @var IUserSession */ - private $userSession; - - /** @var StatusService */ - private $statusService; - /** * JSDataService constructor. * * @param IUserSession $userSession * @param StatusService $statusService */ - public function __construct(IUserSession $userSession, - StatusService $statusService) { - $this->userSession = $userSession; - $this->statusService = $statusService; + public function __construct( + private IUserSession $userSession, + private StatusService $statusService, + ) { } public function jsonSerialize(): array { diff --git a/apps/user_status/lib/Service/PredefinedStatusService.php b/apps/user_status/lib/Service/PredefinedStatusService.php index b17442a0caa..6606966acd1 100644 --- a/apps/user_status/lib/Service/PredefinedStatusService.php +++ b/apps/user_status/lib/Service/PredefinedStatusService.php @@ -31,16 +31,14 @@ class PredefinedStatusService { public const CALL = 'call'; public const OUT_OF_OFFICE = 'out-of-office'; - /** @var IL10N */ - private $l10n; - /** * DefaultStatusService constructor. * * @param IL10N $l10n */ - public function __construct(IL10N $l10n) { - $this->l10n = $l10n; + public function __construct( + private IL10N $l10n, + ) { } /** diff --git a/apps/workflowengine/lib/Check/AbstractStringCheck.php b/apps/workflowengine/lib/Check/AbstractStringCheck.php index 1c544c8c000..4e56cda377e 100644 --- a/apps/workflowengine/lib/Check/AbstractStringCheck.php +++ b/apps/workflowengine/lib/Check/AbstractStringCheck.php @@ -14,14 +14,12 @@ abstract class AbstractStringCheck implements ICheck { /** @var array[] Nested array: [Pattern => [ActualValue => Regex Result]] */ protected $matches; - /** @var IL10N */ - protected $l; - /** * @param IL10N $l */ - public function __construct(IL10N $l) { - $this->l = $l; + public function __construct( + protected IL10N $l, + ) { } /** diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php index c1e448376c9..3062994c6ba 100644 --- a/apps/workflowengine/lib/Check/FileMimeType.php +++ b/apps/workflowengine/lib/Check/FileMimeType.php @@ -21,21 +21,17 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck { /** @var array */ protected $mimeType; - /** @var IRequest */ - protected $request; - - /** @var IMimeTypeDetector */ - protected $mimeTypeDetector; - /** * @param IL10N $l * @param IRequest $request * @param IMimeTypeDetector $mimeTypeDetector */ - public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) { + public function __construct( + IL10N $l, + protected IRequest $request, + protected IMimeTypeDetector $mimeTypeDetector, + ) { parent::__construct($l); - $this->request = $request; - $this->mimeTypeDetector = $mimeTypeDetector; } /** diff --git a/apps/workflowengine/lib/Check/FileName.php b/apps/workflowengine/lib/Check/FileName.php index b4c41811182..4a9d503018f 100644 --- a/apps/workflowengine/lib/Check/FileName.php +++ b/apps/workflowengine/lib/Check/FileName.php @@ -18,19 +18,16 @@ use OCP\WorkflowEngine\IFileCheck; class FileName extends AbstractStringCheck implements IFileCheck { use TFileCheck; - /** @var IRequest */ - protected $request; - /** @var IMountManager */ - private $mountManager; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request, IMountManager $mountManager) { + public function __construct( + IL10N $l, + protected IRequest $request, + private IMountManager $mountManager, + ) { parent::__construct($l); - $this->request = $request; - $this->mountManager = $mountManager; } /** diff --git a/apps/workflowengine/lib/Check/FileSize.php b/apps/workflowengine/lib/Check/FileSize.php index 51d7d38a7af..c1ee1d85ae9 100644 --- a/apps/workflowengine/lib/Check/FileSize.php +++ b/apps/workflowengine/lib/Check/FileSize.php @@ -16,19 +16,14 @@ class FileSize implements ICheck { /** @var int */ protected $size; - /** @var IL10N */ - protected $l; - - /** @var IRequest */ - protected $request; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request) { - $this->l = $l; - $this->request = $request; + public function __construct( + protected IL10N $l, + protected IRequest $request, + ) { } /** diff --git a/apps/workflowengine/lib/Check/FileSystemTags.php b/apps/workflowengine/lib/Check/FileSystemTags.php index e8d27c1c4ad..bd1609e9aff 100644 --- a/apps/workflowengine/lib/Check/FileSystemTags.php +++ b/apps/workflowengine/lib/Check/FileSystemTags.php @@ -29,31 +29,13 @@ class FileSystemTags implements ICheck, IFileCheck { /** @var array */ protected $fileSystemTags; - /** @var IL10N */ - protected $l; - - /** @var ISystemTagManager */ - protected $systemTagManager; - - /** @var ISystemTagObjectMapper */ - protected $systemTagObjectMapper; - /** @var IUserSession */ - protected $userSession; - /** @var IGroupManager */ - protected $groupManager; - public function __construct( - IL10N $l, - ISystemTagManager $systemTagManager, - ISystemTagObjectMapper $systemTagObjectMapper, - IUserSession $userSession, - IGroupManager $groupManager, + protected IL10N $l, + protected ISystemTagManager $systemTagManager, + protected ISystemTagObjectMapper $systemTagObjectMapper, + protected IUserSession $userSession, + protected IGroupManager $groupManager, ) { - $this->l = $l; - $this->systemTagManager = $systemTagManager; - $this->systemTagObjectMapper = $systemTagObjectMapper; - $this->userSession = $userSession; - $this->groupManager = $groupManager; } /** diff --git a/apps/workflowengine/lib/Check/RequestRemoteAddress.php b/apps/workflowengine/lib/Check/RequestRemoteAddress.php index 909b26c74d6..6fb5a3026d6 100644 --- a/apps/workflowengine/lib/Check/RequestRemoteAddress.php +++ b/apps/workflowengine/lib/Check/RequestRemoteAddress.php @@ -11,19 +11,14 @@ use OCP\WorkflowEngine\ICheck; class RequestRemoteAddress implements ICheck { - /** @var IL10N */ - protected $l; - - /** @var IRequest */ - protected $request; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request) { - $this->l = $l; - $this->request = $request; + public function __construct( + protected IL10N $l, + protected IRequest $request, + ) { } /** diff --git a/apps/workflowengine/lib/Check/RequestTime.php b/apps/workflowengine/lib/Check/RequestTime.php index 3bb1dba9d93..f4d2093dc50 100644 --- a/apps/workflowengine/lib/Check/RequestTime.php +++ b/apps/workflowengine/lib/Check/RequestTime.php @@ -16,18 +16,13 @@ class RequestTime implements ICheck { /** @var bool[] */ protected $cachedResults; - /** @var IL10N */ - protected $l; - - /** @var ITimeFactory */ - protected $timeFactory; - /** * @param ITimeFactory $timeFactory */ - public function __construct(IL10N $l, ITimeFactory $timeFactory) { - $this->l = $l; - $this->timeFactory = $timeFactory; + public function __construct( + protected IL10N $l, + protected ITimeFactory $timeFactory, + ) { } /** diff --git a/apps/workflowengine/lib/Check/RequestURL.php b/apps/workflowengine/lib/Check/RequestURL.php index 43123bddbe9..62d6dbc5c38 100644 --- a/apps/workflowengine/lib/Check/RequestURL.php +++ b/apps/workflowengine/lib/Check/RequestURL.php @@ -14,16 +14,15 @@ class RequestURL extends AbstractStringCheck { /** @var ?string */ protected $url; - /** @var IRequest */ - protected $request; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request) { + public function __construct( + IL10N $l, + protected IRequest $request, + ) { parent::__construct($l); - $this->request = $request; } /** diff --git a/apps/workflowengine/lib/Check/RequestUserAgent.php b/apps/workflowengine/lib/Check/RequestUserAgent.php index 2ae630394fb..47db1bb0c68 100644 --- a/apps/workflowengine/lib/Check/RequestUserAgent.php +++ b/apps/workflowengine/lib/Check/RequestUserAgent.php @@ -10,16 +10,15 @@ use OCP\IRequest; class RequestUserAgent extends AbstractStringCheck { - /** @var IRequest */ - protected $request; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request) { + public function __construct( + IL10N $l, + protected IRequest $request, + ) { parent::__construct($l); - $this->request = $request; } /** diff --git a/apps/workflowengine/lib/Check/TFileCheck.php b/apps/workflowengine/lib/Check/TFileCheck.php index 0304a76bd21..a514352e047 100644 --- a/apps/workflowengine/lib/Check/TFileCheck.php +++ b/apps/workflowengine/lib/Check/TFileCheck.php @@ -11,6 +11,7 @@ namespace OCA\WorkflowEngine\Check; use OCA\WorkflowEngine\AppInfo\Application; use OCA\WorkflowEngine\Entity\File; use OCP\Files\Node; +use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorage; use OCP\WorkflowEngine\IEntity; @@ -37,7 +38,7 @@ trait TFileCheck { } /** - * @throws \OCP\Files\NotFoundException + * @throws NotFoundException */ public function setEntitySubject(IEntity $entity, $subject): void { if ($entity instanceof File) { diff --git a/apps/workflowengine/lib/Check/UserGroupMembership.php b/apps/workflowengine/lib/Check/UserGroupMembership.php index 1c2e535b346..215557a75a9 100644 --- a/apps/workflowengine/lib/Check/UserGroupMembership.php +++ b/apps/workflowengine/lib/Check/UserGroupMembership.php @@ -20,24 +20,16 @@ class UserGroupMembership implements ICheck { /** @var string[] */ protected $cachedGroupMemberships; - /** @var IUserSession */ - protected $userSession; - - /** @var IGroupManager */ - protected $groupManager; - - /** @var IL10N */ - protected $l; - /** * @param IUserSession $userSession * @param IGroupManager $groupManager * @param IL10N $l */ - public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) { - $this->userSession = $userSession; - $this->groupManager = $groupManager; - $this->l = $l; + public function __construct( + protected IUserSession $userSession, + protected IGroupManager $groupManager, + protected IL10N $l, + ) { } /** diff --git a/apps/workflowengine/lib/Command/Index.php b/apps/workflowengine/lib/Command/Index.php index 395df8c84bb..1fb8cb416b0 100644 --- a/apps/workflowengine/lib/Command/Index.php +++ b/apps/workflowengine/lib/Command/Index.php @@ -18,11 +18,9 @@ use Symfony\Component\Console\Output\OutputInterface; class Index extends Command { - /** @var Manager */ - private $manager; - - public function __construct(Manager $manager) { - $this->manager = $manager; + public function __construct( + private Manager $manager, + ) { parent::__construct(); } diff --git a/apps/workflowengine/lib/Controller/AWorkflowController.php b/apps/workflowengine/lib/Controller/AWorkflowController.php index 6863cd12ab5..6395d0d98f6 100644 --- a/apps/workflowengine/lib/Controller/AWorkflowController.php +++ b/apps/workflowengine/lib/Controller/AWorkflowController.php @@ -22,22 +22,13 @@ use Psr\Log\LoggerInterface; abstract class AWorkflowController extends OCSController { - /** @var Manager */ - protected $manager; - - /** @var LoggerInterface */ - private $logger; - public function __construct( $appName, IRequest $request, - Manager $manager, - LoggerInterface $logger, + protected Manager $manager, + private LoggerInterface $logger, ) { parent::__construct($appName, $request); - - $this->manager = $manager; - $this->logger = $logger; } /** diff --git a/apps/workflowengine/lib/Controller/UserWorkflowsController.php b/apps/workflowengine/lib/Controller/UserWorkflowsController.php index a615a280f32..953ce149233 100644 --- a/apps/workflowengine/lib/Controller/UserWorkflowsController.php +++ b/apps/workflowengine/lib/Controller/UserWorkflowsController.php @@ -22,9 +22,6 @@ use Psr\Log\LoggerInterface; class UserWorkflowsController extends AWorkflowController { - /** @var IUserSession */ - private $session; - /** @var ScopeContext */ private $scopeContext; @@ -32,12 +29,10 @@ class UserWorkflowsController extends AWorkflowController { $appName, IRequest $request, Manager $manager, - IUserSession $session, + private IUserSession $session, LoggerInterface $logger, ) { parent::__construct($appName, $request, $manager, $logger); - - $this->session = $session; } /** diff --git a/apps/workflowengine/lib/Entity/File.php b/apps/workflowengine/lib/Entity/File.php index f9234926e4d..64d552e1737 100644 --- a/apps/workflowengine/lib/Entity/File.php +++ b/apps/workflowengine/lib/Entity/File.php @@ -34,50 +34,28 @@ use OCP\WorkflowEngine\IRuleMatcher; class File implements IEntity, IDisplayText, IUrl, IIcon, IContextPortation { private const EVENT_NAMESPACE = '\OCP\Files::'; - - /** @var IL10N */ - protected $l10n; - /** @var IURLGenerator */ - protected $urlGenerator; - /** @var IRootFolder */ - protected $root; /** @var string */ protected $eventName; /** @var Event */ protected $event; - /** @var IUserSession */ - private $userSession; - /** @var ISystemTagManager */ - private $tagManager; /** @var ?Node */ private $node; /** @var ?IUser */ private $actingUser = null; - /** @var IUserManager */ - private $userManager; /** @var UserMountCache */ private $userMountCache; - /** @var IMountManager */ - private $mountManager; public function __construct( - IL10N $l10n, - IURLGenerator $urlGenerator, - IRootFolder $root, - IUserSession $userSession, - ISystemTagManager $tagManager, - IUserManager $userManager, + protected IL10N $l10n, + protected IURLGenerator $urlGenerator, + protected IRootFolder $root, + private IUserSession $userSession, + private ISystemTagManager $tagManager, + private IUserManager $userManager, UserMountCache $userMountCache, - IMountManager $mountManager, + private IMountManager $mountManager, ) { - $this->l10n = $l10n; - $this->urlGenerator = $urlGenerator; - $this->root = $root; - $this->userSession = $userSession; - $this->tagManager = $tagManager; - $this->userManager = $userManager; $this->userMountCache = $userMountCache; - $this->mountManager = $mountManager; } public function getName(): string { diff --git a/apps/workflowengine/lib/Service/RuleMatcher.php b/apps/workflowengine/lib/Service/RuleMatcher.php index 46758456205..c95387e14ee 100644 --- a/apps/workflowengine/lib/Service/RuleMatcher.php +++ b/apps/workflowengine/lib/Service/RuleMatcher.php @@ -27,39 +27,24 @@ use RuntimeException; class RuleMatcher implements IRuleMatcher { - /** @var IUserSession */ - protected $session; - /** @var IManager */ - protected $manager; /** @var array */ protected $contexts; - /** @var IServerContainer */ - protected $container; /** @var array */ protected $fileInfo = []; - /** @var IL10N */ - protected $l; /** @var IOperation */ protected $operation; /** @var IEntity */ protected $entity; - /** @var Logger */ - protected $logger; /** @var string */ protected $eventName; public function __construct( - IUserSession $session, - IServerContainer $container, - IL10N $l, - Manager $manager, - Logger $logger, + protected IUserSession $session, + protected IServerContainer $container, + protected IL10N $l, + protected Manager $manager, + protected Logger $logger, ) { - $this->session = $session; - $this->manager = $manager; - $this->container = $container; - $this->l = $l; - $this->logger = $logger; } public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { diff --git a/apps/workflowengine/lib/Settings/ASettings.php b/apps/workflowengine/lib/Settings/ASettings.php index 8b875db043c..23e958755de 100644 --- a/apps/workflowengine/lib/Settings/ASettings.php +++ b/apps/workflowengine/lib/Settings/ASettings.php @@ -26,30 +26,15 @@ use OCP\WorkflowEngine\IOperation; use OCP\WorkflowEngine\ISpecificOperation; abstract class ASettings implements ISettings { - private IL10N $l10n; - private string $appName; - private IEventDispatcher $eventDispatcher; - protected Manager $manager; - private IInitialState $initialStateService; - private IConfig $config; - private IURLGenerator $urlGenerator; - public function __construct( - string $appName, - IL10N $l, - IEventDispatcher $eventDispatcher, - Manager $manager, - IInitialState $initialStateService, - IConfig $config, - IURLGenerator $urlGenerator, + private string $appName, + private IL10N $l10n, + private IEventDispatcher $eventDispatcher, + protected Manager $manager, + private IInitialState $initialStateService, + private IConfig $config, + private IURLGenerator $urlGenerator, ) { - $this->appName = $appName; - $this->l10n = $l; - $this->eventDispatcher = $eventDispatcher; - $this->manager = $manager; - $this->initialStateService = $initialStateService; - $this->config = $config; - $this->urlGenerator = $urlGenerator; } abstract public function getScope(): int; diff --git a/apps/workflowengine/lib/Settings/Section.php b/apps/workflowengine/lib/Settings/Section.php index 1e23eee64ee..5a13a9e4cec 100644 --- a/apps/workflowengine/lib/Settings/Section.php +++ b/apps/workflowengine/lib/Settings/Section.php @@ -11,18 +11,14 @@ use OCP\IURLGenerator; use OCP\Settings\IIconSection; class Section implements IIconSection { - /** @var IL10N */ - private $l; - /** @var IURLGenerator */ - private $url; - /** * @param IURLGenerator $url * @param IL10N $l */ - public function __construct(IURLGenerator $url, IL10N $l) { - $this->url = $url; - $this->l = $l; + public function __construct( + private IURLGenerator $url, + private IL10N $l, + ) { } /** diff --git a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php index 3775d7ff768..47b9138819e 100644 --- a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php +++ b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php @@ -11,11 +11,11 @@ use OCP\IRequest; class RequestRemoteAddressTest extends \Test\TestCase { - /** @var \OCP\IRequest|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */ protected $request; /** - * @return \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject + * @return IL10N|\PHPUnit\Framework\MockObject\MockObject */ protected function getL10NMock() { $l = $this->getMockBuilder(IL10N::class) diff --git a/apps/workflowengine/tests/Check/RequestTimeTest.php b/apps/workflowengine/tests/Check/RequestTimeTest.php index 083e6171d29..6b56bb9427a 100644 --- a/apps/workflowengine/tests/Check/RequestTimeTest.php +++ b/apps/workflowengine/tests/Check/RequestTimeTest.php @@ -6,15 +6,16 @@ namespace OCA\WorkflowEngine\Tests\Check; use OCA\WorkflowEngine\Check\RequestTime; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\IL10N; class RequestTimeTest extends \Test\TestCase { - /** @var \OCP\AppFramework\Utility\ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ protected $timeFactory; /** - * @return \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject + * @return IL10N|\PHPUnit\Framework\MockObject\MockObject */ protected function getL10NMock() { $l = $this->getMockBuilder(IL10N::class) diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index c83074709ce..da9e628dd4d 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -335,11 +335,6 @@ <code><![CDATA[$this->principalUri]]></code> </InvalidArgument> </file> - <file src="apps/dav/lib/CardDAV/Xml/Groups.php"> - <InvalidPropertyAssignmentValue> - <code><![CDATA[$groups]]></code> - </InvalidPropertyAssignmentValue> - </file> <file src="apps/dav/lib/Comments/CommentsPlugin.php"> <UndefinedFunction> <code><![CDATA[\Sabre\HTTP\toDate($value)]]></code> @@ -691,9 +686,7 @@ <LessSpecificReturnStatement> <code><![CDATA[$this->files->getMount($path)->getStorage()]]></code> </LessSpecificReturnStatement> - <MoreSpecificReturnType> - <code><![CDATA[\OC\Files\Storage\Storage|null]]></code> - </MoreSpecificReturnType> + <MoreSpecificReturnType/> </file> <file src="apps/federatedfilesharing/lib/Controller/RequestHandlerController.php"> <InvalidArgument> @@ -1247,15 +1240,6 @@ <code><![CDATA[bool]]></code> </InvalidReturnType> </file> - <file src="apps/workflowengine/lib/Service/RuleMatcher.php"> - <UndefinedInterfaceMethod> - <code><![CDATA[getAllConfiguredScopesForOperation]]></code> - <code><![CDATA[getChecks]]></code> - <code><![CDATA[getOperations]]></code> - <code><![CDATA[getOperations]]></code> - <code><![CDATA[isUserScopeEnabled]]></code> - </UndefinedInterfaceMethod> - </file> <file src="core/BackgroundJobs/CheckForUserCertificates.php"> <ParamNameMismatch> <code><![CDATA[$arguments]]></code> diff --git a/build/rector.php b/build/rector.php index db39fb4ce48..b6e46c1e53a 100644 --- a/build/rector.php +++ b/build/rector.php @@ -10,6 +10,7 @@ declare(strict_types=1); use PhpParser\Node; use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface; use Rector\Config\RectorConfig; +use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\ValueObject\Application\File; @@ -67,7 +68,11 @@ $config = RectorConfig::configure() // uncomment to reach your current PHP version // ->withPhpSets() ->withImportNames(importShortClasses:false) - ->withTypeCoverageLevel(0); + ->withTypeCoverageLevel(0) + ->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [ + 'inline_public' => true, + 'rename_property' => true, + ]); $config->registerService(NextcloudNamespaceSkipVoter::class, tag:ClassNameImportSkipVoterInterface::class); |