aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/lib
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-10-18 12:04:22 +0200
committerprovokateurin <kate@provokateurin.de>2024-10-21 12:37:59 +0200
commit381077028adf388a7081cf42026570c6be47b198 (patch)
treec0f8e9b6caea80d6b55d6fdcc9188ba57197fa0f /apps/user_status/lib
parent4d8d11d2f79da348644e0902e78a2f000498cd52 (diff)
downloadnextcloud-server-381077028adf388a7081cf42026570c6be47b198.tar.gz
nextcloud-server-381077028adf388a7081cf42026570c6be47b198.zip
refactor(apps): Use constructor property promotion when possible
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'apps/user_status/lib')
-rw-r--r--apps/user_status/lib/BackgroundJob/ClearOldStatusesBackgroundJob.php10
-rw-r--r--apps/user_status/lib/Capabilities.php7
-rw-r--r--apps/user_status/lib/Connector/UserStatus.php24
-rw-r--r--apps/user_status/lib/Connector/UserStatusProvider.php8
-rw-r--r--apps/user_status/lib/Controller/HeartbeatController.php28
-rw-r--r--apps/user_status/lib/Controller/PredefinedStatusController.php10
-rw-r--r--apps/user_status/lib/Controller/StatusesController.php10
-rw-r--r--apps/user_status/lib/Dashboard/UserStatusWidget.php31
-rw-r--r--apps/user_status/lib/Db/UserStatusMapper.php3
-rw-r--r--apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php18
-rw-r--r--apps/user_status/lib/Listener/UserDeletedListener.php8
-rw-r--r--apps/user_status/lib/Listener/UserLiveStatusListener.php13
-rw-r--r--apps/user_status/lib/Service/JSDataService.php14
-rw-r--r--apps/user_status/lib/Service/PredefinedStatusService.php8
14 files changed, 63 insertions, 129 deletions
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,
+ ) {
}
/**