From ed5b7ae16150cb4fa67563288396a729b5654005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 30 Jan 2025 16:56:48 +0100 Subject: [PATCH] chore: re-apply current rector configuration to apps folder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/dav/lib/Connector/Sabre/Auth.php | 3 +- apps/dav/lib/Connector/Sabre/FilesPlugin.php | 3 +- .../unit/CardDAV/ImageExportPluginTest.php | 3 +- apps/files_external/lib/Lib/Storage/SFTP.php | 2 +- .../lib/Controller/ShareAPIController.php | 10 +- .../Controller/ShareAPIControllerTest.php | 117 +++++++++--------- .../lib/Controller/ProfilePageController.php | 3 +- .../lib/Controller/AppSettingsController.php | 3 +- .../tests/Settings/Admin/SharingTest.php | 4 +- .../UserMigration/AccountMigratorTest.php | 3 +- .../Version2006Date20240905111627Test.php | 13 +- 11 files changed, 86 insertions(+), 78 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php index 66c41262d54..1d509d0d6f2 100644 --- a/apps/dav/lib/Connector/Sabre/Auth.php +++ b/apps/dav/lib/Connector/Sabre/Auth.php @@ -19,6 +19,7 @@ use OCP\IRequest; use OCP\ISession; use OCP\Security\Bruteforce\IThrottler; use OCP\Security\Bruteforce\MaxDelayReached; +use OCP\Server; use Psr\Log\LoggerInterface; use Sabre\DAV\Auth\Backend\AbstractBasic; use Sabre\DAV\Exception\NotAuthenticated; @@ -108,7 +109,7 @@ class Auth extends AbstractBasic { } catch (Exception $e) { $class = get_class($e); $msg = $e->getMessage(); - \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]); + Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]); throw new ServiceUnavailable("$class: $msg"); } } diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index a879e264459..dff71cbfaaf 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -10,6 +10,7 @@ namespace OCA\DAV\Connector\Sabre; use OC\AppFramework\Http\Request; use OC\FilesMetadata\Model\FilesMetadata; use OCA\DAV\Connector\Sabre\Exception\InvalidPath; +use OCA\Files_Sharing\External\Mount as SharingExternalMount; use OCP\Constants; use OCP\Files\ForbiddenException; use OCP\Files\IFilenameValidator; @@ -424,7 +425,7 @@ class FilesPlugin extends ServerPlugin { $propFind->handle(self::IS_FEDERATED_PROPERTYNAME, function () use ($node) { return $node->getFileInfo()->getMountPoint() - instanceof \OCA\Files_Sharing\External\Mount; + instanceof SharingExternalMount; }); } diff --git a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php index cf6ddb1ff7b..d5c864d3e4e 100644 --- a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php +++ b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php @@ -10,6 +10,7 @@ namespace OCA\DAV\Tests\unit\CardDAV; use OCA\DAV\CardDAV\AddressBook; use OCA\DAV\CardDAV\ImageExportPlugin; use OCA\DAV\CardDAV\PhotoCache; +use OCP\AppFramework\Http; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use Sabre\CardDAV\Card; @@ -171,7 +172,7 @@ class ImageExportPluginTest extends TestCase { ->willThrowException(new NotFoundException()); $this->response->expects($this->once()) ->method('setStatus') - ->with(\OCP\AppFramework\Http::STATUS_NO_CONTENT); + ->with(Http::STATUS_NO_CONTENT); } $result = $this->plugin->httpGet($this->request, $this->response); diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php index aebc61806fc..9907acdc469 100644 --- a/apps/files_external/lib/Lib/Storage/SFTP.php +++ b/apps/files_external/lib/Lib/Storage/SFTP.php @@ -327,7 +327,7 @@ class SFTP extends Common { $context = stream_context_create(['sftp' => ['session' => $connection]]); $fh = fopen('sftpwrite://' . trim($absPath, '/'), 'w', false, $context); if ($fh) { - $fh = CallbackWrapper::wrap($fh, null, null, function () use ($path) { + $fh = CallbackWrapper::wrap($fh, null, null, function () use ($path): void { $this->knownMTimes->set($path, time()); }); } diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 2e21f90943f..6cacc12828e 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -471,7 +471,7 @@ class ShareAPIController extends OCSController { $share = $this->formatShare($share); if ($include_tags) { - $share = Helper::populateTags([$share], \OCP\Server::get(ITagManager::class)); + $share = Helper::populateTags([$share], Server::get(ITagManager::class)); } else { $share = [$share]; } @@ -754,7 +754,7 @@ class ShareAPIController extends OCSController { $share->setSharedWith($shareWith); $share->setPermissions($permissions); } elseif ($shareType === IShare::TYPE_CIRCLE) { - if (!\OCP\Server::get(IAppManager::class)->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) { + if (!Server::get(IAppManager::class)->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) { throw new OCSNotFoundException($this->l->t('You cannot share to a Team if the app is not enabled')); } @@ -842,7 +842,7 @@ class ShareAPIController extends OCSController { } if ($includeTags) { - $formatted = Helper::populateTags($formatted, \OCP\Server::get(ITagManager::class)); + $formatted = Helper::populateTags($formatted, Server::get(ITagManager::class)); } return $formatted; @@ -1096,7 +1096,7 @@ class ShareAPIController extends OCSController { if ($includeTags) { $formatted = - Helper::populateTags($formatted, \OCP\Server::get(ITagManager::class)); + Helper::populateTags($formatted, Server::get(ITagManager::class)); } return $formatted; @@ -1971,7 +1971,7 @@ class ShareAPIController extends OCSController { return true; } - if ($share->getShareType() === IShare::TYPE_CIRCLE && \OCP\Server::get(IAppManager::class)->isEnabledForUser('circles') + if ($share->getShareType() === IShare::TYPE_CIRCLE && Server::get(IAppManager::class)->isEnabledForUser('circles') && class_exists('\OCA\Circles\Api\v1\Circles')) { $hasCircleId = (str_ends_with($share->getSharedWith(), ']')); $shareWithStart = ($hasCircleId ? strrpos($share->getSharedWith(), '[') + 1 : 0); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index ac788dd6b28..29eae2dc581 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -34,6 +34,7 @@ use OCP\IUserManager; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; use OCP\Mail\IMailer; +use OCP\Server; use OCP\Share\Exceptions\GenericShareException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IAttributes as IShareAttributes; @@ -162,7 +163,7 @@ class ShareAPIControllerTest extends TestCase { } private function newShare() { - return \OCP\Server::get(IManager::class)->newShare(); + return Server::get(IManager::class)->newShare(); } @@ -911,7 +912,7 @@ class ShareAPIControllerTest extends TestCase { $this->expectException(OCSNotFoundException::class); $this->expectExceptionMessage('Wrong share ID, share does not exist'); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setSharedBy('initiator') ->setSharedWith('recipient') ->setShareOwner('owner'); @@ -942,7 +943,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getDirectoryListing') ->willReturn([$file1, $file2]); - $file1UserShareOwner = \OCP\Server::get(IManager::class)->newShare(); + $file1UserShareOwner = Server::get(IManager::class)->newShare(); $file1UserShareOwner->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -956,7 +957,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_USER, ]; - $file1UserShareInitiator = \OCP\Server::get(IManager::class)->newShare(); + $file1UserShareInitiator = Server::get(IManager::class)->newShare(); $file1UserShareInitiator->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('currentUser') @@ -970,7 +971,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_USER, ]; - $file1UserShareRecipient = \OCP\Server::get(IManager::class)->newShare(); + $file1UserShareRecipient = Server::get(IManager::class)->newShare(); $file1UserShareRecipient->setShareType(IShare::TYPE_USER) ->setSharedWith('currentUser') ->setSharedBy('initiator') @@ -984,7 +985,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_USER, ]; - $file1UserShareOther = \OCP\Server::get(IManager::class)->newShare(); + $file1UserShareOther = Server::get(IManager::class)->newShare(); $file1UserShareOther->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -998,7 +999,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_USER, ]; - $file1GroupShareOwner = \OCP\Server::get(IManager::class)->newShare(); + $file1GroupShareOwner = Server::get(IManager::class)->newShare(); $file1GroupShareOwner->setShareType(IShare::TYPE_GROUP) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -1012,7 +1013,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_GROUP, ]; - $file1GroupShareRecipient = \OCP\Server::get(IManager::class)->newShare(); + $file1GroupShareRecipient = Server::get(IManager::class)->newShare(); $file1GroupShareRecipient->setShareType(IShare::TYPE_GROUP) ->setSharedWith('currentUserGroup') ->setSharedBy('initiator') @@ -1026,7 +1027,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_GROUP, ]; - $file1GroupShareOther = \OCP\Server::get(IManager::class)->newShare(); + $file1GroupShareOther = Server::get(IManager::class)->newShare(); $file1GroupShareOther->setShareType(IShare::TYPE_GROUP) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -1035,7 +1036,7 @@ class ShareAPIControllerTest extends TestCase { ->setNode($file1) ->setId(108); - $file1LinkShareOwner = \OCP\Server::get(IManager::class)->newShare(); + $file1LinkShareOwner = Server::get(IManager::class)->newShare(); $file1LinkShareOwner->setShareType(IShare::TYPE_LINK) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -1049,7 +1050,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_LINK, ]; - $file1EmailShareOwner = \OCP\Server::get(IManager::class)->newShare(); + $file1EmailShareOwner = Server::get(IManager::class)->newShare(); $file1EmailShareOwner->setShareType(IShare::TYPE_EMAIL) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -1063,7 +1064,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_EMAIL, ]; - $file1CircleShareOwner = \OCP\Server::get(IManager::class)->newShare(); + $file1CircleShareOwner = Server::get(IManager::class)->newShare(); $file1CircleShareOwner->setShareType(IShare::TYPE_CIRCLE) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -1077,7 +1078,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_CIRCLE, ]; - $file1RoomShareOwner = \OCP\Server::get(IManager::class)->newShare(); + $file1RoomShareOwner = Server::get(IManager::class)->newShare(); $file1RoomShareOwner->setShareType(IShare::TYPE_ROOM) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -1091,7 +1092,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_ROOM, ]; - $file1RemoteShareOwner = \OCP\Server::get(IManager::class)->newShare(); + $file1RemoteShareOwner = Server::get(IManager::class)->newShare(); $file1RemoteShareOwner->setShareType(IShare::TYPE_REMOTE) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -1106,7 +1107,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_REMOTE, ]; - $file1RemoteGroupShareOwner = \OCP\Server::get(IManager::class)->newShare(); + $file1RemoteGroupShareOwner = Server::get(IManager::class)->newShare(); $file1RemoteGroupShareOwner->setShareType(IShare::TYPE_REMOTE_GROUP) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -1121,7 +1122,7 @@ class ShareAPIControllerTest extends TestCase { 'share_type' => IShare::TYPE_REMOTE_GROUP, ]; - $file2UserShareOwner = \OCP\Server::get(IManager::class)->newShare(); + $file2UserShareOwner = Server::get(IManager::class)->newShare(); $file2UserShareOwner->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -2020,7 +2021,7 @@ class ShareAPIControllerTest extends TestCase { $this->rootFolder->method('getById') ->willReturn([]); - $this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare()); + $this->shareManager->method('newShare')->willReturn(Server::get(IManager::class)->newShare()); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); $this->shareManager->method('shareApiAllowLinks')->willReturn(false); @@ -2046,7 +2047,7 @@ class ShareAPIControllerTest extends TestCase { $this->rootFolder->method('getById') ->willReturn([]); - $this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare()); + $this->shareManager->method('newShare')->willReturn(Server::get(IManager::class)->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true'); @@ -2073,7 +2074,7 @@ class ShareAPIControllerTest extends TestCase { $this->rootFolder->method('getById') ->willReturn([]); - $this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare()); + $this->shareManager->method('newShare')->willReturn(Server::get(IManager::class)->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -2097,7 +2098,7 @@ class ShareAPIControllerTest extends TestCase { $this->rootFolder->method('getById') ->willReturn([]); - $this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare()); + $this->shareManager->method('newShare')->willReturn(Server::get(IManager::class)->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -2136,7 +2137,7 @@ class ShareAPIControllerTest extends TestCase { $this->rootFolder->method('getById') ->willReturn([]); - $this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare()); + $this->shareManager->method('newShare')->willReturn(Server::get(IManager::class)->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -2175,7 +2176,7 @@ class ShareAPIControllerTest extends TestCase { $this->rootFolder->method('getById') ->willReturn([]); - $this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare()); + $this->shareManager->method('newShare')->willReturn(Server::get(IManager::class)->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -2222,7 +2223,7 @@ class ShareAPIControllerTest extends TestCase { $this->rootFolder->method('getById') ->willReturn([]); - $this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare()); + $this->shareManager->method('newShare')->willReturn(Server::get(IManager::class)->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -2260,7 +2261,7 @@ class ShareAPIControllerTest extends TestCase { $this->rootFolder->method('getById') ->willReturn([]); - $this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare()); + $this->shareManager->method('newShare')->willReturn(Server::get(IManager::class)->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -2306,7 +2307,7 @@ class ShareAPIControllerTest extends TestCase { $this->rootFolder->method('getById') ->willReturn([]); - $this->shareManager->method('newShare')->willReturn(\OCP\Server::get(IManager::class)->newShare()); + $this->shareManager->method('newShare')->willReturn(Server::get(IManager::class)->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -2615,7 +2616,7 @@ class ShareAPIControllerTest extends TestCase { * TODO: Remove once proper solution is in place */ public function testCreateReshareOfFederatedMountNoDeletePermissions(): void { - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $this->shareManager->method('newShare')->willReturn($share); /** @var ShareAPIController&MockObject $ocs */ @@ -2820,7 +2821,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getId') ->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setPermissions(Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) ->setShareType(IShare::TYPE_LINK) @@ -2877,7 +2878,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getId') ->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setPermissions(Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) ->setShareType(IShare::TYPE_LINK) @@ -2938,7 +2939,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getId') ->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setPermissions(Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) ->setShareType(IShare::TYPE_LINK) @@ -3026,7 +3027,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getId') ->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setPermissions(Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) ->setShareType(IShare::TYPE_LINK) @@ -3072,7 +3073,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getId')->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setPermissions(Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) ->setShareType(IShare::TYPE_LINK) @@ -3102,7 +3103,7 @@ class ShareAPIControllerTest extends TestCase { ->with($this->currentUser) ->willReturn($userFolder); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setPermissions(Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) ->setShareType(IShare::TYPE_LINK) @@ -3468,7 +3469,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getId') ->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setPermissions(Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) ->setShareType(IShare::TYPE_LINK) @@ -3529,7 +3530,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getId') ->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setPermissions(Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) ->setShareType(IShare::TYPE_LINK) @@ -3589,7 +3590,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getId') ->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setPermissions(Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) ->setShareType(IShare::TYPE_LINK) @@ -3649,7 +3650,7 @@ class ShareAPIControllerTest extends TestCase { $file->method('getId') ->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setPermissions(Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) ->setShareType(IShare::TYPE_USER) @@ -3695,7 +3696,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getId') ->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share ->setId(42) ->setSharedBy($this->currentUser) @@ -3707,7 +3708,7 @@ class ShareAPIControllerTest extends TestCase { // note: updateShare will modify the received instance but getSharedWith will reread from the database, // so their values will be different - $incomingShare = \OCP\Server::get(IManager::class)->newShare(); + $incomingShare = Server::get(IManager::class)->newShare(); $incomingShare ->setId(42) ->setSharedBy($this->currentUser) @@ -3770,7 +3771,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getId') ->willReturn(42); - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share ->setId(42) ->setSharedBy($this->currentUser) @@ -3782,7 +3783,7 @@ class ShareAPIControllerTest extends TestCase { // note: updateShare will modify the received instance but getSharedWith will reread from the database, // so their values will be different - $incomingShare = \OCP\Server::get(IManager::class)->newShare(); + $incomingShare = Server::get(IManager::class)->newShare(); $incomingShare ->setId(42) ->setSharedBy($this->currentUser) @@ -3945,7 +3946,7 @@ class ShareAPIControllerTest extends TestCase { $result = []; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -4047,7 +4048,7 @@ class ShareAPIControllerTest extends TestCase { ], false ]; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -4101,7 +4102,7 @@ class ShareAPIControllerTest extends TestCase { ], $share, [], false ]; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -4157,7 +4158,7 @@ class ShareAPIControllerTest extends TestCase { // with existing group - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_GROUP) ->setSharedWith('recipientGroup') ->setSharedBy('initiator') @@ -4211,7 +4212,7 @@ class ShareAPIControllerTest extends TestCase { ]; // with unknown group / no group backend - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_GROUP) ->setSharedWith('recipientGroup2') ->setSharedBy('initiator') @@ -4262,7 +4263,7 @@ class ShareAPIControllerTest extends TestCase { ], $share, [], false ]; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_LINK) ->setSharedBy('initiator') ->setShareOwner('owner') @@ -4321,7 +4322,7 @@ class ShareAPIControllerTest extends TestCase { ], $share, [], false ]; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_LINK) ->setSharedBy('initiator') ->setShareOwner('owner') @@ -4380,7 +4381,7 @@ class ShareAPIControllerTest extends TestCase { ], $share, [], false ]; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_REMOTE) ->setSharedBy('initiator') ->setSharedWith('user@server.com') @@ -4433,7 +4434,7 @@ class ShareAPIControllerTest extends TestCase { ], $share, [], false ]; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_REMOTE_GROUP) ->setSharedBy('initiator') ->setSharedWith('user@server.com') @@ -4487,7 +4488,7 @@ class ShareAPIControllerTest extends TestCase { ]; // Circle with id, display name and avatar set by the Circles app - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_CIRCLE) ->setSharedBy('initiator') ->setSharedWith('Circle (Public circle, circleOwner) [4815162342]') @@ -4543,7 +4544,7 @@ class ShareAPIControllerTest extends TestCase { ]; // Circle with id set by the Circles app - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_CIRCLE) ->setSharedBy('initiator') ->setSharedWith('Circle (Public circle, circleOwner) [4815162342]') @@ -4596,7 +4597,7 @@ class ShareAPIControllerTest extends TestCase { ]; // Circle with id not set by the Circles app - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_CIRCLE) ->setSharedBy('initiator') ->setSharedWith('Circle (Public circle, circleOwner)') @@ -4648,7 +4649,7 @@ class ShareAPIControllerTest extends TestCase { ], $share, [], false ]; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_USER) ->setSharedBy('initiator') ->setSharedWith('recipient') @@ -4663,7 +4664,7 @@ class ShareAPIControllerTest extends TestCase { [], $share, [], true ]; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_EMAIL) ->setSharedBy('initiator') ->setSharedWith('user@server.com') @@ -4718,7 +4719,7 @@ class ShareAPIControllerTest extends TestCase { ], $share, [], false ]; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_EMAIL) ->setSharedBy('initiator') ->setSharedWith('user@server.com') @@ -4775,7 +4776,7 @@ class ShareAPIControllerTest extends TestCase { ]; // Preview is available - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') @@ -4941,7 +4942,7 @@ class ShareAPIControllerTest extends TestCase { $result = []; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_ROOM) ->setSharedWith('recipientRoom') ->setSharedBy('initiator') @@ -4993,7 +4994,7 @@ class ShareAPIControllerTest extends TestCase { ], $share, false, [] ]; - $share = \OCP\Server::get(IManager::class)->newShare(); + $share = Server::get(IManager::class)->newShare(); $share->setShareType(IShare::TYPE_ROOM) ->setSharedWith('recipientRoom') ->setSharedBy('initiator') diff --git a/apps/profile/lib/Controller/ProfilePageController.php b/apps/profile/lib/Controller/ProfilePageController.php index 96a052b0bbf..0a5ec251e38 100644 --- a/apps/profile/lib/Controller/ProfilePageController.php +++ b/apps/profile/lib/Controller/ProfilePageController.php @@ -28,6 +28,7 @@ use OCP\Profile\BeforeTemplateRenderedEvent; use OCP\Profile\IProfileManager; use OCP\Share\IManager as IShareManager; use OCP\UserStatus\IManager as IUserStatusManager; +use OCP\Util; #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)] class ProfilePageController extends Controller { @@ -103,7 +104,7 @@ class ProfilePageController extends Controller { $this->eventDispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($targetUserId)); - \OCP\Util::addScript('profile', 'main'); + Util::addScript('profile', 'main'); return new TemplateResponse( 'profile', diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php index 24207d98543..3e17a490d09 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -15,6 +15,7 @@ use OC\App\AppStore\Version\VersionParser; use OC\App\DependencyAnalyzer; use OC\App\Platform; use OC\Installer; +use OCA\AppAPI\Service\ExAppsPageService; use OCP\App\AppPathNotFoundException; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; @@ -94,7 +95,7 @@ class AppSettingsController extends Controller { if ($this->appManager->isEnabledForAnyone('app_api')) { try { - Server::get(\OCA\AppAPI\Service\ExAppsPageService::class)->provideAppApiState($this->initialState); + Server::get(ExAppsPageService::class)->provideAppApiState($this->initialState); } catch (\Psr\Container\NotFoundExceptionInterface|\Psr\Container\ContainerExceptionInterface $e) { } } diff --git a/apps/settings/tests/Settings/Admin/SharingTest.php b/apps/settings/tests/Settings/Admin/SharingTest.php index 5fcc153b6dd..048634be1e0 100644 --- a/apps/settings/tests/Settings/Admin/SharingTest.php +++ b/apps/settings/tests/Settings/Admin/SharingTest.php @@ -101,7 +101,7 @@ class SharingTest extends TestCase { $this->initialState ->expects($this->exactly(3)) ->method('provideInitialState') - ->willReturnCallback(function (string $key) use (&$initialStateCalls) { + ->willReturnCallback(function (string $key) use (&$initialStateCalls): void { $initialStateCalls[$key] = func_get_args(); }); @@ -198,7 +198,7 @@ class SharingTest extends TestCase { $this->initialState ->expects($this->exactly(3)) ->method('provideInitialState') - ->willReturnCallback(function (string $key) use (&$initialStateCalls) { + ->willReturnCallback(function (string $key) use (&$initialStateCalls): void { $initialStateCalls[$key] = func_get_args(); }); diff --git a/apps/settings/tests/UserMigration/AccountMigratorTest.php b/apps/settings/tests/UserMigration/AccountMigratorTest.php index f3f3e2bf90f..cd3fd2f7aeb 100644 --- a/apps/settings/tests/UserMigration/AccountMigratorTest.php +++ b/apps/settings/tests/UserMigration/AccountMigratorTest.php @@ -14,6 +14,7 @@ use OCP\AppFramework\App; use OCP\IAvatarManager; use OCP\IConfig; use OCP\IUserManager; +use OCP\Server; use OCP\UserMigration\IExportDestination; use OCP\UserMigration\IImportSource; use PHPUnit\Framework\Constraint\JsonMatches; @@ -67,7 +68,7 @@ class AccountMigratorTest extends TestCase { } protected function tearDown(): void { - \OCP\Server::get(IConfig::class)->setSystemValue('has_internet_connection', true); + Server::get(IConfig::class)->setSystemValue('has_internet_connection', true); parent::tearDown(); } diff --git a/apps/theming/tests/Migration/Version2006Date20240905111627Test.php b/apps/theming/tests/Migration/Version2006Date20240905111627Test.php index bdd27d08e7f..c4bcb75b364 100644 --- a/apps/theming/tests/Migration/Version2006Date20240905111627Test.php +++ b/apps/theming/tests/Migration/Version2006Date20240905111627Test.php @@ -16,6 +16,7 @@ use OCP\IAppConfig; use OCP\IDBConnection; use OCP\IUserManager; use OCP\Migration\IOutput; +use OCP\Server; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -88,11 +89,11 @@ class Version2006Date20240905111627Test extends TestCase { ->willReturn(false); // Create a user - $manager = \OCP\Server::get(IUserManager::class); + $manager = Server::get(IUserManager::class); $user = $manager->createUser('theming_legacy', 'theming_legacy'); self::assertNotFalse($user); // Set the users theming value to legacy key - $config = \OCP\Server::get(IUserConfig::class); + $config = Server::get(IUserConfig::class); $config->setValueString('theming_legacy', 'theming', 'background_color', 'ffab00'); // expect some output @@ -109,7 +110,7 @@ class Version2006Date20240905111627Test extends TestCase { $migration = new Version2006Date20240905111627( $this->jobList, $this->appConfig, - \OCP\Server::get(IDBConnection::class), + Server::get(IDBConnection::class), ); // Run the migration $migration->changeSchema($output, fn () => null, []); @@ -138,13 +139,13 @@ class Version2006Date20240905111627Test extends TestCase { ->willReturn(false); // Create a user - $manager = \OCP\Server::get(IUserManager::class); + $manager = Server::get(IUserManager::class); $legacyUser = $manager->createUser('theming_legacy', 'theming_legacy'); self::assertNotFalse($legacyUser); $user = $manager->createUser('theming_no_legacy', 'theming_no_legacy'); self::assertNotFalse($user); // Set the users theming value to legacy key - $config = \OCP\Server::get(IUserConfig::class); + $config = Server::get(IUserConfig::class); $config->setValueString($user->getUID(), 'theming', 'primary_color', '999999'); $config->setValueString($user->getUID(), 'theming', 'background_color', '111111'); $config->setValueString($legacyUser->getUID(), 'theming', 'background_color', 'ffab00'); @@ -163,7 +164,7 @@ class Version2006Date20240905111627Test extends TestCase { $migration = new Version2006Date20240905111627( $this->jobList, $this->appConfig, - \OCP\Server::get(IDBConnection::class), + Server::get(IDBConnection::class), ); // Run the migration $migration->changeSchema($output, fn () => null, []);