From 5835599fa1e00a9c67cd64299e10a981a9599103 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 26 Aug 2025 16:27:26 +0200 Subject: [PATCH] chore(rector): Apply current rector config Signed-off-by: Carl Schwan --- apps/dav/lib/CalDAV/CalendarImpl.php | 3 ++- apps/dav/lib/CalDAV/EmbeddedCalDavServer.php | 3 ++- .../tests/Controller/ViewControllerTest.php | 2 +- .../Controller/ShareAPIControllerTest.php | 23 ++++++++++--------- .../tests/Command/ExpireTrashTest.php | 2 +- core/AppInfo/Capabilities.php | 3 ++- core/Command/TaskProcessing/Cleanup.php | 8 ++++--- tests/lib/Avatar/GuestAvatarTest.php | 3 ++- tests/lib/Files/Cache/FileAccessTest.php | 17 +++++++++----- .../PrimaryObjectStoreConfigTest.php | 2 +- 10 files changed, 39 insertions(+), 27 deletions(-) diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php index 5f912da732e..be88beff370 100644 --- a/apps/dav/lib/CalDAV/CalendarImpl.php +++ b/apps/dav/lib/CalDAV/CalendarImpl.php @@ -11,6 +11,7 @@ namespace OCA\DAV\CalDAV; use Generator; use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin; use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer; +use OCA\DAV\Connector\Sabre\Server; use OCP\Calendar\CalendarExportOptions; use OCP\Calendar\Exceptions\CalendarException; use OCP\Calendar\ICalendarExport; @@ -161,7 +162,7 @@ class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIs private function createFromStringInServer( string $name, string $calendarData, - \OCA\DAV\Connector\Sabre\Server $server, + Server $server, ): void { /** @var CustomPrincipalPlugin $plugin */ $plugin = $server->getPlugin('auth'); diff --git a/apps/dav/lib/CalDAV/EmbeddedCalDavServer.php b/apps/dav/lib/CalDAV/EmbeddedCalDavServer.php index d9d6d840c5e..6037fa3194e 100644 --- a/apps/dav/lib/CalDAV/EmbeddedCalDavServer.php +++ b/apps/dav/lib/CalDAV/EmbeddedCalDavServer.php @@ -13,6 +13,7 @@ use OCA\DAV\AppInfo\PluginManager; use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin; use OCA\DAV\CalDAV\Auth\PublicPrincipalPlugin; use OCA\DAV\CalDAV\Publishing\PublishPlugin; +use OCA\DAV\CalDAV\Schedule\IMipPlugin; use OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin; use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin; use OCA\DAV\Connector\Sabre\CachingTree; @@ -94,7 +95,7 @@ class EmbeddedCalDavServer { Server::get(IURLGenerator::class) )); if ($appConfig->getValueString('dav', 'sendInvitations', 'yes') === 'yes') { - $this->server->addPlugin(Server::get(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class)); + $this->server->addPlugin(Server::get(IMipPlugin::class)); } // collection preload plugin diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index 01aa955a13e..e1a62a9336c 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -301,7 +301,7 @@ class ViewControllerTest extends TestCase { $invokedCountProvideInitialState = $this->exactly(9); $this->initialState->expects($invokedCountProvideInitialState) ->method('provideInitialState') - ->willReturnCallback(function ($key, $data) use ($invokedCountProvideInitialState) { + ->willReturnCallback(function ($key, $data) use ($invokedCountProvideInitialState): void { if ($invokedCountProvideInitialState->numberOfInvocations() === 9) { $this->assertEquals('isTwoFactorEnabled', $key); $this->assertTrue($data); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index e6be0342c26..b7ee24fedd8 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -16,6 +16,7 @@ use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\Constants; +use OCP\Files\Cache\ICache; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; @@ -5244,7 +5245,7 @@ class ShareAPIControllerTest extends TestCase { ], $result); } - public function trustedServerProvider(): array { + public static function trustedServerProvider(): array { return [ 'Trusted server' => [true, true], 'Untrusted server' => [false, false], @@ -5272,21 +5273,21 @@ class ShareAPIControllerTest extends TestCase { $nodeId ); - $node = $this->createMock(\OCP\Files\File::class); + $node = $this->createMock(File::class); $node->method('getId')->willReturn($nodeId); $node->method('getPath')->willReturn($nodePath); $node->method('getInternalPath')->willReturn(ltrim($nodePath, '/')); - $mountPoint = $this->createMock(\OCP\Files\Mount\IMountPoint::class); + $mountPoint = $this->createMock(IMountPoint::class); $mountPoint->method('getMountType')->willReturn('local'); $node->method('getMountPoint')->willReturn($mountPoint); $node->method('getMimetype')->willReturn('text/plain'); - $storage = $this->createMock(\OCP\Files\Storage\IStorage::class); - $storageCache = $this->createMock(\OCP\Files\Cache\ICache::class); + $storage = $this->createMock(IStorage::class); + $storageCache = $this->createMock(ICache::class); $storageCache->method('getNumericStorageId')->willReturn(1); $storage->method('getCache')->willReturn($storageCache); $storage->method('getId')->willReturn('home::shareOwner'); $node->method('getStorage')->willReturn($storage); - $parent = $this->createMock(\OCP\Files\Folder::class); + $parent = $this->createMock(Folder::class); $parent->method('getId')->willReturn(2); $node->method('getParent')->willReturn($parent); $node->method('getSize')->willReturn(1234); @@ -5334,21 +5335,21 @@ class ShareAPIControllerTest extends TestCase { $nodeId ); - $node = $this->createMock(\OCP\Files\File::class); + $node = $this->createMock(File::class); $node->method('getId')->willReturn($nodeId); $node->method('getPath')->willReturn($nodePath); $node->method('getInternalPath')->willReturn(ltrim($nodePath, '/')); - $mountPoint = $this->createMock(\OCP\Files\Mount\IMountPoint::class); + $mountPoint = $this->createMock(IMountPoint::class); $mountPoint->method('getMountType')->willReturn('local'); $node->method('getMountPoint')->willReturn($mountPoint); $node->method('getMimetype')->willReturn('text/plain'); - $storage = $this->createMock(\OCP\Files\Storage\IStorage::class); - $storageCache = $this->createMock(\OCP\Files\Cache\ICache::class); + $storage = $this->createMock(IStorage::class); + $storageCache = $this->createMock(ICache::class); $storageCache->method('getNumericStorageId')->willReturn(1); $storage->method('getCache')->willReturn($storageCache); $storage->method('getId')->willReturn('home::shareOwner'); $node->method('getStorage')->willReturn($storage); - $parent = $this->createMock(\OCP\Files\Folder::class); + $parent = $this->createMock(Folder::class); $parent->method('getId')->willReturn(2); $node->method('getParent')->willReturn($parent); $node->method('getSize')->willReturn(1234); diff --git a/apps/files_trashbin/tests/Command/ExpireTrashTest.php b/apps/files_trashbin/tests/Command/ExpireTrashTest.php index 23bf0d8f121..0d0ee98ca7a 100644 --- a/apps/files_trashbin/tests/Command/ExpireTrashTest.php +++ b/apps/files_trashbin/tests/Command/ExpireTrashTest.php @@ -110,7 +110,7 @@ class ExpireTrashTest extends TestCase { $this->assertEquals($shouldExpire ? 0 : 1, count($trashFiles)); } - public function retentionObligationProvider(): array { + public static function retentionObligationProvider(): array { $hour = 3600; // 60 * 60 $oneDay = 24 * $hour; diff --git a/core/AppInfo/Capabilities.php b/core/AppInfo/Capabilities.php index 67bbfd62b2d..ef599e2b9dc 100644 --- a/core/AppInfo/Capabilities.php +++ b/core/AppInfo/Capabilities.php @@ -13,6 +13,7 @@ use OCP\Config\IUserConfig; use OCP\IDateTimeZone; use OCP\IGroupManager; use OCP\IUserSession; +use OCP\Server; class Capabilities implements ICapability { @@ -33,7 +34,7 @@ class Capabilities implements ICapability { $user = $this->session->getUser(); if ($user !== null) { - $timezone = \OCP\Server::get(IDateTimeZone::class)->getTimeZone(); + $timezone = Server::get(IDateTimeZone::class)->getTimeZone(); $capabilities['user'] = [ 'language' => $this->userConfig->getValueString($user->getUID(), Application::APP_ID, ConfigLexicon::USER_LANGUAGE), diff --git a/core/Command/TaskProcessing/Cleanup.php b/core/Command/TaskProcessing/Cleanup.php index 2ed2cbdec94..7a1b1bea5a7 100644 --- a/core/Command/TaskProcessing/Cleanup.php +++ b/core/Command/TaskProcessing/Cleanup.php @@ -12,13 +12,15 @@ use OC\Core\Command\Base; use OC\TaskProcessing\Db\TaskMapper; use OC\TaskProcessing\Manager; use OCP\Files\AppData\IAppDataFactory; +use OCP\Files\IAppData; +use OCP\Files\NotFoundException; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Cleanup extends Base { - private \OCP\Files\IAppData $appData; + private IAppData $appData; public function __construct( protected Manager $taskProcessingManager, @@ -76,7 +78,7 @@ class Cleanup extends Base { foreach ($textToImageDeletedFileNames as $entry) { $output->writeln("\t - " . 'Deleted appData/core/text2image/' . $entry . ''); } - } catch (\OCP\Files\NotFoundException $e) { + } catch (NotFoundException $e) { // noop } try { @@ -84,7 +86,7 @@ class Cleanup extends Base { foreach ($audioToTextDeletedFileNames as $entry) { $output->writeln("\t - " . 'Deleted appData/core/audio2text/' . $entry . ''); } - } catch (\OCP\Files\NotFoundException $e) { + } catch (NotFoundException $e) { // noop } diff --git a/tests/lib/Avatar/GuestAvatarTest.php b/tests/lib/Avatar/GuestAvatarTest.php index b49fcea6ed2..ba14d571e27 100644 --- a/tests/lib/Avatar/GuestAvatarTest.php +++ b/tests/lib/Avatar/GuestAvatarTest.php @@ -11,6 +11,7 @@ namespace Test\Avatar; use OC\Avatar\GuestAvatar; use OCP\Files\SimpleFS\InMemoryFile; +use OCP\IConfig; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; use Test\TestCase; @@ -35,7 +36,7 @@ class GuestAvatarTest extends TestCase { public function setupGuestAvatar() { /* @var MockObject|LoggerInterface $logger */ $logger = $this->createMock(LoggerInterface::class); - $config = $this->createMock(\OCP\IConfig::class); + $config = $this->createMock(IConfig::class); $this->guestAvatar = new GuestAvatar('einstein', $config, $logger); } diff --git a/tests/lib/Files/Cache/FileAccessTest.php b/tests/lib/Files/Cache/FileAccessTest.php index 59fa2494ea8..63577ea874c 100644 --- a/tests/lib/Files/Cache/FileAccessTest.php +++ b/tests/lib/Files/Cache/FileAccessTest.php @@ -9,8 +9,13 @@ namespace Test\Files\Cache; use OC\Files\Cache\CacheEntry; use OC\Files\Cache\FileAccess; +use OC\Files\Mount\LocalHomeMountProvider; +use OC\FilesMetadata\FilesMetadataManager; +use OC\SystemConfig; use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\Files\IMimeTypeLoader; use OCP\IDBConnection; +use OCP\Server; use Psr\Log\LoggerInterface; use Test\TestCase; @@ -25,15 +30,15 @@ class FileAccessTest extends TestCase { parent::setUp(); // Setup the actual database connection (assume the database is configured properly in PHPUnit setup) - $this->dbConnection = \OCP\Server::get(IDBConnection::class); + $this->dbConnection = Server::get(IDBConnection::class); // Ensure FileAccess is instantiated with the real connection $this->fileAccess = new FileAccess( $this->dbConnection, - \OCP\Server::get(\OC\SystemConfig::class), - \OCP\Server::get(LoggerInterface::class), - \OCP\Server::get(\OC\FilesMetadata\FilesMetadataManager::class), - \OCP\Server::get(\OCP\Files\IMimeTypeLoader::class) + Server::get(SystemConfig::class), + Server::get(LoggerInterface::class), + Server::get(FilesMetadataManager::class), + Server::get(IMimeTypeLoader::class) ); // Clear and prepare `filecache` table for tests @@ -142,7 +147,7 @@ class FileAccessTest extends TestCase { ->values([ 'storage_id' => $queryBuilder->createNamedParameter(4, IQueryBuilder::PARAM_INT), 'root_id' => $queryBuilder->createNamedParameter(40, IQueryBuilder::PARAM_INT), - 'mount_provider_class' => $queryBuilder->createNamedParameter(\OC\Files\Mount\LocalHomeMountProvider::class), + 'mount_provider_class' => $queryBuilder->createNamedParameter(LocalHomeMountProvider::class), 'mount_point' => $queryBuilder->createNamedParameter('/home/user'), 'user_id' => $queryBuilder->createNamedParameter('test'), ]) diff --git a/tests/lib/Files/ObjectStore/PrimaryObjectStoreConfigTest.php b/tests/lib/Files/ObjectStore/PrimaryObjectStoreConfigTest.php index b60b7ca4f83..6015040f199 100644 --- a/tests/lib/Files/ObjectStore/PrimaryObjectStoreConfigTest.php +++ b/tests/lib/Files/ObjectStore/PrimaryObjectStoreConfigTest.php @@ -46,7 +46,7 @@ class PrimaryObjectStoreConfigTest extends TestCase { } }); $this->config->method('setUserValue') - ->willReturnCallback(function ($userId, $appName, $key, $value) { + ->willReturnCallback(function ($userId, $appName, $key, $value): void { $this->userConfig[$userId][$appName][$key] = $value; });