Skip to content

Commit af38f3b

Browse files
committed
refactor: Run rector on project
Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent 354cae4 commit af38f3b

File tree

102 files changed

+2977
-2455
lines changed

Some content is hidden

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

102 files changed

+2977
-2455
lines changed

.github/workflows/psalm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
run: composer require --dev roave/security-advisories:dev-latest
5757

5858
- name: Install nextcloud/ocp
59-
run: composer require --dev nextcloud/ocp:dev-${{ steps.versions.outputs.branches-max }} --ignore-platform-reqs --with-dependencies
59+
run: composer require --dev nextcloud/ocp:dev-${{ steps.versions.outputs.branches-min }} --ignore-platform-reqs --with-dependencies
6060

6161
- name: Run coding standards check
6262
run: composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"test:integration:dev": "phpunit -c tests/phpunit.integration.xml --no-coverage --order-by=defects --stop-on-defect --fail-on-warning --stop-on-error --stop-on-failure",
2020
"test:unit": "phpunit -c tests/phpunit.unit.xml --fail-on-warning",
2121
"test:unit:dev": "phpunit -c tests/phpunit.unit.xml --no-coverage --order-by=defects --stop-on-defect --fail-on-warning --stop-on-error --stop-on-failure",
22+
"rector": "rector && composer cs:fix",
2223
"post-install-cmd": [
2324
"[ $COMPOSER_DEV_MODE -eq 0 ] || composer bin all install --ansi"
2425
],

lib/AppInfo/Application.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* ownCloud - maps
57
*
@@ -9,7 +11,6 @@
911
* @author Sander Brand <brantje@gmail.com>, Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
1012
* @copyright Sander Brand 2014, Vinzenz Rosenkranz 2016, 2017
1113
*/
12-
1314
namespace OCA\Maps\AppInfo;
1415

1516
use OCA\DAV\Events\CardCreatedEvent;
@@ -76,9 +77,10 @@ public function boot(IBootContext $context): void {
7677
private function registerFeaturePolicy(): void {
7778
$dispatcher = $this->getContainer()->get(IEventDispatcher::class);
7879

79-
$dispatcher->addListener(AddFeaturePolicyEvent::class, function (AddFeaturePolicyEvent $e) {
80+
$dispatcher->addListener(AddFeaturePolicyEvent::class, function (AddFeaturePolicyEvent $e): void {
8081
$fp = new EmptyFeaturePolicy();
81-
$fp->addAllowedGeoLocationDomain('\'self\'');
82+
$fp->addAllowedGeoLocationDomain("'self'");
83+
8284
$e->addPolicy($fp);
8385
});
8486
}

lib/BackgroundJob/AddPhotoJob.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* Nextcloud - maps
57
*
@@ -9,7 +11,6 @@
911
* @author Julien Veyssier
1012
* @copyright Julien Veyssier 2019
1113
*/
12-
1314
namespace OCA\Maps\BackgroundJob;
1415

1516
use OCA\Maps\Service\PhotofilesService;
@@ -22,45 +23,36 @@
2223

2324
class AddPhotoJob extends QueuedJob {
2425

25-
/** @var PhotofilesService */
26-
private PhotofilesService $photofilesService;
27-
28-
/** @var IRootFolder */
29-
private IRootFolder $root;
26+
private readonly IRootFolder $root;
3027

31-
/** @var ICacheFactory */
32-
private ICacheFactory $cacheFactory;
28+
private readonly ICacheFactory $cacheFactory;
3329

34-
/** @var ICache */
35-
private ICache $backgroundJobCache;
30+
private readonly ICache $backgroundJobCache;
3631

3732
/**
3833
* UserInstallScanJob constructor.
3934
*
4035
* A QueuedJob to scan user storage for photos and tracks
41-
*
42-
* @param ITimeFactory $timeFactory
43-
* @param PhotofilesService $photofilesService
4436
*/
4537
public function __construct(
4638
ITimeFactory $timeFactory,
4739
IRootFolder $root,
48-
PhotofilesService $photofilesService,
40+
private readonly PhotofilesService $photofilesService,
4941
ICacheFactory $cacheFactory,
5042
) {
5143
parent::__construct($timeFactory);
52-
$this->photofilesService = $photofilesService;
5344
$this->root = $root;
5445
$this->cacheFactory = $cacheFactory;
5546
$this->backgroundJobCache = $this->cacheFactory->createDistributed('maps:background-jobs');
5647
}
5748

58-
public function run($argument) {
49+
public function run($argument): void {
5950
$userFolder = $this->root->getUserFolder($argument['userId']);
6051
$files = $userFolder->getById($argument['photoId']);
6152
if (empty($files)) {
6253
return;
6354
}
55+
6456
$file = array_shift($files);
6557
$this->photofilesService->addPhotoNow($file, $argument['userId']);
6658

lib/BackgroundJob/LaunchUsersInstallScanJob.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* Nextcloud - maps
57
*
@@ -9,14 +11,14 @@
911
* @author Julien Veyssier
1012
* @copyright Julien Veyssier 2019
1113
*/
12-
1314
namespace OCA\Maps\BackgroundJob;
1415

1516
use OCP\AppFramework\Utility\ITimeFactory;
1617
use OCP\BackgroundJob\IJobList;
1718
use OCP\BackgroundJob\QueuedJob;
1819
use OCP\IUser;
1920
use OCP\IUserManager;
21+
use OCP\Server;
2022
use Psr\Log\LoggerInterface;
2123

2224
class LaunchUsersInstallScanJob extends QueuedJob {
@@ -25,20 +27,18 @@ class LaunchUsersInstallScanJob extends QueuedJob {
2527
* LaunchUsersInstallScanJob constructor.
2628
*
2729
* A QueuedJob to launch a scan job for each user
28-
*
29-
* @param IJobList $jobList
3030
*/
3131
public function __construct(
3232
ITimeFactory $timeFactory,
33-
private IJobList $jobList,
34-
private IUserManager $userManager,
33+
private readonly IJobList $jobList,
34+
private readonly IUserManager $userManager,
3535
) {
3636
parent::__construct($timeFactory);
3737
}
3838

39-
public function run($argument) {
40-
\OCP\Server::get(LoggerInterface::class)->debug('Launch users install scan jobs cronjob executed');
41-
$this->userManager->callForSeenUsers(function (IUser $user) {
39+
public function run($argument): void {
40+
Server::get(LoggerInterface::class)->debug('Launch users install scan jobs cronjob executed');
41+
$this->userManager->callForSeenUsers(function (IUser $user): void {
4242
$this->jobList->add(UserInstallScanJob::class, ['userId' => $user->getUID()]);
4343
});
4444
}

lib/BackgroundJob/LookupMissingGeoJob.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* Nextcloud - maps
57
*
@@ -9,13 +11,13 @@
911
* @author Arne Hamann
1012
* @copyright Arne Hamann 2019
1113
*/
12-
1314
namespace OCA\Maps\BackgroundJob;
1415

1516
use OCA\Maps\Service\AddressService;
1617
use OCP\AppFramework\Utility\ITimeFactory;
1718
use OCP\BackgroundJob\IJobList;
1819
use OCP\BackgroundJob\QueuedJob;
20+
use OCP\Server;
1921
use Psr\Log\LoggerInterface;
2022

2123
class LookupMissingGeoJob extends QueuedJob {
@@ -27,14 +29,14 @@ class LookupMissingGeoJob extends QueuedJob {
2729
*/
2830
public function __construct(
2931
ITimeFactory $timeFactory,
30-
private AddressService $addressService,
31-
private IJobList $jobList,
32+
private readonly AddressService $addressService,
33+
private readonly IJobList $jobList,
3234
) {
3335
parent::__construct($timeFactory);
3436
}
3537

36-
public function run($argument) {
37-
\OCP\Server::get(LoggerInterface::class)->debug('Maps address lookup cronjob executed');
38+
public function run($argument): void {
39+
Server::get(LoggerInterface::class)->debug('Maps address lookup cronjob executed');
3840
// lookup at most 200 addresses
3941
if (!$this->addressService->lookupMissingGeo(200)) {
4042
// if not all addresses where looked up successfully add a new job for next time

lib/BackgroundJob/UpdatePhotoByFileJob.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* Nextcloud - maps
57
*
@@ -9,7 +11,6 @@
911
* @author Julien Veyssier
1012
* @copyright Julien Veyssier 2019
1113
*/
12-
1314
namespace OCA\Maps\BackgroundJob;
1415

1516
use OCA\Maps\Service\PhotofilesService;
@@ -22,7 +23,7 @@
2223
use OCP\ICacheFactory;
2324

2425
class UpdatePhotoByFileJob extends QueuedJob {
25-
private ICache $backgroundJobCache;
26+
private readonly ICache $backgroundJobCache;
2627

2728
/**
2829
* UserInstallScanJob constructor.
@@ -31,9 +32,9 @@ class UpdatePhotoByFileJob extends QueuedJob {
3132
*/
3233
public function __construct(
3334
ITimeFactory $timeFactory,
34-
private IRootFolder $root,
35-
private PhotofilesService $photofilesService,
36-
private ICacheFactory $cacheFactory,
35+
private readonly IRootFolder $root,
36+
private readonly PhotofilesService $photofilesService,
37+
private readonly ICacheFactory $cacheFactory,
3738
) {
3839
parent::__construct($timeFactory);
3940
$this->backgroundJobCache = $this->cacheFactory->createDistributed('maps:background-jobs');
@@ -45,6 +46,7 @@ public function run($argument): void {
4546
if (!$file instanceof File) {
4647
return;
4748
}
49+
4850
$this->photofilesService->updateByFileNow($file);
4951

5052
$counter = $this->backgroundJobCache->get('recentlyUpdated:' . $argument['userId']) ?? 0;

lib/BackgroundJob/UserInstallScanJob.php

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* Nextcloud - maps
57
*
@@ -9,71 +11,65 @@
911
* @author Julien Veyssier
1012
* @copyright Julien Veyssier 2019
1113
*/
12-
1314
namespace OCA\Maps\BackgroundJob;
1415

1516
use OCA\Maps\Service\PhotofilesService;
1617
use OCA\Maps\Service\TracksService;
1718
use OCP\AppFramework\Utility\ITimeFactory;
1819
use OCP\BackgroundJob\IJobList;
1920
use OCP\BackgroundJob\QueuedJob;
20-
2121
use OCP\IConfig;
22+
2223
use OCP\IUserManager;
24+
use OCP\Server;
2325
use Psr\Log\LoggerInterface;
2426

2527
class UserInstallScanJob extends QueuedJob {
2628

27-
private IJobList $jobList;
28-
private IConfig $config;
29-
private IUserManager $userManager;
30-
private PhotofilesService $photofilesService;
31-
private TracksService $tracksService;
29+
private readonly IConfig $config;
30+
3231

3332
/**
3433
* UserInstallScanJob constructor.
3534
*
3635
* A QueuedJob to scan user storage for photos and tracks
37-
*
38-
* @param IJobList $jobList
3936
*/
40-
public function __construct(ITimeFactory $timeFactory, IJobList $jobList,
37+
public function __construct(
38+
ITimeFactory $timeFactory,
39+
IJobList $jobList,
4140
IUserManager $userManager,
4241
IConfig $config,
43-
PhotofilesService $photofilesService,
44-
TracksService $tracksService) {
42+
private readonly PhotofilesService $photofilesService,
43+
private readonly TracksService $tracksService,
44+
) {
4545
parent::__construct($timeFactory);
4646
$this->config = $config;
47-
$this->jobList = $jobList;
48-
$this->userManager = $userManager;
49-
$this->photofilesService = $photofilesService;
50-
$this->tracksService = $tracksService;
5147
}
5248

53-
public function run($argument) {
49+
public function run($argument): void {
5450
$userId = $argument['userId'];
55-
\OCP\Server::get(LoggerInterface::class)->debug('Launch user install scan job for ' . $userId . ' cronjob executed');
51+
Server::get(LoggerInterface::class)->debug('Launch user install scan job for ' . $userId . ' cronjob executed');
5652
// scan photos and tracks for given user
5753
$this->rescanUserPhotos($userId);
5854
$this->rescanUserTracks($userId);
5955
$this->config->setUserValue($userId, 'maps', 'installScanDone', 'yes');
6056
}
6157

62-
private function rescanUserPhotos($userId) {
58+
private function rescanUserPhotos($userId): void {
6359
//$this->output->info('======== User '.$userId.' ========'."\n");
6460
$c = 1;
6561
foreach ($this->photofilesService->rescan($userId) as $path) {
6662
//$this->output->info('['.$c.'] Photo "'.$path.'" added'."\n");
67-
$c++;
63+
++$c;
6864
}
6965
}
7066

71-
private function rescanUserTracks($userId) {
67+
private function rescanUserTracks($userId): void {
7268
//$this->output->info('======== User '.$userId.' ========'."\n");
7369
$c = 1;
7470
foreach ($this->tracksService->rescan($userId) as $path) {
7571
//$this->output->info('['.$c.'] Track "'.$path.'" added'."\n");
76-
$c++;
72+
++$c;
7773
}
7874
}
7975

lib/Command/RegisterMimetypes.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* Nextcloud - maps
57
*
@@ -9,7 +11,6 @@
911
* @author Piotr Bator <prbator@gmail.com>
1012
* @copyright Piotr Bator 2017
1113
*/
12-
1314
namespace OCA\Maps\Command;
1415

1516
use OCA\Maps\Service\MimetypeService;
@@ -19,11 +20,10 @@
1920

2021
class RegisterMimetypes extends Command {
2122

22-
protected MimetypeService $mimetypeService;
23-
24-
public function __construct(MimetypeService $mimetypeService) {
23+
public function __construct(
24+
protected MimetypeService $mimetypeService,
25+
) {
2526
parent::__construct();
26-
$this->mimetypeService = $mimetypeService;
2727
}
2828

2929
/**
@@ -34,11 +34,6 @@ protected function configure() {
3434
->setDescription('Registers the maps mimetypes for existing and new files.');
3535
}
3636

37-
/**
38-
* @param InputInterface $input
39-
* @param OutputInterface $output
40-
* @return int
41-
*/
4237
protected function execute(InputInterface $input, OutputInterface $output): int {
4338
$output->writeln('Register mimetypes for existing files');
4439
$this->mimetypeService->registerForExistingFiles();

0 commit comments

Comments
 (0)