From 641c4b8c0d675edc43989008cbacf95b7fb547c7 Mon Sep 17 00:00:00 2001 From: nextcloud-command Date: Sun, 9 Aug 2026 14:47:11 +0000 Subject: [PATCH] refactor: Apply rector changes Signed-off-by: GitHub --- .../lib/Controller/PublicPreviewController.php | 3 ++- apps/files_trashbin/lib/Sabre/TrashbinPlugin.php | 1 - lib/private/Avatar/RemoteAvatar.php | 5 +++-- lib/private/Server.php | 3 ++- lib/private/User/Manager.php | 2 +- tests/lib/FilesMetadata/FilesMetadataManagerTest.php | 12 +++++++----- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/apps/files_sharing/lib/Controller/PublicPreviewController.php b/apps/files_sharing/lib/Controller/PublicPreviewController.php index d0495bb43ee43..233dc87a0ecfe 100644 --- a/apps/files_sharing/lib/Controller/PublicPreviewController.php +++ b/apps/files_sharing/lib/Controller/PublicPreviewController.php @@ -17,6 +17,7 @@ use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\PublicShareController; use OCP\Constants; +use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\NotFoundException; use OCP\IPreview; @@ -136,7 +137,7 @@ public function getPreview( return $response; } catch (NotFoundException $e) { // If we have no preview enabled, we can redirect to the mime icon if any - if ($file instanceof \OCP\Files\File && $mimeFallback) { + if ($file instanceof File && $mimeFallback) { if ($url = $this->mimeIconProvider->getMimeIconUrl($file->getMimeType())) { return new RedirectResponse($url); } diff --git a/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php b/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php index 274d73eb7d1d3..56d3548b6233c 100644 --- a/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php +++ b/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php @@ -10,7 +10,6 @@ namespace OCA\Files_Trashbin\Sabre; use OC\Files\FileInfo; -use OC\Files\View; use OCA\DAV\Connector\Sabre\FilesPlugin; use OCA\Files_Trashbin\Trash\ITrashItem; use OCP\Files\IRootFolder; diff --git a/lib/private/Avatar/RemoteAvatar.php b/lib/private/Avatar/RemoteAvatar.php index 6813fe2d58672..6295d54ed9567 100644 --- a/lib/private/Avatar/RemoteAvatar.php +++ b/lib/private/Avatar/RemoteAvatar.php @@ -15,6 +15,7 @@ use OCP\Files\SimpleFS\ISimpleFolder; use OCP\Http\Client\IClientService; use OCP\IConfig; +use OCP\Server; use Psr\Log\LoggerInterface; class RemoteAvatar extends Avatar { @@ -30,7 +31,7 @@ public function __construct( ) { parent::__construct($config, $logger); - $cloudIdManager = \OCP\Server::get(ICloudIdManager::class); + $cloudIdManager = Server::get(ICloudIdManager::class); $this->cloudId = $cloudIdManager->resolveCloudId($userId); } @@ -88,7 +89,7 @@ public function getFile(int $size, bool $darkTheme = false): ISimpleFile { $url .= '/dark'; } - $clientService = \OCP\Server::get(IClientService::class); + $clientService = Server::get(IClientService::class); $client = $clientService->newClient(); $response = $client->get($url, [ 'verify' => !$this->config->getSystemValueBool('sharing.federation.allowSelfSignedCertificates', false) diff --git a/lib/private/Server.php b/lib/private/Server.php index 71d5b0b9fc0e0..3ef76ee74547f 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -134,6 +134,7 @@ use OC\Share20\ProviderFactory; use OC\Share20\PublicShareTemplateFactory; use OC\Share20\ShareHelper; +use OC\Sharing\SharingBackend; use OC\Sharing\SharingManager; use OC\Sharing\SharingRegistry; use OC\Snowflake\APCuSequence; @@ -1156,7 +1157,7 @@ function () use ($c) { $this->registerAlias(\NCU\Sharing\ISharingRegistry::class, SharingRegistry::class); $this->registerAlias(\NCU\Sharing\ISharingManager::class, SharingManager::class); - $this->registerAlias(\NCU\Sharing\ISharingBackend::class, \OC\Sharing\SharingBackend::class); + $this->registerAlias(\NCU\Sharing\ISharingBackend::class, SharingBackend::class); $this->connectDispatcher(); } diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index f69c8de7eaa52..cd30b63199fa3 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -124,7 +124,7 @@ public function clearBackends(): void { * @param list $excludeBackends A list of IUserBackend::getBackendName() that need to be excluded from the search. */ #[\Override] - public function get($uid, array $excludeBackends = []): ?\OCP\IUser { + public function get($uid, array $excludeBackends = []): ?IUser { if (is_null($uid) || $uid === '' || $uid === false) { return null; } diff --git a/tests/lib/FilesMetadata/FilesMetadataManagerTest.php b/tests/lib/FilesMetadata/FilesMetadataManagerTest.php index 03fc9de22b006..31bf2f0f9852c 100644 --- a/tests/lib/FilesMetadata/FilesMetadataManagerTest.php +++ b/tests/lib/FilesMetadata/FilesMetadataManagerTest.php @@ -13,6 +13,8 @@ use OC\FilesMetadata\FilesMetadataManager; use OC\FilesMetadata\Service\IndexRequestService; use OC\FilesMetadata\Service\MetadataRequestService; +use OCP\DB\QueryBuilder\IExpressionBuilder; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Folder; @@ -97,8 +99,8 @@ public function testRefreshMetadata(): void { public function testDropMetadataForFilesChunking(): void { $connection = $this->createMock(IDBConnection::class); - $qb = $this->createMock(\OCP\DB\QueryBuilder\IQueryBuilder::class); - $expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + $qb = $this->createMock(IQueryBuilder::class); + $expr = $this->createMock(IExpressionBuilder::class); $connection->method('getQueryBuilder')->willReturn($qb); $qb->method('expr')->willReturn($expr); @@ -106,14 +108,14 @@ public function testDropMetadataForFilesChunking(): void { $qb->method('where')->willReturnSelf(); $qb->method('hintShardKey')->willReturnSelf(); - $fileIds = range(1, \OCP\DB\QueryBuilder\IQueryBuilder::MAX_IN_PARAMETERS * 2 + 1); - $expectedChunks = array_chunk($fileIds, \OCP\DB\QueryBuilder\IQueryBuilder::MAX_IN_PARAMETERS); + $fileIds = range(1, IQueryBuilder::MAX_IN_PARAMETERS * 2 + 1); + $expectedChunks = array_chunk($fileIds, IQueryBuilder::MAX_IN_PARAMETERS); $boundChunks = []; $qb->expects($this->exactly(count($expectedChunks))) ->method('createNamedParameter') ->willReturnCallback(function (array $chunk, $type) use (&$boundChunks): string { - $this->assertSame(\OCP\DB\QueryBuilder\IQueryBuilder::PARAM_INT_ARRAY, $type); + $this->assertSame(IQueryBuilder::PARAM_INT_ARRAY, $type); $boundChunks[] = $chunk; return ':param'; });