Skip to content

Commit 45f5daa

Browse files
Merge pull request #54666 from nextcloud/carl/apply-rector
2 parents 9e9f3b9 + 5835599 commit 45f5daa

File tree

10 files changed

+39
-27
lines changed

10 files changed

+39
-27
lines changed

apps/dav/lib/CalDAV/CalendarImpl.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Generator;
1212
use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin;
1313
use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer;
14+
use OCA\DAV\Connector\Sabre\Server;
1415
use OCP\Calendar\CalendarExportOptions;
1516
use OCP\Calendar\Exceptions\CalendarException;
1617
use OCP\Calendar\ICalendarExport;
@@ -170,7 +171,7 @@ public function isShared(): bool {
170171
private function createFromStringInServer(
171172
string $name,
172173
string $calendarData,
173-
\OCA\DAV\Connector\Sabre\Server $server,
174+
Server $server,
174175
): void {
175176
/** @var CustomPrincipalPlugin $plugin */
176177
$plugin = $server->getPlugin('auth');

apps/dav/lib/CalDAV/EmbeddedCalDavServer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin;
1414
use OCA\DAV\CalDAV\Auth\PublicPrincipalPlugin;
1515
use OCA\DAV\CalDAV\Publishing\PublishPlugin;
16+
use OCA\DAV\CalDAV\Schedule\IMipPlugin;
1617
use OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin;
1718
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
1819
use OCA\DAV\Connector\Sabre\CachingTree;
@@ -94,7 +95,7 @@ public function __construct(bool $public = true) {
9495
Server::get(IURLGenerator::class)
9596
));
9697
if ($appConfig->getValueString('dav', 'sendInvitations', 'yes') === 'yes') {
97-
$this->server->addPlugin(Server::get(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
98+
$this->server->addPlugin(Server::get(IMipPlugin::class));
9899
}
99100

100101
// collection preload plugin

apps/files/tests/Controller/ViewControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function testTwoFactorAuthEnabled(): void {
301301
$invokedCountProvideInitialState = $this->exactly(9);
302302
$this->initialState->expects($invokedCountProvideInitialState)
303303
->method('provideInitialState')
304-
->willReturnCallback(function ($key, $data) use ($invokedCountProvideInitialState) {
304+
->willReturnCallback(function ($key, $data) use ($invokedCountProvideInitialState): void {
305305
if ($invokedCountProvideInitialState->numberOfInvocations() === 9) {
306306
$this->assertEquals('isTwoFactorEnabled', $key);
307307
$this->assertTrue($data);

apps/files_sharing/tests/Controller/ShareAPIControllerTest.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use OCP\AppFramework\OCS\OCSForbiddenException;
1717
use OCP\AppFramework\OCS\OCSNotFoundException;
1818
use OCP\Constants;
19+
use OCP\Files\Cache\ICache;
1920
use OCP\Files\File;
2021
use OCP\Files\Folder;
2122
use OCP\Files\IRootFolder;
@@ -5244,7 +5245,7 @@ public function testPopulateTags(): void {
52445245
], $result);
52455246
}
52465247

5247-
public function trustedServerProvider(): array {
5248+
public static function trustedServerProvider(): array {
52485249
return [
52495250
'Trusted server' => [true, true],
52505251
'Untrusted server' => [false, false],
@@ -5272,21 +5273,21 @@ public function testFormatShareWithFederatedShare(bool $isKnownServer, bool $isT
52725273
$nodeId
52735274
);
52745275

5275-
$node = $this->createMock(\OCP\Files\File::class);
5276+
$node = $this->createMock(File::class);
52765277
$node->method('getId')->willReturn($nodeId);
52775278
$node->method('getPath')->willReturn($nodePath);
52785279
$node->method('getInternalPath')->willReturn(ltrim($nodePath, '/'));
5279-
$mountPoint = $this->createMock(\OCP\Files\Mount\IMountPoint::class);
5280+
$mountPoint = $this->createMock(IMountPoint::class);
52805281
$mountPoint->method('getMountType')->willReturn('local');
52815282
$node->method('getMountPoint')->willReturn($mountPoint);
52825283
$node->method('getMimetype')->willReturn('text/plain');
5283-
$storage = $this->createMock(\OCP\Files\Storage\IStorage::class);
5284-
$storageCache = $this->createMock(\OCP\Files\Cache\ICache::class);
5284+
$storage = $this->createMock(IStorage::class);
5285+
$storageCache = $this->createMock(ICache::class);
52855286
$storageCache->method('getNumericStorageId')->willReturn(1);
52865287
$storage->method('getCache')->willReturn($storageCache);
52875288
$storage->method('getId')->willReturn('home::shareOwner');
52885289
$node->method('getStorage')->willReturn($storage);
5289-
$parent = $this->createMock(\OCP\Files\Folder::class);
5290+
$parent = $this->createMock(Folder::class);
52905291
$parent->method('getId')->willReturn(2);
52915292
$node->method('getParent')->willReturn($parent);
52925293
$node->method('getSize')->willReturn(1234);
@@ -5334,21 +5335,21 @@ public function testFormatShareWithFederatedShareWithAtInUsername(): void {
53345335
$nodeId
53355336
);
53365337

5337-
$node = $this->createMock(\OCP\Files\File::class);
5338+
$node = $this->createMock(File::class);
53385339
$node->method('getId')->willReturn($nodeId);
53395340
$node->method('getPath')->willReturn($nodePath);
53405341
$node->method('getInternalPath')->willReturn(ltrim($nodePath, '/'));
5341-
$mountPoint = $this->createMock(\OCP\Files\Mount\IMountPoint::class);
5342+
$mountPoint = $this->createMock(IMountPoint::class);
53425343
$mountPoint->method('getMountType')->willReturn('local');
53435344
$node->method('getMountPoint')->willReturn($mountPoint);
53445345
$node->method('getMimetype')->willReturn('text/plain');
5345-
$storage = $this->createMock(\OCP\Files\Storage\IStorage::class);
5346-
$storageCache = $this->createMock(\OCP\Files\Cache\ICache::class);
5346+
$storage = $this->createMock(IStorage::class);
5347+
$storageCache = $this->createMock(ICache::class);
53475348
$storageCache->method('getNumericStorageId')->willReturn(1);
53485349
$storage->method('getCache')->willReturn($storageCache);
53495350
$storage->method('getId')->willReturn('home::shareOwner');
53505351
$node->method('getStorage')->willReturn($storage);
5351-
$parent = $this->createMock(\OCP\Files\Folder::class);
5352+
$parent = $this->createMock(Folder::class);
53525353
$parent->method('getId')->willReturn(2);
53535354
$node->method('getParent')->willReturn($parent);
53545355
$node->method('getSize')->willReturn(1234);

apps/files_trashbin/tests/Command/ExpireTrashTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function testRetentionObligation(string $obligation, string $quota, int $
110110
$this->assertEquals($shouldExpire ? 0 : 1, count($trashFiles));
111111
}
112112

113-
public function retentionObligationProvider(): array {
113+
public static function retentionObligationProvider(): array {
114114
$hour = 3600; // 60 * 60
115115

116116
$oneDay = 24 * $hour;

core/AppInfo/Capabilities.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OCP\IDateTimeZone;
1414
use OCP\IGroupManager;
1515
use OCP\IUserSession;
16+
use OCP\Server;
1617

1718
class Capabilities implements ICapability {
1819

@@ -33,7 +34,7 @@ public function getCapabilities(): array {
3334

3435
$user = $this->session->getUser();
3536
if ($user !== null) {
36-
$timezone = \OCP\Server::get(IDateTimeZone::class)->getTimeZone();
37+
$timezone = Server::get(IDateTimeZone::class)->getTimeZone();
3738

3839
$capabilities['user'] = [
3940
'language' => $this->userConfig->getValueString($user->getUID(), Application::APP_ID, ConfigLexicon::USER_LANGUAGE),

core/Command/TaskProcessing/Cleanup.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
use OC\TaskProcessing\Db\TaskMapper;
1313
use OC\TaskProcessing\Manager;
1414
use OCP\Files\AppData\IAppDataFactory;
15+
use OCP\Files\IAppData;
16+
use OCP\Files\NotFoundException;
1517
use Psr\Log\LoggerInterface;
1618
use Symfony\Component\Console\Input\InputArgument;
1719
use Symfony\Component\Console\Input\InputInterface;
1820
use Symfony\Component\Console\Output\OutputInterface;
1921

2022
class Cleanup extends Base {
21-
private \OCP\Files\IAppData $appData;
23+
private IAppData $appData;
2224

2325
public function __construct(
2426
protected Manager $taskProcessingManager,
@@ -76,15 +78,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7678
foreach ($textToImageDeletedFileNames as $entry) {
7779
$output->writeln("<info>\t - " . 'Deleted appData/core/text2image/' . $entry . '</info>');
7880
}
79-
} catch (\OCP\Files\NotFoundException $e) {
81+
} catch (NotFoundException $e) {
8082
// noop
8183
}
8284
try {
8385
$audioToTextDeletedFileNames = $this->taskProcessingManager->clearFilesOlderThan($this->appData->getFolder('audio2text'), $maxAgeSeconds);
8486
foreach ($audioToTextDeletedFileNames as $entry) {
8587
$output->writeln("<info>\t - " . 'Deleted appData/core/audio2text/' . $entry . '</info>');
8688
}
87-
} catch (\OCP\Files\NotFoundException $e) {
89+
} catch (NotFoundException $e) {
8890
// noop
8991
}
9092

tests/lib/Avatar/GuestAvatarTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use OC\Avatar\GuestAvatar;
1313
use OCP\Files\SimpleFS\InMemoryFile;
14+
use OCP\IConfig;
1415
use PHPUnit\Framework\MockObject\MockObject;
1516
use Psr\Log\LoggerInterface;
1617
use Test\TestCase;
@@ -35,7 +36,7 @@ class GuestAvatarTest extends TestCase {
3536
public function setupGuestAvatar() {
3637
/* @var MockObject|LoggerInterface $logger */
3738
$logger = $this->createMock(LoggerInterface::class);
38-
$config = $this->createMock(\OCP\IConfig::class);
39+
$config = $this->createMock(IConfig::class);
3940
$this->guestAvatar = new GuestAvatar('einstein', $config, $logger);
4041
}
4142

tests/lib/Files/Cache/FileAccessTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99

1010
use OC\Files\Cache\CacheEntry;
1111
use OC\Files\Cache\FileAccess;
12+
use OC\Files\Mount\LocalHomeMountProvider;
13+
use OC\FilesMetadata\FilesMetadataManager;
14+
use OC\SystemConfig;
1215
use OCP\DB\QueryBuilder\IQueryBuilder;
16+
use OCP\Files\IMimeTypeLoader;
1317
use OCP\IDBConnection;
18+
use OCP\Server;
1419
use Psr\Log\LoggerInterface;
1520
use Test\TestCase;
1621

@@ -25,15 +30,15 @@ protected function setUp(): void {
2530
parent::setUp();
2631

2732
// Setup the actual database connection (assume the database is configured properly in PHPUnit setup)
28-
$this->dbConnection = \OCP\Server::get(IDBConnection::class);
33+
$this->dbConnection = Server::get(IDBConnection::class);
2934

3035
// Ensure FileAccess is instantiated with the real connection
3136
$this->fileAccess = new FileAccess(
3237
$this->dbConnection,
33-
\OCP\Server::get(\OC\SystemConfig::class),
34-
\OCP\Server::get(LoggerInterface::class),
35-
\OCP\Server::get(\OC\FilesMetadata\FilesMetadataManager::class),
36-
\OCP\Server::get(\OCP\Files\IMimeTypeLoader::class)
38+
Server::get(SystemConfig::class),
39+
Server::get(LoggerInterface::class),
40+
Server::get(FilesMetadataManager::class),
41+
Server::get(IMimeTypeLoader::class)
3742
);
3843

3944
// Clear and prepare `filecache` table for tests
@@ -142,7 +147,7 @@ public function testGetDistinctMountsWithRewriteHomeDirectories(): void {
142147
->values([
143148
'storage_id' => $queryBuilder->createNamedParameter(4, IQueryBuilder::PARAM_INT),
144149
'root_id' => $queryBuilder->createNamedParameter(40, IQueryBuilder::PARAM_INT),
145-
'mount_provider_class' => $queryBuilder->createNamedParameter(\OC\Files\Mount\LocalHomeMountProvider::class),
150+
'mount_provider_class' => $queryBuilder->createNamedParameter(LocalHomeMountProvider::class),
146151
'mount_point' => $queryBuilder->createNamedParameter('/home/user'),
147152
'user_id' => $queryBuilder->createNamedParameter('test'),
148153
])

tests/lib/Files/ObjectStore/PrimaryObjectStoreConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function setUp(): void {
4646
}
4747
});
4848
$this->config->method('setUserValue')
49-
->willReturnCallback(function ($userId, $appName, $key, $value) {
49+
->willReturnCallback(function ($userId, $appName, $key, $value): void {
5050
$this->userConfig[$userId][$appName][$key] = $value;
5151
});
5252

0 commit comments

Comments
 (0)