Skip to content

Commit 15a786d

Browse files
authored
Merge pull request #1117 from nextcloud/carl/rector
refactor(rector): Run rector
2 parents b0519b8 + 1023b1f commit 15a786d

22 files changed

+487
-114
lines changed

lib/AppInfo/Application.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public function boot(IBootContext $context): void {
7373
}
7474
});
7575

76-
$context->injectFn([$this, 'registerNotifier']);
77-
$context->injectFn([$this, 'createNotificationOnFirstLogin']);
78-
$context->injectFn([$this, 'registerFrontend']);
76+
$context->injectFn($this->registerNotifier(...));
77+
$context->injectFn($this->createNotificationOnFirstLogin(...));
78+
$context->injectFn($this->registerFrontend(...));
7979
}
8080

8181
public function registerFrontend(IRequest $request, IAppConfig $appConfig, IUserSession $userSession): void {
@@ -123,7 +123,7 @@ public function registerFrontend(IRequest $request, IAppConfig $appConfig, IUser
123123

124124
public function addStorageWrapper(): void {
125125
Filesystem::addStorageWrapper(
126-
'terms_of_service', [$this, 'addStorageWrapperCallback'], -10
126+
'terms_of_service', $this->addStorageWrapperCallback(...), -10
127127
);
128128
}
129129

@@ -139,12 +139,12 @@ public function addStorageWrapperCallback(string $mountPoint, IStorage $storage)
139139
[
140140
'storage' => $storage,
141141
'mountPoint' => $mountPoint,
142-
'request' => \OC::$server->get(IRequest::class),
143-
'checker' => \OC::$server->get(Checker::class),
142+
'request' => \OCP\Server::get(IRequest::class),
143+
'checker' => \OCP\Server::get(Checker::class),
144144
]
145145
);
146146
} catch (ContainerExceptionInterface $e) {
147-
\OC::$server->get(LoggerInterface::class)->error(
147+
\OCP\Server::get(LoggerInterface::class)->error(
148148
$e->getMessage(),
149149
['exception' => $e]
150150
);

lib/BackgroundJobs/CreateNotifications.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function run($argument): void {
6363

6464
$this->notificationsManager->defer();
6565
$this->currentBatch = 0;
66-
$this->userManager->callForSeenUsers(\Closure::fromCallable([$this, 'callForSeenUsers']));
66+
$this->userManager->callForSeenUsers($this->callForSeenUsers(...));
6767
$this->notificationsManager->flush();
6868
}
6969

lib/Checker.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ class Checker {
2222
private array $termsCache = [];
2323

2424
public function __construct(
25-
private IRequest $request,
26-
private IUserSession $userSession,
27-
private ISession $session,
28-
private SignatoryMapper $signatoryMapper,
29-
private TermsMapper $termsMapper,
30-
private CountryDetector $countryDetector,
31-
private IAppConfig $appConfig,
32-
private \OCP\IAppConfig $globalAppConfig,
33-
private LoggerInterface $logger,
34-
private IURLGenerator $url,
25+
private readonly IRequest $request,
26+
private readonly IUserSession $userSession,
27+
private readonly ISession $session,
28+
private readonly SignatoryMapper $signatoryMapper,
29+
private readonly TermsMapper $termsMapper,
30+
private readonly CountryDetector $countryDetector,
31+
private readonly IAppConfig $appConfig,
32+
private readonly \OCP\IAppConfig $globalAppConfig,
33+
private readonly LoggerInterface $logger,
34+
private readonly IURLGenerator $url,
3535
) {
3636
}
3737

lib/Controller/SigningController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
class SigningController extends OCSController {
3131
public function __construct(
3232
string $appName,
33-
private ?string $userId,
33+
private readonly ?string $userId,
3434
IRequest $request,
35-
private SignatoryMapper $signatoryMapper,
36-
private IManager $notificationsManager,
37-
private IAppConfig $appConfig,
38-
private ISession $session,
39-
private IEventDispatcher $eventDispatcher,
35+
private readonly SignatoryMapper $signatoryMapper,
36+
private readonly IManager $notificationsManager,
37+
private readonly IAppConfig $appConfig,
38+
private readonly ISession $session,
39+
private readonly IEventDispatcher $eventDispatcher,
4040
protected IJobList $jobList,
4141
) {
4242
parent::__construct($appName, $request);

lib/Controller/TermsController.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ class TermsController extends OCSController {
3636
public function __construct(
3737
string $appName,
3838
IRequest $request,
39-
private TermsMapper $termsMapper,
40-
private SignatoryMapper $signatoryMapper,
41-
private CountryMapper $countryMapper,
42-
private LanguageMapper $languageMapper,
43-
private CountryDetector $countryDetector,
44-
private Checker $checker,
45-
private IAppConfig $appConfig,
46-
private IEventDispatcher $eventDispatcher,
39+
private readonly TermsMapper $termsMapper,
40+
private readonly SignatoryMapper $signatoryMapper,
41+
private readonly CountryMapper $countryMapper,
42+
private readonly LanguageMapper $languageMapper,
43+
private readonly CountryDetector $countryDetector,
44+
private readonly Checker $checker,
45+
private readonly IAppConfig $appConfig,
46+
private readonly IEventDispatcher $eventDispatcher,
4747
protected IJobList $jobList,
4848
) {
4949
parent::__construct($appName, $request);

lib/CountryDetector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
class CountryDetector {
1515
public function __construct(
16-
private IRequest $request,
17-
private CountryMapper $countryMapper,
16+
private readonly IRequest $request,
17+
private readonly CountryMapper $countryMapper,
1818
) {
1919
}
2020

lib/Dav/CheckPlugin.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ class CheckPlugin extends ServerPlugin {
2727
*/
2828
public function initialize(Server $server): void {
2929
$this->server = $server;
30-
$server->on('method:PROPFIND', [$this, 'checkToS']);
31-
$server->on('method:PROPPATCH', [$this, 'checkToS']);
32-
$server->on('method:GET', [$this, 'checkToS']);
33-
$server->on('method:POST', [$this, 'checkToS']);
34-
$server->on('method:PUT', [$this, 'checkToS']);
35-
$server->on('method:DELETE', [$this, 'checkToS']);
36-
$server->on('method:MKCOL', [$this, 'checkToS']);
37-
$server->on('method:MOVE', [$this, 'checkToS']);
38-
$server->on('method:COPY', [$this, 'checkToS']);
39-
$server->on('method:REPORT', [$this, 'checkToS']);
30+
$server->on('method:PROPFIND', $this->checkToS(...));
31+
$server->on('method:PROPPATCH', $this->checkToS(...));
32+
$server->on('method:GET', $this->checkToS(...));
33+
$server->on('method:POST', $this->checkToS(...));
34+
$server->on('method:PUT', $this->checkToS(...));
35+
$server->on('method:DELETE', $this->checkToS(...));
36+
$server->on('method:MKCOL', $this->checkToS(...));
37+
$server->on('method:MOVE', $this->checkToS(...));
38+
$server->on('method:COPY', $this->checkToS(...));
39+
$server->on('method:REPORT', $this->checkToS(...));
4040
}
4141

4242
/**

lib/Events/SignaturesResetEvent.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@
1414
* @package OCA\Terms_Of_Service\Events
1515
*/
1616
class SignaturesResetEvent extends Event {
17-
public function __construct() {
18-
}
1917
}

lib/Events/TermsCreatedEvent.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@
1414
* @package OCA\Terms_Of_Service\Events
1515
*/
1616
class TermsCreatedEvent extends Event {
17-
public function __construct() {
18-
}
1917
}

lib/Filesystem/CacheWrapper.php

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,30 @@
99
use OC\Files\Cache\Wrapper\CacheWrapper as Wrapper;
1010
use OCP\Constants;
1111
use OCP\Files\Cache\ICache;
12-
use OCP\Files\Storage\IStorage;
12+
use OCP\Files\Cache\ICacheEntry;
13+
use Override;
1314

1415
class CacheWrapper extends Wrapper {
15-
protected int $mask;
16-
1716
public function __construct(
1817
ICache $cache,
19-
protected IStorage $storage,
20-
private Helper $helper,
18+
private readonly Helper $helper,
2119
) {
2220
parent::__construct($cache);
23-
24-
$this->mask = Constants::PERMISSION_ALL;
25-
$this->mask &= ~Constants::PERMISSION_READ;
26-
$this->mask &= ~Constants::PERMISSION_CREATE;
27-
$this->mask &= ~Constants::PERMISSION_UPDATE;
28-
$this->mask &= ~Constants::PERMISSION_DELETE;
2921
}
3022

31-
public const PERMISSION_CREATE = 4;
32-
public const PERMISSION_READ = 1;
33-
public const PERMISSION_UPDATE = 2;
34-
public const PERMISSION_DELETE = 8;
35-
36-
protected function formatCacheEntry($entry) {
37-
if (isset($entry['path'], $entry['permissions'])
23+
/**
24+
* @param ICacheEntry|false $entry
25+
*/
26+
#[Override]
27+
protected function formatCacheEntry($entry): ICacheEntry|false {
28+
if ($entry !== false && isset($entry['path'], $entry['permissions'])
3829
&& !$this->helper->verifyAccess($entry['path'])) {
39-
$entry['permissions'] &= $this->mask;
30+
$mask = Constants::PERMISSION_ALL
31+
& ~Constants::PERMISSION_READ
32+
& ~Constants::PERMISSION_CREATE
33+
& ~Constants::PERMISSION_UPDATE
34+
& ~Constants::PERMISSION_DELETE;
35+
$entry['permissions'] &= $mask;
4036
}
4137
return $entry;
4238
}

0 commit comments

Comments
 (0)