Skip to content

Commit 3810770

Browse files
committed
refactor(apps): Use constructor property promotion when possible
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 4d8d11d commit 3810770

590 files changed

Lines changed: 2827 additions & 6646 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/cloud_federation_api/lib/Config.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
*/
1717
class Config {
1818

19-
/** @var ICloudFederationProviderManager */
20-
private $cloudFederationProviderManager;
21-
22-
public function __construct(ICloudFederationProviderManager $cloudFederationProviderManager) {
23-
$this->cloudFederationProviderManager = $cloudFederationProviderManager;
19+
public function __construct(
20+
private ICloudFederationProviderManager $cloudFederationProviderManager,
21+
) {
2422
}
2523

2624
/**

apps/comments/lib/Search/Result.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ class Result extends BaseResult {
2525
* @deprecated 20.0.0
2626
*/
2727
public $authorId;
28-
/**
29-
* @deprecated 20.0.0
30-
*/
31-
public string $authorName;
3228
/**
3329
* @deprecated 20.0.0
3430
*/
@@ -45,7 +41,10 @@ class Result extends BaseResult {
4541
public function __construct(
4642
string $search,
4743
IComment $comment,
48-
string $authorName,
44+
/**
45+
* @deprecated 20.0.0
46+
*/
47+
public string $authorName,
4948
string $path,
5049
) {
5150
parent::__construct(
@@ -56,7 +55,6 @@ public function __construct(
5655

5756
$this->comment = $this->getRelevantMessagePart($comment->getMessage(), $search);
5857
$this->authorId = $comment->getActorId();
59-
$this->authorName = $authorName;
6058
$this->fileName = basename($path);
6159
$this->path = $this->getVisiblePath($path);
6260
}

apps/dav/lib/AppInfo/PluginManager.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@
2727
*/
2828
class PluginManager {
2929

30-
/**
31-
* @var ServerContainer
32-
*/
33-
private $container;
34-
35-
/**
36-
* @var IAppManager
37-
*/
38-
private $appManager;
39-
4030
/**
4131
* App plugins
4232
*
@@ -74,9 +64,10 @@ class PluginManager {
7464
* @param ServerContainer $container server container for resolving plugin classes
7565
* @param IAppManager $appManager app manager to loading apps and their info
7666
*/
77-
public function __construct(ServerContainer $container, IAppManager $appManager) {
78-
$this->container = $container;
79-
$this->appManager = $appManager;
67+
public function __construct(
68+
private ServerContainer $container,
69+
private IAppManager $appManager,
70+
) {
8071
}
8172

8273
/**

apps/dav/lib/Avatars/AvatarHome.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,16 @@
1616

1717
class AvatarHome implements ICollection {
1818

19-
/** @var array */
20-
private $principalInfo;
21-
/** @var IAvatarManager */
22-
private $avatarManager;
23-
2419
/**
2520
* AvatarHome constructor.
2621
*
2722
* @param array $principalInfo
2823
* @param IAvatarManager $avatarManager
2924
*/
30-
public function __construct($principalInfo, IAvatarManager $avatarManager) {
31-
$this->principalInfo = $principalInfo;
32-
$this->avatarManager = $avatarManager;
25+
public function __construct(
26+
private $principalInfo,
27+
private IAvatarManager $avatarManager,
28+
) {
3329
}
3430

3531
public function createFile($name, $data = null) {

apps/dav/lib/Avatars/AvatarNode.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,18 @@
1111
use Sabre\DAV\File;
1212

1313
class AvatarNode extends File {
14-
private $ext;
15-
private $size;
16-
private $avatar;
17-
1814
/**
1915
* AvatarNode constructor.
2016
*
2117
* @param integer $size
2218
* @param string $ext
2319
* @param IAvatar $avatar
2420
*/
25-
public function __construct($size, $ext, $avatar) {
26-
$this->size = $size;
27-
$this->ext = $ext;
28-
$this->avatar = $avatar;
21+
public function __construct(
22+
private $size,
23+
private $ext,
24+
private $avatar,
25+
) {
2926
}
3027

3128
/**

apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,20 @@
2222
*/
2323
class BuildReminderIndexBackgroundJob extends QueuedJob {
2424

25-
/** @var IDBConnection */
26-
private $db;
27-
28-
/** @var ReminderService */
29-
private $reminderService;
30-
31-
private LoggerInterface $logger;
32-
33-
/** @var IJobList */
34-
private $jobList;
35-
3625
/** @var ITimeFactory */
3726
private $timeFactory;
3827

3928
/**
4029
* BuildReminderIndexBackgroundJob constructor.
4130
*/
42-
public function __construct(IDBConnection $db,
43-
ReminderService $reminderService,
44-
LoggerInterface $logger,
45-
IJobList $jobList,
46-
ITimeFactory $timeFactory) {
31+
public function __construct(
32+
private IDBConnection $db,
33+
private ReminderService $reminderService,
34+
private LoggerInterface $logger,
35+
private IJobList $jobList,
36+
ITimeFactory $timeFactory,
37+
) {
4738
parent::__construct($timeFactory);
48-
$this->db = $db;
49-
$this->reminderService = $reminderService;
50-
$this->logger = $logger;
51-
$this->jobList = $jobList;
5239
$this->timeFactory = $timeFactory;
5340
}
5441

apps/dav/lib/BackgroundJob/CalendarRetentionJob.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
use OCP\BackgroundJob\TimedJob;
1414

1515
class CalendarRetentionJob extends TimedJob {
16-
/** @var RetentionService */
17-
private $service;
18-
19-
public function __construct(ITimeFactory $time,
20-
RetentionService $service) {
16+
public function __construct(
17+
ITimeFactory $time,
18+
private RetentionService $service,
19+
) {
2120
parent::__construct($time);
22-
$this->service = $service;
2321

2422
// Run four times a day
2523
$this->setInterval(6 * 60 * 60);

apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
use OCP\BackgroundJob\TimedJob;
1414

1515
class CleanupDirectLinksJob extends TimedJob {
16-
/** @var DirectMapper */
17-
private $mapper;
18-
19-
public function __construct(ITimeFactory $timeFactory, DirectMapper $mapper) {
16+
public function __construct(
17+
ITimeFactory $timeFactory,
18+
private DirectMapper $mapper,
19+
) {
2020
parent::__construct($timeFactory);
21-
$this->mapper = $mapper;
2221

2322
// Run once a day at off-peak time
2423
$this->setInterval(24 * 60 * 60);

apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414

1515
class CleanupInvitationTokenJob extends TimedJob {
1616

17-
/** @var IDBConnection */
18-
private $db;
19-
20-
public function __construct(IDBConnection $db, ITimeFactory $time) {
17+
public function __construct(
18+
private IDBConnection $db,
19+
ITimeFactory $time,
20+
) {
2121
parent::__construct($time);
22-
$this->db = $db;
2322

2423
// Run once a day at off-peak time
2524
$this->setInterval(24 * 60 * 60);

apps/dav/lib/BackgroundJob/EventReminderJob.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
namespace OCA\DAV\BackgroundJob;
1010

11+
use OC\User\NoUserException;
1112
use OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException;
1213
use OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException;
1314
use OCA\DAV\CalDAV\Reminder\ReminderService;
@@ -17,18 +18,12 @@
1718

1819
class EventReminderJob extends TimedJob {
1920

20-
/** @var ReminderService */
21-
private $reminderService;
22-
23-
/** @var IConfig */
24-
private $config;
25-
26-
public function __construct(ITimeFactory $time,
27-
ReminderService $reminderService,
28-
IConfig $config) {
21+
public function __construct(
22+
ITimeFactory $time,
23+
private ReminderService $reminderService,
24+
private IConfig $config,
25+
) {
2926
parent::__construct($time);
30-
$this->reminderService = $reminderService;
31-
$this->config = $config;
3227

3328
// Run every 5 minutes
3429
$this->setInterval(5 * 60);
@@ -38,7 +33,7 @@ public function __construct(ITimeFactory $time,
3833
/**
3934
* @throws ProviderNotAvailableException
4035
* @throws NotificationTypeDoesNotExistException
41-
* @throws \OC\User\NoUserException
36+
* @throws NoUserException
4237
*/
4338
public function run($argument):void {
4439
if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {

0 commit comments

Comments
 (0)