diff --git a/apps/admin_audit/lib/Actions/Files.php b/apps/admin_audit/lib/Actions/Files.php
index 86eba871ea7cd..1923bdac2c1dd 100644
--- a/apps/admin_audit/lib/Actions/Files.php
+++ b/apps/admin_audit/lib/Actions/Files.php
@@ -18,6 +18,7 @@
use OCP\Files\Events\Node\NodeWrittenEvent;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
+use OCP\Server;
use Psr\Log\LoggerInterface;
/**
@@ -41,7 +42,7 @@ public function read(BeforeNodeReadEvent $event): void {
'path' => mb_substr($node->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Exception thrown in file read: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);
return;
@@ -63,7 +64,7 @@ public function beforeRename(BeforeNodeRenamedEvent $event): void {
$source = $event->getSource();
$this->renamedNodes[$source->getId()] = $source;
} catch (InvalidPathException|NotFoundException $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Exception thrown in file rename: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);
return;
@@ -85,7 +86,7 @@ public function afterRename(NodeRenamedEvent $event): void {
'newpath' => mb_substr($target->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Exception thrown in file rename: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);
return;
@@ -111,7 +112,7 @@ public function create(NodeCreatedEvent $event): void {
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Exception thrown in file create: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);
return;
@@ -140,7 +141,7 @@ public function copy(NodeCopiedEvent $event): void {
'newpath' => mb_substr($event->getTarget()->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Exception thrown in file copy: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);
return;
@@ -165,7 +166,7 @@ public function write(BeforeNodeWrittenEvent $event): void {
'path' => mb_substr($node->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Exception thrown in file write: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);
return;
@@ -193,7 +194,7 @@ public function update(NodeWrittenEvent $event): void {
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Exception thrown in file update: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);
return;
@@ -217,7 +218,7 @@ public function delete(NodeDeletedEvent $event): void {
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Exception thrown in file delete: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);
return;
diff --git a/apps/admin_audit/lib/AppInfo/Application.php b/apps/admin_audit/lib/AppInfo/Application.php
index b6cee3c0a938a..bde893a062755 100644
--- a/apps/admin_audit/lib/AppInfo/Application.php
+++ b/apps/admin_audit/lib/AppInfo/Application.php
@@ -57,6 +57,7 @@
use OCP\Share;
use OCP\Share\Events\ShareCreatedEvent;
use OCP\Share\Events\ShareDeletedEvent;
+use OCP\SystemTag\ManagerEvent;
use OCP\User\Events\BeforeUserLoggedInEvent;
use OCP\User\Events\BeforeUserLoggedOutEvent;
use OCP\User\Events\PasswordUpdatedEvent;
@@ -157,7 +158,7 @@ private function sharingLegacyHooks(IAuditLogger $logger): void {
private function tagHooks(IAuditLogger $logger,
IEventDispatcher $eventDispatcher): void {
- $eventDispatcher->addListener(\OCP\SystemTag\ManagerEvent::EVENT_CREATE, function (\OCP\SystemTag\ManagerEvent $event) use ($logger): void {
+ $eventDispatcher->addListener(ManagerEvent::EVENT_CREATE, function (ManagerEvent $event) use ($logger): void {
$tagActions = new TagManagement($logger);
$tagActions->createTag($event->getTag());
});
diff --git a/apps/admin_audit/lib/Listener/FileEventListener.php b/apps/admin_audit/lib/Listener/FileEventListener.php
index 369f97239d7fa..4ea3db6aa7d3f 100644
--- a/apps/admin_audit/lib/Listener/FileEventListener.php
+++ b/apps/admin_audit/lib/Listener/FileEventListener.php
@@ -15,6 +15,7 @@
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\Preview\BeforePreviewFetchedEvent;
+use OCP\Server;
use Psr\Log\LoggerInterface;
/**
@@ -47,7 +48,7 @@ private function beforePreviewFetched(BeforePreviewFetchedEvent $event): void {
array_keys($params)
);
} catch (InvalidPathException|NotFoundException $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Exception thrown in file preview: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
);
return;
diff --git a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php
index 733f02434cd14..4cd668c29a063 100644
--- a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php
+++ b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php
@@ -27,6 +27,7 @@
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\Share\Exceptions\ShareNotFound;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
@@ -276,7 +277,7 @@ public function receiveNotification($notificationType, $resourceType, $providerI
private function mapUid($uid) {
// FIXME this should be a method in the user management instead
$this->logger->debug('shareWith before, ' . $uid, ['app' => $this->appName]);
- \OCP\Util::emitHook(
+ Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$uid]
diff --git a/apps/comments/tests/Unit/Notification/ListenerTest.php b/apps/comments/tests/Unit/Notification/ListenerTest.php
index 4cdb5f93b158e..97730f9e8cf8c 100644
--- a/apps/comments/tests/Unit/Notification/ListenerTest.php
+++ b/apps/comments/tests/Unit/Notification/ListenerTest.php
@@ -32,8 +32,8 @@ class ListenerTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->notificationManager = $this->createMock(\OCP\Notification\IManager::class);
- $this->userManager = $this->createMock(\OCP\IUserManager::class);
+ $this->notificationManager = $this->createMock(IManager::class);
+ $this->userManager = $this->createMock(IUserManager::class);
$this->listener = new Listener(
$this->notificationManager,
diff --git a/apps/dashboard/lib/Controller/DashboardController.php b/apps/dashboard/lib/Controller/DashboardController.php
index 69ddceadf17d8..959129cdfa365 100644
--- a/apps/dashboard/lib/Controller/DashboardController.php
+++ b/apps/dashboard/lib/Controller/DashboardController.php
@@ -10,11 +10,11 @@
use OCA\Dashboard\Service\DashboardService;
use OCP\AppFramework\Controller;
-use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
+use OCP\AppFramework\Http\FeaturePolicy;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\Dashboard\IIconWidget;
@@ -24,6 +24,7 @@
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
+use OCP\Util;
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
class DashboardController extends Controller {
@@ -49,8 +50,8 @@ public function __construct(
#[NoAdminRequired]
#[FrontpageRoute(verb: 'GET', url: '/')]
public function index(): TemplateResponse {
- \OCP\Util::addStyle('dashboard', 'dashboard');
- \OCP\Util::addScript('dashboard', 'main', 'theming');
+ Util::addStyle('dashboard', 'dashboard');
+ Util::addScript('dashboard', 'main', 'theming');
$widgets = array_map(function (IWidget $widget) {
return [
@@ -76,7 +77,7 @@ public function index(): TemplateResponse {
]);
// For the weather widget we should allow the geolocation
- $featurePolicy = new Http\FeaturePolicy();
+ $featurePolicy = new FeaturePolicy();
$featurePolicy->addAllowedGeoLocationDomain('\'self\'');
$response->setFeaturePolicy($featurePolicy);
diff --git a/apps/dav/appinfo/v1/caldav.php b/apps/dav/appinfo/v1/caldav.php
index bfa4d6184d51f..c84162e3f4e12 100644
--- a/apps/dav/appinfo/v1/caldav.php
+++ b/apps/dav/appinfo/v1/caldav.php
@@ -10,7 +10,11 @@
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\CalendarRoot;
use OCA\DAV\CalDAV\DefaultCalendarValidator;
+use OCA\DAV\CalDAV\Proxy\ProxyMapper;
+use OCA\DAV\CalDAV\Schedule\IMipPlugin;
+use OCA\DAV\CalDAV\Schedule\Plugin;
use OCA\DAV\CalDAV\Security\RateLimitingPlugin;
+use OCA\DAV\CalDAV\Sharing\Backend;
use OCA\DAV\CalDAV\Validation\CalDavValidatePlugin;
use OCA\DAV\Connector\LegacyDAVACL;
use OCA\DAV\Connector\Sabre\Auth;
@@ -18,6 +22,9 @@
use OCA\DAV\Connector\Sabre\MaintenancePlugin;
use OCA\DAV\Connector\Sabre\Principal;
use OCP\Accounts\IAccountManager;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\IConfig;
+use OCP\Server;
use Psr\Log\LoggerInterface;
$authBackend = new Auth(
@@ -35,7 +42,7 @@
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
\OC::$server->getAppManager(),
- \OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class),
+ \OC::$server->query(ProxyMapper::class),
\OC::$server->get(KnownUserService::class),
\OC::$server->getConfig(),
\OC::$server->getL10NFactory(),
@@ -45,8 +52,8 @@
$userManager = \OC::$server->getUserManager();
$random = \OC::$server->getSecureRandom();
$logger = \OC::$server->get(LoggerInterface::class);
-$dispatcher = \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class);
-$config = \OC::$server->get(\OCP\IConfig::class);
+$dispatcher = \OC::$server->get(IEventDispatcher::class);
+$config = \OC::$server->get(IConfig::class);
$calDavBackend = new CalDavBackend(
$db,
@@ -56,7 +63,7 @@
$logger,
$dispatcher,
$config,
- OC::$server->get(\OCA\DAV\CalDAV\Sharing\Backend::class),
+ OC::$server->get(Backend::class),
true
);
@@ -93,14 +100,14 @@
$server->addPlugin(new \Sabre\DAV\Sync\Plugin());
$server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
-$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DefaultCalendarValidator::class)));
+$server->addPlugin(new Plugin(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DefaultCalendarValidator::class)));
if ($sendInvitations) {
- $server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
+ $server->addPlugin(\OC::$server->query(IMipPlugin::class));
}
$server->addPlugin(new ExceptionLoggerPlugin('caldav', $logger));
-$server->addPlugin(\OCP\Server::get(RateLimitingPlugin::class));
-$server->addPlugin(\OCP\Server::get(CalDavValidatePlugin::class));
+$server->addPlugin(Server::get(RateLimitingPlugin::class));
+$server->addPlugin(Server::get(CalDavValidatePlugin::class));
// And off we go!
$server->exec();
diff --git a/apps/dav/appinfo/v1/carddav.php b/apps/dav/appinfo/v1/carddav.php
index 72be4712705c4..9164982813b4e 100644
--- a/apps/dav/appinfo/v1/carddav.php
+++ b/apps/dav/appinfo/v1/carddav.php
@@ -8,9 +8,13 @@
// Backends
use OC\KnownUser\KnownUserService;
use OCA\DAV\AppInfo\PluginManager;
+use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCA\DAV\CardDAV\AddressBookRoot;
use OCA\DAV\CardDAV\CardDavBackend;
+use OCA\DAV\CardDAV\ImageExportPlugin;
+use OCA\DAV\CardDAV\PhotoCache;
use OCA\DAV\CardDAV\Security\CardDavRateLimitingPlugin;
+use OCA\DAV\CardDAV\Sharing\Backend;
use OCA\DAV\CardDAV\Validation\CardDavValidatePlugin;
use OCA\DAV\Connector\LegacyDAVACL;
use OCA\DAV\Connector\Sabre\Auth;
@@ -19,6 +23,9 @@
use OCA\DAV\Connector\Sabre\Principal;
use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\IGroupManager;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Sabre\CardDAV\Plugin;
@@ -37,7 +44,7 @@
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
\OC::$server->getAppManager(),
- \OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class),
+ \OC::$server->query(ProxyMapper::class),
\OC::$server->get(KnownUserService::class),
\OC::$server->getConfig(),
\OC::$server->getL10NFactory(),
@@ -48,8 +55,8 @@
$db,
$principalBackend,
\OC::$server->getUserManager(),
- \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class),
- \OC::$server->get(\OCA\DAV\CardDAV\Sharing\Backend::class),
+ \OC::$server->get(IEventDispatcher::class),
+ \OC::$server->get(Backend::class),
);
$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);
@@ -59,7 +66,7 @@
$principalCollection->disableListing = !$debugging; // Disable listing
$pluginManager = new PluginManager(\OC::$server, \OC::$server->query(IAppManager::class));
-$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, $pluginManager, \OC::$server->getUserSession()->getUser(), \OC::$server->get(\OCP\IGroupManager::class));
+$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, $pluginManager, \OC::$server->getUserSession()->getUser(), \OC::$server->get(IGroupManager::class));
$addressBookRoot->disableListing = !$debugging; // Disable listing
$nodes = [
@@ -84,13 +91,13 @@
$server->addPlugin(new \Sabre\DAV\Sync\Plugin());
$server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
-$server->addPlugin(new \OCA\DAV\CardDAV\ImageExportPlugin(new \OCA\DAV\CardDAV\PhotoCache(
+$server->addPlugin(new ImageExportPlugin(new PhotoCache(
\OC::$server->getAppDataDir('dav-photocache'),
\OC::$server->get(LoggerInterface::class)
)));
$server->addPlugin(new ExceptionLoggerPlugin('carddav', \OC::$server->get(LoggerInterface::class)));
-$server->addPlugin(\OCP\Server::get(CardDavRateLimitingPlugin::class));
-$server->addPlugin(\OCP\Server::get(CardDavValidatePlugin::class));
+$server->addPlugin(Server::get(CardDavRateLimitingPlugin::class));
+$server->addPlugin(Server::get(CardDavValidatePlugin::class));
// And off we go!
$server->exec();
diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php
index 3875337415004..dc74fe214afbb 100644
--- a/apps/dav/appinfo/v1/publicwebdav.php
+++ b/apps/dav/appinfo/v1/publicwebdav.php
@@ -5,9 +5,20 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
-
+use OC\Files\Filesystem;
+use OC\Files\Storage\Wrapper\PermissionsMask;
+use OC\Files\View;
+use OCA\DAV\Connector\LegacyPublicAuth;
+use OCA\DAV\Connector\Sabre\ServerFactory;
+use OCA\DAV\Files\Sharing\FilesDropPlugin;
+use OCA\DAV\Files\Sharing\PublicLinkCheckPlugin;
+use OCA\DAV\Storage\PublicOwnerWrapper;
+use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\BeforeSabrePubliclyLoadedEvent;
+use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\IRootFolder;
+use OCP\Server;
use Psr\Log\LoggerInterface;
// load needed apps
@@ -19,7 +30,7 @@
\OC::$server->getSession()->close();
// Backends
-$authBackend = new OCA\DAV\Connector\LegacyPublicAuth(
+$authBackend = new LegacyPublicAuth(
\OC::$server->getRequest(),
\OC::$server->getShareManager(),
\OC::$server->getSession(),
@@ -30,7 +41,7 @@
/** @var IEventDispatcher $eventDispatcher */
$eventDispatcher = \OC::$server->get(IEventDispatcher::class);
-$serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory(
+$serverFactory = new ServerFactory(
\OC::$server->getConfig(),
\OC::$server->get(LoggerInterface::class),
\OC::$server->getDatabaseConnection(),
@@ -45,13 +56,13 @@
$requestUri = \OC::$server->getRequest()->getRequestUri();
-$linkCheckPlugin = new \OCA\DAV\Files\Sharing\PublicLinkCheckPlugin();
-$filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin();
+$linkCheckPlugin = new PublicLinkCheckPlugin();
+$filesDropPlugin = new FilesDropPlugin();
$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
$isAjax = in_array('XMLHttpRequest', explode(',', $_SERVER['HTTP_X_REQUESTED_WITH'] ?? ''));
- /** @var \OCA\FederatedFileSharing\FederatedShareProvider $shareProvider */
- $federatedShareProvider = \OC::$server->query(\OCA\FederatedFileSharing\FederatedShareProvider::class);
+ /** @var FederatedShareProvider $shareProvider */
+ $federatedShareProvider = \OC::$server->query(FederatedShareProvider::class);
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
// this is what is thrown when trying to access a non-existing share
throw new \Sabre\DAV\Exception\NotAuthenticated();
@@ -59,20 +70,20 @@
$share = $authBackend->getShare();
$owner = $share->getShareOwner();
- $isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ;
+ $isReadable = $share->getPermissions() & Constants::PERMISSION_READ;
$fileId = $share->getNodeId();
// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
- $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
- \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
- return new \OC\Files\Storage\Wrapper\PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE]);
+ $previousLog = Filesystem::logWarningWhenAddingStorageWrapper(false);
+ Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
+ return new PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | Constants::PERMISSION_SHARE]);
});
- \OC\Files\Filesystem::addStorageWrapper('shareOwner', function ($mountPoint, $storage) use ($share) {
- return new \OCA\DAV\Storage\PublicOwnerWrapper(['storage' => $storage, 'owner' => $share->getShareOwner()]);
+ Filesystem::addStorageWrapper('shareOwner', function ($mountPoint, $storage) use ($share) {
+ return new PublicOwnerWrapper(['storage' => $storage, 'owner' => $share->getShareOwner()]);
});
- \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
+ Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
- $rootFolder = \OCP\Server::get(\OCP\Files\IRootFolder::class);
+ $rootFolder = Server::get(IRootFolder::class);
$userFolder = $rootFolder->getUserFolder($owner);
$node = $userFolder->getFirstNodeById($fileId);
if (!$node) {
@@ -85,7 +96,7 @@
$filesDropPlugin->enable();
}
- $view = new \OC\Files\View($node->getPath());
+ $view = new View($node->getPath());
$filesDropPlugin->setView($view);
$filesDropPlugin->setShare($share);
diff --git a/apps/dav/appinfo/v1/webdav.php b/apps/dav/appinfo/v1/webdav.php
index 1683c29ca80f5..0faed7ccc947f 100644
--- a/apps/dav/appinfo/v1/webdav.php
+++ b/apps/dav/appinfo/v1/webdav.php
@@ -5,6 +5,13 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
+use OC\Files\Filesystem;
+use OCA\DAV\Connector\Sabre\Auth;
+use OCA\DAV\Connector\Sabre\BearerAuth;
+use OCA\DAV\Connector\Sabre\ServerFactory;
+use OCA\DAV\Events\SabrePluginAddEvent;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\SabrePluginEvent;
use Psr\Log\LoggerInterface;
// no php execution timeout for webdav
@@ -16,9 +23,9 @@
// Turn off output buffering to prevent memory problems
\OC_Util::obEnd();
-$dispatcher = \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class);
+$dispatcher = \OC::$server->get(IEventDispatcher::class);
-$serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory(
+$serverFactory = new ServerFactory(
\OC::$server->getConfig(),
\OC::$server->get(LoggerInterface::class),
\OC::$server->getDatabaseConnection(),
@@ -32,7 +39,7 @@
);
// Backends
-$authBackend = new \OCA\DAV\Connector\Sabre\Auth(
+$authBackend = new Auth(
\OC::$server->getSession(),
\OC::$server->getUserSession(),
\OC::$server->getRequest(),
@@ -41,7 +48,7 @@
'principals/'
);
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
-$bearerAuthPlugin = new \OCA\DAV\Connector\Sabre\BearerAuth(
+$bearerAuthPlugin = new BearerAuth(
\OC::$server->getUserSession(),
\OC::$server->getSession(),
\OC::$server->getRequest()
@@ -52,13 +59,13 @@
$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () {
// use the view for the logged in user
- return \OC\Files\Filesystem::getView();
+ return Filesystem::getView();
});
// allow setup of additional plugins
-$event = new \OCP\SabrePluginEvent($server);
+$event = new SabrePluginEvent($server);
$dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
-$event = new \OCA\DAV\Events\SabrePluginAddEvent($server);
+$event = new SabrePluginAddEvent($server);
$dispatcher->dispatchTyped($event);
// And off we go!
diff --git a/apps/dav/appinfo/v2/direct.php b/apps/dav/appinfo/v2/direct.php
index 46443a60f8a87..5ba9570602acb 100644
--- a/apps/dav/appinfo/v2/direct.php
+++ b/apps/dav/appinfo/v2/direct.php
@@ -6,7 +6,9 @@
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+use OCA\DAV\Db\DirectMapper;
use OCA\DAV\Direct\ServerFactory;
+use OCP\AppFramework\Utility\ITimeFactory;
// no php execution timeout for webdav
if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) {
@@ -25,8 +27,8 @@
$baseuri,
$requestUri,
\OC::$server->getRootFolder(),
- \OC::$server->query(\OCA\DAV\Db\DirectMapper::class),
- \OC::$server->query(\OCP\AppFramework\Utility\ITimeFactory::class),
+ \OC::$server->query(DirectMapper::class),
+ \OC::$server->query(ITimeFactory::class),
\OC::$server->getBruteForceThrottler(),
\OC::$server->getRequest()
);
diff --git a/apps/dav/appinfo/v2/publicremote.php b/apps/dav/appinfo/v2/publicremote.php
index 53e85d556eb9f..96f1b42e50198 100644
--- a/apps/dav/appinfo/v2/publicremote.php
+++ b/apps/dav/appinfo/v2/publicremote.php
@@ -5,14 +5,19 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
-
use OC\Files\Filesystem;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OC\Files\View;
+use OCA\DAV\Connector\Sabre\PublicAuth;
+use OCA\DAV\Connector\Sabre\ServerFactory;
+use OCA\DAV\Files\Sharing\FilesDropPlugin;
+use OCA\DAV\Files\Sharing\PublicLinkCheckPlugin;
use OCA\DAV\Storage\PublicOwnerWrapper;
use OCA\DAV\Storage\PublicShareWrapper;
use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -23,6 +28,7 @@
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Security\Bruteforce\IThrottler;
+use OCP\Server;
use OCP\Share\IManager;
use Psr\Log\LoggerInterface;
use Sabre\DAV\Exception\NotAuthenticated;
@@ -33,39 +39,39 @@
OC_App::loadApps($RUNTIME_APPTYPES);
OC_Util::obEnd();
-$session = \OCP\Server::get(ISession::class);
-$request = \OCP\Server::get(IRequest::class);
+$session = Server::get(ISession::class);
+$request = Server::get(IRequest::class);
$session->close();
$requestUri = $request->getRequestUri();
// Backends
-$authBackend = new OCA\DAV\Connector\Sabre\PublicAuth(
+$authBackend = new PublicAuth(
$request,
- \OCP\Server::get(IManager::class),
+ Server::get(IManager::class),
$session,
- \OCP\Server::get(IThrottler::class),
- \OCP\Server::get(LoggerInterface::class)
+ Server::get(IThrottler::class),
+ Server::get(LoggerInterface::class)
);
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
-$l10nFactory = \OCP\Server::get(IFactory::class);
-$serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory(
- \OCP\Server::get(IConfig::class),
- \OCP\Server::get(LoggerInterface::class),
- \OCP\Server::get(IDBConnection::class),
- \OCP\Server::get(IUserSession::class),
- \OCP\Server::get(IMountManager::class),
- \OCP\Server::get(ITagManager::class),
+$l10nFactory = Server::get(IFactory::class);
+$serverFactory = new ServerFactory(
+ Server::get(IConfig::class),
+ Server::get(LoggerInterface::class),
+ Server::get(IDBConnection::class),
+ Server::get(IUserSession::class),
+ Server::get(IMountManager::class),
+ Server::get(ITagManager::class),
$request,
- \OCP\Server::get(IPreview::class),
- \OCP\Server::get(IEventDispatcher::class),
+ Server::get(IPreview::class),
+ Server::get(IEventDispatcher::class),
$l10nFactory->get('dav'),
);
-$linkCheckPlugin = new \OCA\DAV\Files\Sharing\PublicLinkCheckPlugin();
-$filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin();
+$linkCheckPlugin = new PublicLinkCheckPlugin();
+$filesDropPlugin = new FilesDropPlugin();
// Define root url with /public.php/dav/files/TOKEN
/** @var string $baseuri defined in public.php */
@@ -74,7 +80,7 @@
$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
$isAjax = in_array('XMLHttpRequest', explode(',', $_SERVER['HTTP_X_REQUESTED_WITH'] ?? ''));
- $federatedShareProvider = \OCP\Server::get(FederatedShareProvider::class);
+ $federatedShareProvider = Server::get(FederatedShareProvider::class);
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
// this is what is thrown when trying to access a non-existing share
throw new NotAuthenticated();
@@ -82,7 +88,7 @@
$share = $authBackend->getShare();
$owner = $share->getShareOwner();
- $isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ;
+ $isReadable = $share->getPermissions() & Constants::PERMISSION_READ;
$fileId = $share->getNodeId();
// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
@@ -91,7 +97,7 @@
/** @psalm-suppress MissingClosureParamType */
Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
- return new PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE]);
+ return new PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | Constants::PERMISSION_SHARE]);
});
/** @psalm-suppress MissingClosureParamType */
@@ -108,7 +114,7 @@
/** @psalm-suppress InternalMethod */
Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
- $rootFolder = \OCP\Server::get(\OCP\Files\IRootFolder::class);
+ $rootFolder = Server::get(IRootFolder::class);
$userFolder = $rootFolder->getUserFolder($owner);
$node = $userFolder->getFirstNodeById($fileId);
if (!$node) {
diff --git a/apps/dav/appinfo/v2/remote.php b/apps/dav/appinfo/v2/remote.php
index 73031c0794fd0..28cfe338a9361 100644
--- a/apps/dav/appinfo/v2/remote.php
+++ b/apps/dav/appinfo/v2/remote.php
@@ -1,5 +1,7 @@
getRequest();
-$server = new \OCA\DAV\Server($request, $baseuri);
+$server = new Server($request, $baseuri);
$server->exec();
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php
index fb6a195aedb34..2325a3c3ba8f2 100644
--- a/apps/dav/lib/AppInfo/Application.php
+++ b/apps/dav/lib/AppInfo/Application.php
@@ -19,8 +19,8 @@
use OCA\DAV\CalDAV\Reminder\NotificationProvider\PushProvider;
use OCA\DAV\CalDAV\Reminder\NotificationProviderManager;
use OCA\DAV\CalDAV\Reminder\Notifier;
-
use OCA\DAV\Capabilities;
+
use OCA\DAV\CardDAV\ContactsManager;
use OCA\DAV\CardDAV\PhotoCache;
use OCA\DAV\CardDAV\SyncService;
@@ -85,6 +85,7 @@
use OCP\Federation\Events\TrustedServerRemovedEvent;
use OCP\Files\AppData\IAppDataFactory;
use OCP\IUser;
+use OCP\Server;
use OCP\User\Events\OutOfOfficeChangedEvent;
use OCP\User\Events\OutOfOfficeClearedEvent;
use OCP\User\Events\OutOfOfficeScheduledEvent;
@@ -222,7 +223,7 @@ public function registerHooks(HookManager $hm,
$dispatcher->addListener(UserUpdatedEvent::class, function (UserUpdatedEvent $event) use ($container): void {
/** @var SyncService $syncService */
- $syncService = \OCP\Server::get(SyncService::class);
+ $syncService = Server::get(SyncService::class);
$syncService->updateUser($event->getUser());
});
diff --git a/apps/dav/lib/BackgroundJob/EventReminderJob.php b/apps/dav/lib/BackgroundJob/EventReminderJob.php
index 5025919c84ffe..894b347de9f89 100644
--- a/apps/dav/lib/BackgroundJob/EventReminderJob.php
+++ b/apps/dav/lib/BackgroundJob/EventReminderJob.php
@@ -8,6 +8,8 @@
*/
namespace OCA\DAV\BackgroundJob;
+use OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException;
+use OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException;
use OCA\DAV\CalDAV\Reminder\ReminderService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
@@ -34,8 +36,8 @@ public function __construct(ITimeFactory $time,
}
/**
- * @throws \OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException
- * @throws \OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException
+ * @throws ProviderNotAvailableException
+ * @throws NotificationTypeDoesNotExistException
* @throws \OC\User\NoUserException
*/
public function run($argument):void {
diff --git a/apps/dav/lib/BackgroundJob/OutOfOfficeEventDispatcherJob.php b/apps/dav/lib/BackgroundJob/OutOfOfficeEventDispatcherJob.php
index cc4fd5dce9dea..c7705aebc43ab 100644
--- a/apps/dav/lib/BackgroundJob/OutOfOfficeEventDispatcherJob.php
+++ b/apps/dav/lib/BackgroundJob/OutOfOfficeEventDispatcherJob.php
@@ -14,6 +14,7 @@
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\QueuedJob;
+use OCP\DB\Exception;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUserManager;
use OCP\User\Events\OutOfOfficeEndedEvent;
@@ -41,7 +42,7 @@ public function run($argument): void {
try {
$absence = $this->absenceMapper->findById($id);
- } catch (DoesNotExistException|\OCP\DB\Exception $e) {
+ } catch (DoesNotExistException|Exception $e) {
$this->logger->error('Failed to dispatch out-of-office event: ' . $e->getMessage(), [
'exception' => $e,
'argument' => $argument,
diff --git a/apps/dav/lib/CalDAV/AppCalendar/AppCalendarPlugin.php b/apps/dav/lib/CalDAV/AppCalendar/AppCalendarPlugin.php
index 56e91c581f835..3e058a9b6c19b 100644
--- a/apps/dav/lib/CalDAV/AppCalendar/AppCalendarPlugin.php
+++ b/apps/dav/lib/CalDAV/AppCalendar/AppCalendarPlugin.php
@@ -9,6 +9,8 @@
namespace OCA\DAV\CalDAV\AppCalendar;
+use OCA\DAV\CalDAV\CachedSubscriptionImpl;
+use OCA\DAV\CalDAV\CalendarImpl;
use OCA\DAV\CalDAV\Integration\ExternalCalendar;
use OCA\DAV\CalDAV\Integration\ICalendarProvider;
use OCP\Calendar\IManager;
@@ -51,7 +53,7 @@ protected function getWrappedCalendars(string $principalUri, array $calendarUris
return array_values(
array_filter($this->manager->getCalendarsForPrincipal($principalUri, $calendarUris), function ($c) {
// We must not provide a wrapper for DAV calendars
- return ! (($c instanceof \OCA\DAV\CalDAV\CalendarImpl) || ($c instanceof \OCA\DAV\CalDAV\CachedSubscriptionImpl));
+ return ! (($c instanceof CalendarImpl) || ($c instanceof CachedSubscriptionImpl));
})
);
}
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index 101bf36617aab..6517a8d244684 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -189,7 +189,7 @@ public function __construct(
private LoggerInterface $logger,
private IEventDispatcher $dispatcher,
private IConfig $config,
- private Sharing\Backend $calendarSharingBackend,
+ private Backend $calendarSharingBackend,
private bool $legacyEndpoint = false,
) {
}
@@ -3117,7 +3117,7 @@ public function preloadShares(array $resourceIds): void {
/**
* @param boolean $value
- * @param \OCA\DAV\CalDAV\Calendar $calendar
+ * @param Calendar $calendar
* @return string|null
*/
public function setPublishStatus($value, $calendar) {
@@ -3152,7 +3152,7 @@ public function setPublishStatus($value, $calendar) {
}
/**
- * @param \OCA\DAV\CalDAV\Calendar $calendar
+ * @param Calendar $calendar
* @return mixed
*/
public function getPublishStatus($calendar) {
diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php
index ea2ac0e9a62ac..b70cb0d0aeb44 100644
--- a/apps/dav/lib/CalDAV/CalendarImpl.php
+++ b/apps/dav/lib/CalDAV/CalendarImpl.php
@@ -10,6 +10,7 @@
use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin;
use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer;
+use OCA\DAV\CalDAV\Schedule\Plugin;
use OCP\Calendar\Exceptions\CalendarException;
use OCP\Calendar\ICreateFromString;
use OCP\Calendar\IHandleImipMessage;
@@ -70,11 +71,11 @@ public function getDisplayColor(): ?string {
}
public function getSchedulingTransparency(): ?ScheduleCalendarTransp {
- return $this->calendarInfo['{' . \OCA\DAV\CalDAV\Schedule\Plugin::NS_CALDAV . '}schedule-calendar-transp'];
+ return $this->calendarInfo['{' . Plugin::NS_CALDAV . '}schedule-calendar-transp'];
}
public function getSchedulingTimezone(): ?VTimeZone {
- $tzProp = '{' . \OCA\DAV\CalDAV\Schedule\Plugin::NS_CALDAV . '}calendar-timezone';
+ $tzProp = '{' . Plugin::NS_CALDAV . '}calendar-timezone';
if (!isset($this->calendarInfo[$tzProp])) {
return null;
}
diff --git a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php
index 6fa94eebc91ea..c17e428d50a0f 100644
--- a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php
+++ b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php
@@ -9,15 +9,21 @@
use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin;
use OCA\DAV\CalDAV\Auth\PublicPrincipalPlugin;
use OCA\DAV\CalDAV\DefaultCalendarValidator;
+use OCA\DAV\CalDAV\Plugin;
+use OCA\DAV\CalDAV\Publishing\PublishPlugin;
use OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin;
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
use OCA\DAV\Connector\Sabre\CachingTree;
use OCA\DAV\Connector\Sabre\DavAclPlugin;
+use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
+use OCA\DAV\Connector\Sabre\LockPlugin;
+use OCA\DAV\Connector\Sabre\MaintenancePlugin;
use OCA\DAV\Events\SabrePluginAuthInitEvent;
use OCA\DAV\RootCollection;
use OCA\Theming\ThemingDefaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Sabre\VObject\ITip\Message;
@@ -30,22 +36,22 @@ class InvitationResponseServer {
*/
public function __construct(bool $public = true) {
$baseUri = \OC::$WEBROOT . '/remote.php/dav/';
- $logger = \OCP\Server::get(LoggerInterface::class);
- $dispatcher = \OCP\Server::get(IEventDispatcher::class);
+ $logger = Server::get(LoggerInterface::class);
+ $dispatcher = Server::get(IEventDispatcher::class);
$root = new RootCollection();
$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
// Add maintenance plugin
- $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
+ $this->server->addPlugin(new MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
// Set URL explicitly due to reverse-proxy situations
$this->server->httpRequest->setUrl($baseUri);
$this->server->setBaseUri($baseUri);
$this->server->addPlugin(new BlockLegacyClientPlugin(
- \OCP\Server::get(IConfig::class),
- \OCP\Server::get(ThemingDefaults::class),
+ Server::get(IConfig::class),
+ Server::get(ThemingDefaults::class),
));
$this->server->addPlugin(new AnonymousOptionsPlugin());
@@ -60,8 +66,8 @@ public function __construct(bool $public = true) {
$event = new SabrePluginAuthInitEvent($this->server);
$dispatcher->dispatchTyped($event);
- $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
- $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
+ $this->server->addPlugin(new ExceptionLoggerPlugin('webdav', $logger));
+ $this->server->addPlugin(new LockPlugin());
$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
// acl
@@ -72,13 +78,13 @@ public function __construct(bool $public = true) {
$this->server->addPlugin($acl);
// calendar plugins
- $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
+ $this->server->addPlugin(new Plugin());
$this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
$this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DefaultCalendarValidator::class)));
$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
//$this->server->addPlugin(new \OCA\DAV\DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
- $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
+ $this->server->addPlugin(new PublishPlugin(
\OC::$server->getConfig(),
\OC::$server->getURLGenerator()
));
diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php
index 59f412c0a7bea..b33b9c61834a2 100644
--- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php
+++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php
@@ -17,6 +17,7 @@
use OCP\Mail\Headers\AutoSubmitted;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
+use OCP\Util;
use Psr\Log\LoggerInterface;
use Sabre\VObject;
use Sabre\VObject\Component\VEvent;
@@ -87,7 +88,7 @@ public function send(VEvent $vevent,
$lang = $fallbackLanguage;
}
$l10n = $this->getL10NForLang($lang);
- $fromEMail = \OCP\Util::getDefaultEmailAddress('reminders-noreply');
+ $fromEMail = Util::getDefaultEmailAddress('reminders-noreply');
$template = $this->mailer->createEMailTemplate('dav.calendarReminder');
$template->addHeader();
diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php b/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php
index f64de85c4493f..21f4f5094d474 100644
--- a/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php
+++ b/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php
@@ -8,6 +8,8 @@
*/
namespace OCA\DAV\CalDAV\Reminder;
+use OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException;
+
/**
* Class NotificationProviderManager
*
@@ -42,7 +44,7 @@ public function getProvider(string $type):INotificationProvider {
if (isset($this->providers[$type])) {
return $this->providers[$type];
}
- throw new NotificationProvider\ProviderNotAvailableException($type);
+ throw new ProviderNotAvailableException($type);
}
throw new NotificationTypeDoesNotExistException($type);
}
diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
index e46cd039fd5ee..beca5cff233d9 100644
--- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
+++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
@@ -15,6 +15,8 @@
use OCP\IConfig;
use OCP\IUserSession;
use OCP\Mail\IMailer;
+use OCP\Mail\Provider\Address;
+use OCP\Mail\Provider\Attachment;
use OCP\Mail\Provider\IManager as IMailManager;
use OCP\Mail\Provider\IMessageSend;
use OCP\Util;
@@ -277,15 +279,15 @@ public function schedule(Message $iTipMessage) {
// construct mail message and set required parameters
$message = $mailService->initiateMessage();
$message->setFrom(
- (new \OCP\Mail\Provider\Address($sender, $fromName))
+ (new Address($sender, $fromName))
);
$message->setTo(
- (new \OCP\Mail\Provider\Address($recipient, $recipientName))
+ (new Address($recipient, $recipientName))
);
$message->setSubject($template->renderSubject());
$message->setBodyPlain($template->renderText());
$message->setBodyHtml($template->renderHtml());
- $message->setAttachments((new \OCP\Mail\Provider\Attachment(
+ $message->setAttachments((new Attachment(
$itip_msg,
'event.ics',
'text/calendar; method=' . $iTipMessage->method,
diff --git a/apps/dav/lib/CalDAV/Schedule/Plugin.php b/apps/dav/lib/CalDAV/Schedule/Plugin.php
index 48f4cbf22ef0a..11f0dfbe25170 100644
--- a/apps/dav/lib/CalDAV/Schedule/Plugin.php
+++ b/apps/dav/lib/CalDAV/Schedule/Plugin.php
@@ -9,6 +9,7 @@
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Calendar;
use OCA\DAV\CalDAV\CalendarHome;
+use OCA\DAV\CalDAV\CalendarObject;
use OCA\DAV\CalDAV\DefaultCalendarValidator;
use OCP\IConfig;
use Psr\Log\LoggerInterface;
@@ -163,7 +164,7 @@ public function calendarObjectChange(RequestInterface $request, ResponseInterfac
return;
}
- /** @var \OCA\DAV\CalDAV\Calendar $calendarNode */
+ /** @var Calendar $calendarNode */
$calendarNode = $this->server->tree->getNodeForPath($calendarPath);
// extract addresses for owner
$addresses = $this->getAddressesForPrincipal($calendarNode->getOwner());
@@ -178,7 +179,7 @@ public function calendarObjectChange(RequestInterface $request, ResponseInterfac
// determine if we are updating a calendar event
if (!$isNew) {
// retrieve current calendar event node
- /** @var \OCA\DAV\CalDAV\CalendarObject $currentNode */
+ /** @var CalendarObject $currentNode */
$currentNode = $this->server->tree->getNodeForPath($request->getPath());
// convert calendar event string data to VCalendar object
/** @var \Sabre\VObject\Component\VCalendar $currentObject */
@@ -561,7 +562,7 @@ private function isAvailableAtTime(string $email, \DateTimeInterface $start, \Da
$calendarTimeZone = new DateTimeZone('UTC');
$homePath = $result[0][200]['{' . self::NS_CALDAV . '}calendar-home-set']->getHref();
- /** @var \OCA\DAV\CalDAV\Calendar $node */
+ /** @var Calendar $node */
foreach ($this->server->tree->getNodeForPath($homePath)->getChildren() as $node) {
if (!$node instanceof ICalendar) {
diff --git a/apps/dav/lib/CalDAV/Search/SearchPlugin.php b/apps/dav/lib/CalDAV/Search/SearchPlugin.php
index fb55dec593c86..c69537523f299 100644
--- a/apps/dav/lib/CalDAV/Search/SearchPlugin.php
+++ b/apps/dav/lib/CalDAV/Search/SearchPlugin.php
@@ -108,7 +108,7 @@ public function getSupportedReportSet($uri) {
* This report is used by clients to request calendar objects based on
* complex conditions.
*
- * @param Xml\Request\CalendarSearchReport $report
+ * @param CalendarSearchReport $report
* @return void
*/
private function calendarSearch($report) {
diff --git a/apps/dav/lib/CalDAV/Trashbin/TrashbinHome.php b/apps/dav/lib/CalDAV/Trashbin/TrashbinHome.php
index a1958bb27942c..ad761020272fd 100644
--- a/apps/dav/lib/CalDAV/Trashbin/TrashbinHome.php
+++ b/apps/dav/lib/CalDAV/Trashbin/TrashbinHome.php
@@ -9,6 +9,7 @@
namespace OCA\DAV\CalDAV\Trashbin;
use OCA\DAV\CalDAV\CalDavBackend;
+use OCA\DAV\DAV\Sharing\Plugin;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\ICollection;
@@ -105,7 +106,7 @@ public function getProperties($properties): array {
return [
'{DAV:}resourcetype' => new ResourceType([
'{DAV:}collection',
- sprintf('{%s}trash-bin', \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD),
+ sprintf('{%s}trash-bin', Plugin::NS_NEXTCLOUD),
]),
];
}
diff --git a/apps/dav/lib/CardDAV/ContactsManager.php b/apps/dav/lib/CardDAV/ContactsManager.php
index 30af37481ab75..899396ddc1729 100644
--- a/apps/dav/lib/CardDAV/ContactsManager.php
+++ b/apps/dav/lib/CardDAV/ContactsManager.php
@@ -56,7 +56,7 @@ public function setupSystemContactsProvider(IManager $cm, IURLGenerator $urlGene
*/
private function register(IManager $cm, $addressBooks, $urlGenerator) {
foreach ($addressBooks as $addressBookInfo) {
- $addressBook = new \OCA\DAV\CardDAV\AddressBook($this->backend, $addressBookInfo, $this->l10n);
+ $addressBook = new AddressBook($this->backend, $addressBookInfo, $this->l10n);
$cm->registerAddressBook(
new AddressBookImpl(
$addressBook,
diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php
index 00989386df767..0fb5592142ed2 100644
--- a/apps/dav/lib/CardDAV/PhotoCache.php
+++ b/apps/dav/lib/CardDAV/PhotoCache.php
@@ -10,6 +10,7 @@
use OCP\Files\NotPermittedException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
+use OCP\Image;
use Psr\Log\LoggerInterface;
use Sabre\CardDAV\Card;
use Sabre\VObject\Document;
@@ -109,7 +110,7 @@ private function getFile(ISimpleFolder $folder, $size): ISimpleFile {
throw new NotFoundException;
}
- $photo = new \OCP\Image();
+ $photo = new Image();
/** @var ISimpleFile $file */
$file = $folder->getFile('photo.' . $ext);
$photo->loadFromData($file->getContent());
diff --git a/apps/dav/lib/CardDAV/UserAddressBooks.php b/apps/dav/lib/CardDAV/UserAddressBooks.php
index e2d3fe4d8c84d..aee26af4ed9c7 100644
--- a/apps/dav/lib/CardDAV/UserAddressBooks.php
+++ b/apps/dav/lib/CardDAV/UserAddressBooks.php
@@ -20,6 +20,7 @@
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
+use OCP\Server;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Sabre\CardDAV\Backend;
@@ -98,7 +99,7 @@ public function getChildren() {
$addressBook,
$this->l10n,
$this->config,
- \OCP\Server::get(IUserSession::class),
+ Server::get(IUserSession::class),
$request,
$trustedServers,
$this->groupManager
diff --git a/apps/dav/lib/Command/ListCalendars.php b/apps/dav/lib/Command/ListCalendars.php
index 5344530e8a528..7cbde674d61e6 100644
--- a/apps/dav/lib/Command/ListCalendars.php
+++ b/apps/dav/lib/Command/ListCalendars.php
@@ -7,6 +7,7 @@
use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\CalDAV\CalDavBackend;
+use OCA\DAV\DAV\Sharing\Plugin;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
@@ -47,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$readOnly = false;
- $readOnlyIndex = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
+ $readOnlyIndex = '{' . Plugin::NS_OWNCLOUD . '}read-only';
if (isset($calendar[$readOnlyIndex])) {
$readOnly = $calendar[$readOnlyIndex];
}
@@ -55,8 +56,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$calendarTableData[] = [
$calendar['uri'],
$calendar['{DAV:}displayname'],
- $calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'],
- $calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'],
+ $calendar['{' . Plugin::NS_OWNCLOUD . '}owner-principal'],
+ $calendar['{' . Plugin::NS_NEXTCLOUD . '}owner-displayname'],
$readOnly ? ' x ' : ' ✓ ',
];
}
diff --git a/apps/dav/lib/Comments/CommentsPlugin.php b/apps/dav/lib/Comments/CommentsPlugin.php
index ef0de057ebbe0..6cae12d20ab20 100644
--- a/apps/dav/lib/Comments/CommentsPlugin.php
+++ b/apps/dav/lib/Comments/CommentsPlugin.php
@@ -9,6 +9,7 @@
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
+use OCP\Comments\MessageTooLongException;
use OCP\IUserSession;
use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\NotFound;
@@ -227,9 +228,9 @@ private function createComment($objectType, $objectId, $data, $contentType = 'ap
return $comment;
} catch (\InvalidArgumentException $e) {
throw new BadRequest('Invalid input values', 0, $e);
- } catch (\OCP\Comments\MessageTooLongException $e) {
+ } catch (MessageTooLongException $e) {
$msg = 'Message exceeds allowed character limit of ';
- throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0, $e);
+ throw new BadRequest($msg . IComment::MAX_MESSAGE_LENGTH, 0, $e);
}
}
}
diff --git a/apps/dav/lib/Connector/LegacyPublicAuth.php b/apps/dav/lib/Connector/LegacyPublicAuth.php
index 564eae506ac9a..731654df31a45 100644
--- a/apps/dav/lib/Connector/LegacyPublicAuth.php
+++ b/apps/dav/lib/Connector/LegacyPublicAuth.php
@@ -8,6 +8,7 @@
namespace OCA\DAV\Connector;
use OCA\DAV\Connector\Sabre\PublicAuth;
+use OCP\Defaults;
use OCP\IRequest;
use OCP\ISession;
use OCP\Security\Bruteforce\IThrottler;
@@ -40,7 +41,7 @@ public function __construct(IRequest $request,
$this->throttler = $throttler;
// setup realm
- $defaults = new \OCP\Defaults();
+ $defaults = new Defaults();
$this->realm = $defaults->getName() ?: 'Nextcloud';
}
diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php
index 9b67d960107cb..4c6ce55798029 100644
--- a/apps/dav/lib/Connector/Sabre/Auth.php
+++ b/apps/dav/lib/Connector/Sabre/Auth.php
@@ -13,6 +13,7 @@
use OC\User\Session;
use OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden;
use OCA\DAV\Connector\Sabre\Exception\TooManyRequests;
+use OCP\Defaults;
use OCP\IRequest;
use OCP\ISession;
use OCP\Security\Bruteforce\IThrottler;
@@ -48,7 +49,7 @@ public function __construct(ISession $session,
$this->principalPrefix = $principalPrefix;
// setup realm
- $defaults = new \OCP\Defaults();
+ $defaults = new Defaults();
$this->realm = $defaults->getName() ?: 'Nextcloud';
}
diff --git a/apps/dav/lib/Connector/Sabre/BearerAuth.php b/apps/dav/lib/Connector/Sabre/BearerAuth.php
index 8caae8dced9d2..d5840848ceff0 100644
--- a/apps/dav/lib/Connector/Sabre/BearerAuth.php
+++ b/apps/dav/lib/Connector/Sabre/BearerAuth.php
@@ -5,6 +5,7 @@
*/
namespace OCA\DAV\Connector\Sabre;
+use OCP\Defaults;
use OCP\IRequest;
use OCP\ISession;
use OCP\IUserSession;
@@ -28,7 +29,7 @@ public function __construct(IUserSession $userSession,
$this->principalPrefix = $principalPrefix;
// setup realm
- $defaults = new \OCP\Defaults();
+ $defaults = new Defaults();
$this->realm = $defaults->getName() ?: 'Nextcloud';
}
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index c1b69323a44e4..c520a6c5a8495 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -13,10 +13,12 @@
use OCA\DAV\Connector\Sabre\Exception\FileLocked;
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
+use OCP\App\IAppManager;
use OCP\Files\FileInfo;
use OCP\Files\Folder;
use OCP\Files\ForbiddenException;
use OCP\Files\InvalidPathException;
+use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\StorageNotAvailableException;
use OCP\IL10N;
@@ -24,6 +26,7 @@
use OCP\L10N\IFactory;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
+use OCP\Server;
use OCP\Share\IManager as IShareManager;
use Psr\Log\LoggerInterface;
use Sabre\DAV\Exception\BadRequest;
@@ -33,7 +36,7 @@
use Sabre\DAV\IFile;
use Sabre\DAV\INode;
-class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget, \Sabre\DAV\ICopyTarget {
+class Directory extends Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget, \Sabre\DAV\ICopyTarget {
/**
* Cached directory content
* @var \OCP\Files\FileInfo[]
@@ -101,7 +104,7 @@ public function createFile($name, $data = null) {
'type' => FileInfo::TYPE_FILE
], null);
}
- $node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info);
+ $node = new File($this->fileView, $info);
// only allow 1 process to upload a file at once but still allow reading the file while writing the part file
$node->acquireLock(ILockingProvider::LOCK_SHARED);
@@ -112,7 +115,7 @@ public function createFile($name, $data = null) {
$this->fileView->unlockFile($path . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE);
$node->releaseLock(ILockingProvider::LOCK_SHARED);
return $result;
- } catch (\OCP\Files\StorageNotAvailableException $e) {
+ } catch (StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage(), $e->getCode(), $e);
} catch (InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage(), false, $ex);
@@ -143,7 +146,7 @@ public function createDirectory($name) {
if (!$this->fileView->mkdir($newPath)) {
throw new \Sabre\DAV\Exception\Forbidden('Could not create directory ' . $newPath);
}
- } catch (\OCP\Files\StorageNotAvailableException $e) {
+ } catch (StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage(), 0, $e);
} catch (InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage(), false, $ex);
@@ -175,7 +178,7 @@ public function getChild($name, $info = null, ?IRequest $request = null, ?IL10N
try {
$this->fileView->verifyPath($this->path, $name, true);
$info = $this->fileView->getFileInfo($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
+ } catch (StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage(), 0, $e);
} catch (InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage(), false, $ex);
@@ -191,7 +194,7 @@ public function getChild($name, $info = null, ?IRequest $request = null, ?IL10N
if ($info->getMimeType() === FileInfo::MIMETYPE_FOLDER) {
$node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this->tree, $this->shareManager);
} else {
- $node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info, $this->shareManager, $request, $l10n);
+ $node = new File($this->fileView, $info, $this->shareManager, $request, $l10n);
}
if ($this->tree) {
$this->tree->cacheNode($node);
@@ -204,7 +207,7 @@ public function getChild($name, $info = null, ?IRequest $request = null, ?IL10N
*
* @return \Sabre\DAV\INode[]
* @throws \Sabre\DAV\Exception\Locked
- * @throws \OCA\DAV\Connector\Sabre\Exception\Forbidden
+ * @throws Forbidden
*/
public function getChildren() {
if (!is_null($this->dirContent)) {
@@ -214,7 +217,7 @@ public function getChildren() {
if (!$this->info->isReadable()) {
// return 403 instead of 404 because a 404 would make
// the caller believe that the collection itself does not exist
- if (\OCP\Server::get(\OCP\App\IAppManager::class)->isInstalled('files_accesscontrol')) {
+ if (Server::get(IAppManager::class)->isInstalled('files_accesscontrol')) {
throw new Forbidden('No read permissions. This might be caused by files_accesscontrol, check your configured rules');
} else {
throw new Forbidden('No read permissions');
@@ -300,8 +303,8 @@ public function getQuotaInfo() {
try {
$storageInfo = \OC_Helper::getStorageInfo($relativePath, $this->info, false);
- if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
- $free = \OCP\Files\FileInfo::SPACE_UNLIMITED;
+ if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) {
+ $free = FileInfo::SPACE_UNLIMITED;
} else {
$free = $storageInfo['free'];
}
@@ -310,10 +313,10 @@ public function getQuotaInfo() {
$free
];
return $this->quotaInfo;
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
$this->getLogger()->warning('error while getting quota into', ['exception' => $e]);
return [0, 0];
- } catch (\OCP\Files\StorageNotAvailableException $e) {
+ } catch (StorageNotAvailableException $e) {
$this->getLogger()->warning('error while getting quota into', ['exception' => $e]);
return [0, 0];
} catch (NotPermittedException $e) {
diff --git a/apps/dav/lib/Connector/Sabre/Exception/FileLocked.php b/apps/dav/lib/Connector/Sabre/Exception/FileLocked.php
index bad4bfa12ab58..38708e945e986 100644
--- a/apps/dav/lib/Connector/Sabre/Exception/FileLocked.php
+++ b/apps/dav/lib/Connector/Sabre/Exception/FileLocked.php
@@ -8,6 +8,7 @@
namespace OCA\DAV\Connector\Sabre\Exception;
use Exception;
+use OCP\Files\LockNotAcquiredException;
class FileLocked extends \Sabre\DAV\Exception {
/**
@@ -15,7 +16,7 @@ class FileLocked extends \Sabre\DAV\Exception {
* @param int $code
*/
public function __construct($message = '', $code = 0, ?Exception $previous = null) {
- if ($previous instanceof \OCP\Files\LockNotAcquiredException) {
+ if ($previous instanceof LockNotAcquiredException) {
$message = sprintf('Target file %s is locked by another process.', $previous->path);
}
parent::__construct($message, $code, $previous);
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index d1769ce6b81b1..36ac0fcec7218 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -18,6 +18,7 @@
use OCA\DAV\Connector\Sabre\Exception\FileLocked;
use OCA\DAV\Connector\Sabre\Exception\Forbidden as DAVForbiddenException;
use OCA\DAV\Connector\Sabre\Exception\UnsupportedMediaType;
+use OCP\App\IAppManager;
use OCP\Encryption\Exceptions\GenericEncryptionException;
use OCP\Files\EntityTooLargeException;
use OCP\Files\FileInfo;
@@ -35,6 +36,7 @@
use OCP\L10N\IFactory as IL10NFactory;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
+use OCP\Server;
use OCP\Share\IManager;
use Psr\Log\LoggerInterface;
use Sabre\DAV\Exception;
@@ -123,7 +125,7 @@ public function put($data) {
}
$needsPartFile = $partStorage->needsPartFile() && (strlen($this->path) > 1);
- $view = \OC\Files\Filesystem::getView();
+ $view = Filesystem::getView();
if ($needsPartFile) {
// mark file as partial while uploading (ignored by the scanner)
@@ -402,19 +404,19 @@ private function emitPreHooks(bool $exists, ?string $path = null): bool {
$run = true;
if (!$exists) {
- \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_create, [
- \OC\Files\Filesystem::signal_param_path => $hookPath,
- \OC\Files\Filesystem::signal_param_run => &$run,
+ \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_create, [
+ Filesystem::signal_param_path => $hookPath,
+ Filesystem::signal_param_run => &$run,
]);
} else {
- \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_update, [
- \OC\Files\Filesystem::signal_param_path => $hookPath,
- \OC\Files\Filesystem::signal_param_run => &$run,
+ \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_update, [
+ Filesystem::signal_param_path => $hookPath,
+ Filesystem::signal_param_run => &$run,
]);
}
- \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_write, [
- \OC\Files\Filesystem::signal_param_path => $hookPath,
- \OC\Files\Filesystem::signal_param_run => &$run,
+ \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_write, [
+ Filesystem::signal_param_path => $hookPath,
+ Filesystem::signal_param_run => &$run,
]);
return $run;
}
@@ -429,16 +431,16 @@ private function emitPostHooks(bool $exists, ?string $path = null): void {
return;
}
if (!$exists) {
- \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_create, [
- \OC\Files\Filesystem::signal_param_path => $hookPath
+ \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_create, [
+ Filesystem::signal_param_path => $hookPath
]);
} else {
- \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_update, [
- \OC\Files\Filesystem::signal_param_path => $hookPath
+ \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_update, [
+ Filesystem::signal_param_path => $hookPath
]);
}
- \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_write, [
- \OC\Files\Filesystem::signal_param_path => $hookPath
+ \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_write, [
+ Filesystem::signal_param_path => $hookPath
]);
}
@@ -535,7 +537,7 @@ public function getContentType() {
* @return array|bool
*/
public function getDirectDownload() {
- if (\OCP\Server::get(\OCP\App\IAppManager::class)->isEnabledForUser('encryption')) {
+ if (Server::get(IAppManager::class)->isEnabledForUser('encryption')) {
return [];
}
[$storage, $internalPath] = $this->fileView->resolvePath($this->path);
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
index 07308d4e805d0..3855f51c65a2d 100644
--- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
@@ -259,7 +259,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response)
}
}
- if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
+ if ($node instanceof File) {
//Add OC-Checksum header
$checksum = $node->getChecksum();
if ($checksum !== null && $checksum !== '') {
@@ -279,7 +279,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response)
public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) {
$httpRequest = $this->server->httpRequest;
- if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
+ if ($node instanceof Node) {
/**
* This was disabled, because it made dir listing throw an exception,
* so users were unable to navigate into folders where one subitem
@@ -415,7 +415,7 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
});
}
- if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
+ if ($node instanceof File) {
$propFind->handle(self::DOWNLOADURL_PROPERTYNAME, function () use ($node) {
try {
$directDownloadUrl = $node->getDirectDownload();
@@ -504,7 +504,7 @@ protected function ncPermissions2ocmPermissions($ncPermissions) {
*/
public function handleUpdateProperties($path, PropPatch $propPatch) {
$node = $this->tree->getNodeForPath($path);
- if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) {
+ if (!($node instanceof Node)) {
return;
}
@@ -670,7 +670,7 @@ public function sendFileIdHeader($filePath, ?\Sabre\DAV\INode $node = null) {
return;
}
$node = $this->server->tree->getNodeForPath($filePath);
- if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
+ if ($node instanceof Node) {
$fileId = $node->getFileId();
if (!is_null($fileId)) {
$this->server->httpResponse->setHeader('OC-FileId', $fileId);
diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
index b82fee957bc24..49ceff9118dd5 100644
--- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
@@ -8,6 +8,7 @@
namespace OCA\DAV\Connector\Sabre;
use OC\Files\View;
+use OCA\Circles\Api\v1\Circles;
use OCP\App\IAppManager;
use OCP\Files\Folder;
use OCP\Files\Node as INode;
@@ -355,7 +356,7 @@ private function getCirclesFileIds(array $circlesIds) {
if (!$this->appManager->isEnabledForUser('circles') || !class_exists('\OCA\Circles\Api\v1\Circles')) {
return [];
}
- return \OCA\Circles\Api\v1\Circles::getFilesForCircles($circlesIds);
+ return Circles::getFilesForCircles($circlesIds);
}
@@ -419,7 +420,7 @@ public function findNodesByFileIds(Node $rootNode, array $fileIds): array {
return $results;
}
- protected function wrapNode(\OCP\Files\Node $node): File|Directory {
+ protected function wrapNode(INode $node): File|Directory {
if ($node instanceof \OCP\Files\File) {
return new File($this->fileView, $node);
} else {
diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php
index ac5514e11e140..93cf302ff8936 100644
--- a/apps/dav/lib/Connector/Sabre/Node.php
+++ b/apps/dav/lib/Connector/Sabre/Node.php
@@ -12,8 +12,10 @@
use OC\Files\Node\Folder;
use OC\Files\View;
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
+use OCP\Constants;
use OCP\Files\DavUtil;
use OCP\Files\FileInfo;
+use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\ISharedStorage;
@@ -282,15 +284,15 @@ public function getSharePermissions($user) {
}
if (!$mountpoint->getOption('readonly', false) && $mountpointpath === $this->info->getPath()) {
- $permissions |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE;
+ $permissions |= Constants::PERMISSION_DELETE | Constants::PERMISSION_UPDATE;
}
}
/*
* Files can't have create or delete permissions
*/
- if ($this->info->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
- $permissions &= ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE);
+ if ($this->info->getType() === FileInfo::TYPE_FILE) {
+ $permissions &= ~(Constants::PERMISSION_CREATE | Constants::PERMISSION_DELETE);
}
return $permissions;
@@ -358,7 +360,7 @@ protected function verifyPath(?string $path = null): void {
dirname($path),
basename($path),
);
- } catch (\OCP\Files\InvalidPathException $ex) {
+ } catch (InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage());
}
}
diff --git a/apps/dav/lib/Connector/Sabre/ObjectTree.php b/apps/dav/lib/Connector/Sabre/ObjectTree.php
index 94098b4aca3ba..6cdd570874385 100644
--- a/apps/dav/lib/Connector/Sabre/ObjectTree.php
+++ b/apps/dav/lib/Connector/Sabre/ObjectTree.php
@@ -9,10 +9,13 @@
use OC\Files\FileInfo;
use OC\Files\Storage\FailedStorage;
+use OC\Files\View;
use OCA\DAV\Connector\Sabre\Exception\FileLocked;
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
use OCP\Files\ForbiddenException;
+use OCP\Files\InvalidPathException;
+use OCP\Files\Mount\IMountManager;
use OCP\Files\StorageInvalidException;
use OCP\Files\StorageNotAvailableException;
use OCP\Lock\LockedException;
@@ -40,7 +43,7 @@ public function __construct() {
* @param \OC\Files\View $view
* @param \OCP\Files\Mount\IMountManager $mountManager
*/
- public function init(\Sabre\DAV\INode $rootNode, \OC\Files\View $view, \OCP\Files\Mount\IMountManager $mountManager) {
+ public function init(\Sabre\DAV\INode $rootNode, View $view, IMountManager $mountManager) {
$this->rootNode = $rootNode;
$this->fileView = $view;
$this->mountManager = $mountManager;
@@ -70,7 +73,7 @@ public function getNodeForPath($path) {
if ($path) {
try {
$this->fileView->verifyPath($path, basename($path));
- } catch (\OCP\Files\InvalidPathException $ex) {
+ } catch (InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage());
}
}
@@ -120,9 +123,9 @@ public function getNodeForPath($path) {
}
if ($info->getType() === 'dir') {
- $node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this);
+ $node = new Directory($this->fileView, $info, $this);
} else {
- $node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info);
+ $node = new File($this->fileView, $info);
}
$this->cache[$path] = $node;
@@ -169,7 +172,7 @@ public function copy($sourcePath, $destinationPath) {
[$destinationDir, $destinationName] = \Sabre\Uri\split($destinationPath);
try {
$this->fileView->verifyPath($destinationDir, $destinationName);
- } catch (\OCP\Files\InvalidPathException $ex) {
+ } catch (InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage());
}
diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php
index 029061694ea27..0151bc9cf697c 100644
--- a/apps/dav/lib/Connector/Sabre/Principal.php
+++ b/apps/dav/lib/Connector/Sabre/Principal.php
@@ -7,6 +7,7 @@
namespace OCA\DAV\Connector\Sabre;
use OC\KnownUser\KnownUserService;
+use OCA\Circles\Api\v1\Circles;
use OCA\Circles\Exceptions\CircleNotFoundException;
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCA\DAV\Traits\PrincipalProxyTrait;
@@ -530,7 +531,7 @@ protected function circleToPrincipal($circleUniqueId) {
}
try {
- $circle = \OCA\Circles\Api\v1\Circles::detailsCircle($circleUniqueId, true);
+ $circle = Circles::detailsCircle($circleUniqueId, true);
} catch (QueryException $ex) {
return null;
} catch (CircleNotFoundException $ex) {
@@ -570,7 +571,7 @@ public function getCircleMembership($principal):array {
throw new Exception('Principal not found');
}
- $circles = \OCA\Circles\Api\v1\Circles::joinedCircles($name, true);
+ $circles = Circles::joinedCircles($name, true);
$circles = array_map(function ($circle) {
/** @var \OCA\Circles\Model\Circle $circle */
diff --git a/apps/dav/lib/Connector/Sabre/PublicAuth.php b/apps/dav/lib/Connector/Sabre/PublicAuth.php
index 3e2cd81a80051..977b3bf304e27 100644
--- a/apps/dav/lib/Connector/Sabre/PublicAuth.php
+++ b/apps/dav/lib/Connector/Sabre/PublicAuth.php
@@ -11,6 +11,7 @@
namespace OCA\DAV\Connector\Sabre;
+use OCP\Defaults;
use OCP\IRequest;
use OCP\ISession;
use OCP\Security\Bruteforce\IThrottler;
@@ -54,7 +55,7 @@ public function __construct(IRequest $request,
$this->logger = $logger;
// setup realm
- $defaults = new \OCP\Defaults();
+ $defaults = new Defaults();
$this->realm = $defaults->getName();
}
diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php
index 53ce0ec3eee4b..6dae98ce7f43a 100644
--- a/apps/dav/lib/Connector/Sabre/ServerFactory.php
+++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php
@@ -9,6 +9,7 @@
use OCA\DAV\AppInfo\PluginManager;
use OCA\DAV\CalDAV\DefaultCalendarValidator;
+use OCA\DAV\DAV\CustomPropertiesBackend;
use OCA\DAV\DAV\ViewOnlyPlugin;
use OCA\DAV\Files\ErrorPagePlugin;
use OCA\Theming\ThemingDefaults;
@@ -71,24 +72,24 @@ public function createServer(string $baseUri,
Plugin $authPlugin,
callable $viewCallBack): Server {
// Fire up server
- $objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
- $server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
+ $objectTree = new ObjectTree();
+ $server = new Server($objectTree);
// Set URL explicitly due to reverse-proxy situations
$server->httpRequest->setUrl($requestUri);
$server->setBaseUri($baseUri);
// Load plugins
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config, $this->l10n));
+ $server->addPlugin(new MaintenancePlugin($this->config, $this->l10n));
$server->addPlugin(new BlockLegacyClientPlugin(
\OCP\Server::get(IConfig::class),
\OCP\Server::get(ThemingDefaults::class),
));
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin());
+ $server->addPlugin(new AnonymousOptionsPlugin());
$server->addPlugin($authPlugin);
// FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
+ $server->addPlugin(new DummyGetResponsePlugin());
+ $server->addPlugin(new ExceptionLoggerPlugin('webdav', $this->logger));
+ $server->addPlugin(new LockPlugin());
$server->addPlugin(new RequestIdHeaderPlugin(\OC::$server->get(IRequest::class)));
@@ -99,7 +100,7 @@ public function createServer(string $baseUri,
'/OneNote/',
'/Microsoft-WebDAV-MiniRedir/',
])) {
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
+ $server->addPlugin(new FakeLockerPlugin());
}
$server->addPlugin(new ErrorPagePlugin($this->request, $this->config));
@@ -119,14 +120,14 @@ public function createServer(string $baseUri,
// Create Nextcloud Dir
if ($rootInfo->getType() === 'dir') {
- $root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo, $objectTree);
+ $root = new Directory($view, $rootInfo, $objectTree);
} else {
- $root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
+ $root = new File($view, $rootInfo);
}
$objectTree->init($root, $view, $this->mountManager);
$server->addPlugin(
- new \OCA\DAV\Connector\Sabre\FilesPlugin(
+ new FilesPlugin(
$objectTree,
$this->config,
$this->request,
@@ -137,8 +138,8 @@ public function createServer(string $baseUri,
!$this->config->getSystemValue('debug', false)
)
);
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view, true));
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\ChecksumUpdatePlugin());
+ $server->addPlugin(new QuotaPlugin($view, true));
+ $server->addPlugin(new ChecksumUpdatePlugin());
// Allow view-only plugin for webdav requests
$server->addPlugin(new ViewOnlyPlugin(
@@ -146,15 +147,15 @@ public function createServer(string $baseUri,
));
if ($this->userSession->isLoggedIn()) {
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin(
+ $server->addPlugin(new TagsPlugin($objectTree, $this->tagManager));
+ $server->addPlugin(new SharesPlugin(
$objectTree,
$this->userSession,
$userFolder,
\OC::$server->getShareManager()
));
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin(
+ $server->addPlugin(new CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
+ $server->addPlugin(new FilesReportPlugin(
$objectTree,
$view,
\OC::$server->getSystemTagManager(),
@@ -168,7 +169,7 @@ public function createServer(string $baseUri,
// custom properties plugin must be the last one
$server->addPlugin(
new \Sabre\DAV\PropertyStorage\Plugin(
- new \OCA\DAV\DAV\CustomPropertiesBackend(
+ new CustomPropertiesBackend(
$server,
$objectTree,
$this->databaseConnection,
@@ -178,7 +179,7 @@ public function createServer(string $baseUri,
)
);
}
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
+ $server->addPlugin(new CopyEtagHeaderPlugin());
// Load dav plugins from apps
$event = new SabrePluginEvent($server);
diff --git a/apps/dav/lib/Connector/Sabre/TagsPlugin.php b/apps/dav/lib/Connector/Sabre/TagsPlugin.php
index a3f2847ee1ac0..c048b79484a60 100644
--- a/apps/dav/lib/Connector/Sabre/TagsPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/TagsPlugin.php
@@ -27,7 +27,7 @@
* License along with this library. If not, see .
*
*/
-
+use OCP\ITagManager;
use Sabre\DAV\PropFind;
use Sabre\DAV\PropPatch;
@@ -73,7 +73,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin {
* @param \Sabre\DAV\Tree $tree tree
* @param \OCP\ITagManager $tagManager tag manager
*/
- public function __construct(\Sabre\DAV\Tree $tree, \OCP\ITagManager $tagManager) {
+ public function __construct(\Sabre\DAV\Tree $tree, ITagManager $tagManager) {
$this->tree = $tree;
$this->tagManager = $tagManager;
$this->tagger = null;
@@ -191,12 +191,12 @@ public function handleGetProperties(
PropFind $propFind,
\Sabre\DAV\INode $node,
) {
- if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) {
+ if (!($node instanceof Node)) {
return;
}
// need prefetch ?
- if ($node instanceof \OCA\DAV\Connector\Sabre\Directory
+ if ($node instanceof Directory
&& $propFind->getDepth() !== 0
&& (!is_null($propFind->getStatus(self::TAGS_PROPERTYNAME))
|| !is_null($propFind->getStatus(self::FAVORITE_PROPERTYNAME))
@@ -250,7 +250,7 @@ public function handleGetProperties(
*/
public function handleUpdateProperties($path, PropPatch $propPatch) {
$node = $this->tree->getNodeForPath($path);
- if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) {
+ if (!($node instanceof Node)) {
return;
}
diff --git a/apps/dav/lib/DAV/Sharing/Backend.php b/apps/dav/lib/DAV/Sharing/Backend.php
index 06a082628d3eb..a69645655a88a 100644
--- a/apps/dav/lib/DAV/Sharing/Backend.php
+++ b/apps/dav/lib/DAV/Sharing/Backend.php
@@ -183,13 +183,13 @@ public function applyShareAcl(array $shares, array $acl): array {
foreach ($shares as $share) {
$acl[] = [
'privilege' => '{DAV:}read',
- 'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'],
+ 'principal' => $share['{' . Plugin::NS_OWNCLOUD . '}principal'],
'protected' => true,
];
if (!$share['readOnly']) {
$acl[] = [
'privilege' => '{DAV:}write',
- 'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'],
+ 'principal' => $share['{' . Plugin::NS_OWNCLOUD . '}principal'],
'protected' => true,
];
} elseif (in_array($this->service->getResourceType(), ['calendar','addressbook'])) {
@@ -197,7 +197,7 @@ public function applyShareAcl(array $shares, array $acl): array {
// so users can change the visibility.
$acl[] = [
'privilege' => '{DAV:}write-properties',
- 'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'],
+ 'principal' => $share['{' . Plugin::NS_OWNCLOUD . '}principal'],
'protected' => true,
];
}
diff --git a/apps/dav/lib/Files/FileSearchBackend.php b/apps/dav/lib/Files/FileSearchBackend.php
index 3bc729d640727..1b7859621129b 100644
--- a/apps/dav/lib/Files/FileSearchBackend.php
+++ b/apps/dav/lib/Files/FileSearchBackend.php
@@ -13,6 +13,7 @@
use OC\Files\View;
use OCA\DAV\Connector\Sabre\CachingTree;
use OCA\DAV\Connector\Sabre\Directory;
+use OCA\DAV\Connector\Sabre\File;
use OCA\DAV\Connector\Sabre\FilesPlugin;
use OCA\DAV\Connector\Sabre\TagsPlugin;
use OCP\Files\Cache\ICacheEntry;
@@ -206,9 +207,9 @@ public function search(Query $search): array {
/** @var SearchResult[] $nodes */
$nodes = array_map(function (Node $node) {
if ($node instanceof Folder) {
- $davNode = new \OCA\DAV\Connector\Sabre\Directory($this->view, $node, $this->tree, $this->shareManager);
+ $davNode = new Directory($this->view, $node, $this->tree, $this->shareManager);
} else {
- $davNode = new \OCA\DAV\Connector\Sabre\File($this->view, $node, $this->shareManager);
+ $davNode = new File($this->view, $node, $this->shareManager);
}
$path = $this->getHrefForNode($node);
$this->tree->cacheNode($davNode, $path);
diff --git a/apps/dav/lib/Files/FilesHome.php b/apps/dav/lib/Files/FilesHome.php
index 1c0c531e2f903..b865b7c1bb65b 100644
--- a/apps/dav/lib/Files/FilesHome.php
+++ b/apps/dav/lib/Files/FilesHome.php
@@ -7,6 +7,7 @@
*/
namespace OCA\DAV\Files;
+use OC\Files\Filesystem;
use OCA\DAV\Connector\Sabre\Directory;
use OCP\Files\FileInfo;
use Sabre\DAV\Exception\Forbidden;
@@ -26,7 +27,7 @@ class FilesHome extends Directory {
*/
public function __construct($principalInfo, FileInfo $userFolder) {
$this->principalInfo = $principalInfo;
- $view = \OC\Files\Filesystem::getView();
+ $view = Filesystem::getView();
parent::__construct($view, $userFolder);
}
diff --git a/apps/dav/lib/Listener/OutOfOfficeListener.php b/apps/dav/lib/Listener/OutOfOfficeListener.php
index 45728aa35d31d..8e12d2ef4fe0a 100644
--- a/apps/dav/lib/Listener/OutOfOfficeListener.php
+++ b/apps/dav/lib/Listener/OutOfOfficeListener.php
@@ -14,6 +14,7 @@
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Calendar;
use OCA\DAV\CalDAV\CalendarHome;
+use OCA\DAV\CalDAV\Plugin;
use OCA\DAV\CalDAV\TimezoneService;
use OCA\DAV\ServerFactory;
use OCP\EventDispatcher\Event;
@@ -111,7 +112,7 @@ private function getCalendarNode(string $principal, string $userId): ?Calendar {
$invitationServer = $this->serverFactory->createInviationResponseServer(false);
$server = $invitationServer->getServer();
- /** @var \OCA\DAV\CalDAV\Plugin $caldavPlugin */
+ /** @var Plugin $caldavPlugin */
$caldavPlugin = $server->getPlugin('caldav');
$calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principal);
if ($calendarHomePath === null) {
diff --git a/apps/dav/lib/RootCollection.php b/apps/dav/lib/RootCollection.php
index d9ba4c3e2a6cb..6ede8cb683c17 100644
--- a/apps/dav/lib/RootCollection.php
+++ b/apps/dav/lib/RootCollection.php
@@ -23,6 +23,9 @@
use OCA\DAV\DAV\GroupPrincipalBackend;
use OCA\DAV\DAV\SystemPrincipalBackend;
use OCA\DAV\Provisioning\Apple\AppleProvisioningNode;
+use OCA\DAV\SystemTag\SystemTagsByIdCollection;
+use OCA\DAV\SystemTag\SystemTagsInUseCollection;
+use OCA\DAV\SystemTag\SystemTagsRelationsCollection;
use OCA\DAV\Upload\CleanupService;
use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager;
@@ -30,6 +33,7 @@
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\IConfig;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Sabre\DAV\SimpleCollection;
@@ -46,7 +50,7 @@ public function __construct() {
$dispatcher = \OC::$server->get(IEventDispatcher::class);
$config = \OC::$server->get(IConfig::class);
$proxyMapper = \OC::$server->query(ProxyMapper::class);
- $rootFolder = \OCP\Server::get(IRootFolder::class);
+ $rootFolder = Server::get(IRootFolder::class);
$userPrincipalBackend = new Principal(
$userManager,
@@ -101,12 +105,12 @@ public function __construct() {
$publicCalendarRoot = new PublicCalendarRoot($caldavBackend, $l10n, $config, $logger);
- $systemTagCollection = new SystemTag\SystemTagsByIdCollection(
+ $systemTagCollection = new SystemTagsByIdCollection(
\OC::$server->getSystemTagManager(),
\OC::$server->getUserSession(),
$groupManager
);
- $systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection(
+ $systemTagRelationsCollection = new SystemTagsRelationsCollection(
\OC::$server->getSystemTagManager(),
\OC::$server->getSystemTagObjectMapper(),
\OC::$server->getUserSession(),
@@ -114,7 +118,7 @@ public function __construct() {
$dispatcher,
$rootFolder,
);
- $systemTagInUseCollection = \OCP\Server::get(SystemTag\SystemTagsInUseCollection::class);
+ $systemTagInUseCollection = Server::get(SystemTagsInUseCollection::class);
$commentsCollection = new Comments\RootCollection(
\OC::$server->getCommentsManager(),
$userManager,
diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php
index daf180aec8373..a22d2b685412e 100644
--- a/apps/dav/lib/Server.php
+++ b/apps/dav/lib/Server.php
@@ -6,11 +6,17 @@
*/
namespace OCA\DAV;
+use OC\Files\Filesystem;
use OCA\DAV\AppInfo\PluginManager;
use OCA\DAV\BulkUpload\BulkUploadPlugin;
+use OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin;
use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\CalDAV\DefaultCalendarValidator;
+use OCA\DAV\CalDAV\EventComparisonService;
+use OCA\DAV\CalDAV\ICSExportPlugin\ICSExportPlugin;
+use OCA\DAV\CalDAV\Publishing\PublishPlugin;
use OCA\DAV\CalDAV\Schedule\IMipPlugin;
+use OCA\DAV\CalDAV\Schedule\IMipService;
use OCA\DAV\CalDAV\Security\RateLimitingPlugin;
use OCA\DAV\CalDAV\Validation\CalDavValidatePlugin;
use OCA\DAV\CardDAV\HasPhotoPlugin;
@@ -21,6 +27,7 @@
use OCA\DAV\CardDAV\Validation\CardDavValidatePlugin;
use OCA\DAV\Comments\CommentsPlugin;
use OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin;
+use OCA\DAV\Connector\Sabre\AppleQuirksPlugin;
use OCA\DAV\Connector\Sabre\Auth;
use OCA\DAV\Connector\Sabre\BearerAuth;
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
@@ -30,9 +37,12 @@
use OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin;
use OCA\DAV\Connector\Sabre\DavAclPlugin;
use OCA\DAV\Connector\Sabre\DummyGetResponsePlugin;
+use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
use OCA\DAV\Connector\Sabre\FakeLockerPlugin;
use OCA\DAV\Connector\Sabre\FilesPlugin;
use OCA\DAV\Connector\Sabre\FilesReportPlugin;
+use OCA\DAV\Connector\Sabre\LockPlugin;
+use OCA\DAV\Connector\Sabre\MaintenancePlugin;
use OCA\DAV\Connector\Sabre\PropfindCompressionPlugin;
use OCA\DAV\Connector\Sabre\QuotaPlugin;
use OCA\DAV\Connector\Sabre\RequestIdHeaderPlugin;
@@ -44,6 +54,7 @@
use OCA\DAV\Events\SabrePluginAddEvent;
use OCA\DAV\Events\SabrePluginAuthInitEvent;
use OCA\DAV\Files\ErrorPagePlugin;
+use OCA\DAV\Files\FileSearchBackend;
use OCA\DAV\Files\LazySearchBackend;
use OCA\DAV\Profiler\ProfilerPlugin;
use OCA\DAV\Provisioning\Apple\AppleProvisioningPlugin;
@@ -52,6 +63,8 @@
use OCA\DAV\Upload\ChunkingV2Plugin;
use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\Http\Response;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Defaults;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IFilenameValidator;
@@ -61,8 +74,10 @@
use OCP\IPreview;
use OCP\IRequest;
use OCP\IUserSession;
+use OCP\Mail\IMailer;
use OCP\Profiler\IProfiler;
use OCP\SabrePluginEvent;
+use OCP\Share\IManager;
use Psr\Log\LoggerInterface;
use Sabre\CardDAV\VCFExportPlugin;
use Sabre\DAV\Auth\Plugin;
@@ -93,9 +108,9 @@ public function __construct(IRequest $request, string $baseUri) {
$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
// Add maintenance plugin
- $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
+ $this->server->addPlugin(new MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
- $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\AppleQuirksPlugin());
+ $this->server->addPlugin(new AppleQuirksPlugin());
// Backends
$authBackend = new Auth(
@@ -143,8 +158,8 @@ public function __construct(IRequest $request, string $baseUri) {
$this->server->addPlugin(new DummyGetResponsePlugin());
}
- $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
- $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
+ $this->server->addPlugin(new ExceptionLoggerPlugin('webdav', $logger));
+ $this->server->addPlugin(new LockPlugin());
$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
// acl
@@ -161,7 +176,7 @@ public function __construct(IRequest $request, string $baseUri) {
if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) {
$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest(), \OC::$server->getConfig()));
$this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
- $this->server->addPlugin(new \OCA\DAV\CalDAV\ICSExportPlugin\ICSExportPlugin(\OC::$server->getConfig(), $logger));
+ $this->server->addPlugin(new ICSExportPlugin(\OC::$server->getConfig(), $logger));
$this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DefaultCalendarValidator::class)));
$this->server->addPlugin(\OC::$server->get(\OCA\DAV\CalDAV\Trashbin\Plugin::class));
@@ -171,7 +186,7 @@ public function __construct(IRequest $request, string $baseUri) {
}
$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
- $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
+ $this->server->addPlugin(new PublishPlugin(
\OC::$server->getConfig(),
\OC::$server->getURLGenerator()
));
@@ -241,7 +256,7 @@ public function __construct(IRequest $request, string $baseUri) {
$userSession = \OC::$server->getUserSession();
$user = $userSession->getUser();
if ($user !== null) {
- $view = \OC\Files\Filesystem::getView();
+ $view = Filesystem::getView();
$config = \OCP\Server::get(IConfig::class);
$this->server->addPlugin(
new FilesPlugin(
@@ -280,7 +295,7 @@ public function __construct(IRequest $request, string $baseUri) {
// TODO: switch to LazyUserFolder
$userFolder = \OC::$server->getUserFolder();
- $shareManager = \OCP\Server::get(\OCP\Share\IManager::class);
+ $shareManager = \OCP\Server::get(IManager::class);
$this->server->addPlugin(new SharesPlugin(
$this->server->tree,
$userSession,
@@ -293,14 +308,14 @@ public function __construct(IRequest $request, string $baseUri) {
));
if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
$this->server->addPlugin(new IMipPlugin(
- \OC::$server->get(\OCP\IConfig::class),
- \OC::$server->get(\OCP\Mail\IMailer::class),
+ \OC::$server->get(IConfig::class),
+ \OC::$server->get(IMailer::class),
\OC::$server->get(LoggerInterface::class),
- \OC::$server->get(\OCP\AppFramework\Utility\ITimeFactory::class),
- \OC::$server->get(\OCP\Defaults::class),
+ \OC::$server->get(ITimeFactory::class),
+ \OC::$server->get(Defaults::class),
$userSession,
- \OC::$server->get(\OCA\DAV\CalDAV\Schedule\IMipService::class),
- \OC::$server->get(\OCA\DAV\CalDAV\EventComparisonService::class),
+ \OC::$server->get(IMipService::class),
+ \OC::$server->get(EventComparisonService::class),
\OC::$server->get(\OCP\Mail\Provider\IManager::class)
));
}
@@ -317,7 +332,7 @@ public function __construct(IRequest $request, string $baseUri) {
$userFolder,
\OC::$server->getAppManager()
));
- $lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend(
+ $lazySearchBackend->setBackend(new FileSearchBackend(
$this->server->tree,
$user,
\OC::$server->getRootFolder(),
@@ -332,7 +347,7 @@ public function __construct(IRequest $request, string $baseUri) {
)
);
}
- $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin(
+ $this->server->addPlugin(new EnablePlugin(
\OC::$server->getConfig(),
\OC::$server->query(BirthdayService::class),
$user
diff --git a/apps/dav/lib/Settings/AvailabilitySettings.php b/apps/dav/lib/Settings/AvailabilitySettings.php
index 6afb03bda8ddd..e36755c254e65 100644
--- a/apps/dav/lib/Settings/AvailabilitySettings.php
+++ b/apps/dav/lib/Settings/AvailabilitySettings.php
@@ -14,6 +14,7 @@
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
+use OCP\DB\Exception;
use OCP\IConfig;
use OCP\Settings\ISettings;
use OCP\User\IAvailabilityCoordinator;
@@ -56,7 +57,7 @@ public function getForm(): TemplateResponse {
} catch (DoesNotExistException) {
// The user has not yet set up an absence period.
// Logging this error is not necessary.
- } catch (\OCP\DB\Exception $e) {
+ } catch (Exception $e) {
$this->logger->error("Could not find absence data for user $this->userId: " . $e->getMessage(), [
'exception' => $e,
]);
diff --git a/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php b/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php
index 85000aba6d37b..21e999d34be98 100644
--- a/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php
@@ -10,6 +10,7 @@
use OCA\DAV\BackgroundJob\CleanupInvitationTokenJob;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\DB\QueryBuilder\IExpressionBuilder;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use Test\TestCase;
@@ -21,7 +22,7 @@ class CleanupInvitationTokenJobTest extends TestCase {
/** @var ITimeFactory | \PHPUnit\Framework\MockObject\MockObject */
private $timeFactory;
- /** @var \OCA\DAV\BackgroundJob\CleanupInvitationTokenJob */
+ /** @var CleanupInvitationTokenJob */
private $backgroundJob;
protected function setUp(): void {
@@ -41,7 +42,7 @@ public function testRun(): void {
->willReturn(1337);
$queryBuilder = $this->createMock(IQueryBuilder::class);
- $expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class);
+ $expr = $this->createMock(IExpressionBuilder::class);
$stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class);
$this->dbConnection->expects($this->once())
diff --git a/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php b/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php
index 4874e79b9a256..82d2251f17ab7 100644
--- a/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php
@@ -26,7 +26,7 @@ class GenerateBirthdayCalendarBackgroundJobTest extends TestCase {
/** @var IConfig | MockObject */
private $config;
- /** @var \OCA\DAV\BackgroundJob\GenerateBirthdayCalendarBackgroundJob */
+ /** @var GenerateBirthdayCalendarBackgroundJob */
private $backgroundJob;
protected function setUp(): void {
diff --git a/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php b/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php
index 89ef73ec134c5..f895deb7fd1d9 100644
--- a/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php
@@ -27,7 +27,7 @@ class EnablePluginTest extends TestCase {
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
protected $user;
- /** @var \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin $plugin */
+ /** @var EnablePlugin $plugin */
protected $plugin;
protected $request;
diff --git a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
index 4333754222bad..aee90f6b8d0cf 100644
--- a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
+++ b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
@@ -9,6 +9,7 @@
use OCA\DAV\CalDAV\Calendar;
use OCA\DAV\CalDAV\PublicCalendar;
use OCA\DAV\CalDAV\PublicCalendarRoot;
+use OCA\DAV\CalDAV\Sharing\Backend;
use OCA\DAV\Connector\Sabre\Principal;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
@@ -59,7 +60,7 @@ protected function setUp(): void {
$this->logger = $this->createMock(LoggerInterface::class);
$dispatcher = $this->createMock(IEventDispatcher::class);
$config = $this->createMock(IConfig::class);
- $sharingBackend = $this->createMock(\OCA\DAV\CalDAV\Sharing\Backend::class);
+ $sharingBackend = $this->createMock(Backend::class);
$this->principal->expects($this->any())->method('getGroupMembership')
->withAnyParameters()
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
index 708581f9b6df5..42eb0b0faa323 100644
--- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
+++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
@@ -14,6 +14,7 @@
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
use OCP\Mail\IMessage;
+use OCP\Util;
use PHPUnit\Framework\MockObject\MockObject;
use Sabre\VObject\Component\VCalendar;
@@ -350,7 +351,7 @@ private function getMessageMock(string $toMail, IEMailTemplate $templateMock, ?a
$message->expects($this->once())
->method('setFrom')
- ->with([\OCP\Util::getDefaultEmailAddress('reminders-noreply')])
+ ->with([Util::getDefaultEmailAddress('reminders-noreply')])
->willReturn($message);
if ($replyTo) {
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php
index 98d49552b0207..bdb318ee32f54 100644
--- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php
+++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php
@@ -36,7 +36,7 @@ protected function setUp(): void {
* @throws NotificationTypeDoesNotExistException
*/
public function testGetProviderForUnknownType(): void {
- $this->expectException(\OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException::class);
+ $this->expectException(NotificationTypeDoesNotExistException::class);
$this->expectExceptionMessage('Type NOT EXISTENT is not an accepted type of notification');
$this->providerManager->getProvider('NOT EXISTENT');
@@ -47,7 +47,7 @@ public function testGetProviderForUnknownType(): void {
* @throws ProviderNotAvailableException
*/
public function testGetProviderForUnRegisteredType(): void {
- $this->expectException(\OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException::class);
+ $this->expectException(ProviderNotAvailableException::class);
$this->expectExceptionMessage('No notification provider for type AUDIO available');
$this->providerManager->getProvider('AUDIO');
diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php
index ed39129fa56b4..b2fd9cfb93f18 100644
--- a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php
@@ -7,6 +7,8 @@
use OCA\DAV\CalDAV\Proxy\Proxy;
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
+use OCA\DAV\CalDAV\ResourceBooking\ResourcePrincipalBackend;
+use OCA\DAV\CalDAV\ResourceBooking\RoomPrincipalBackend;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
@@ -15,7 +17,7 @@
use Test\TestCase;
abstract class AbstractPrincipalBackendTest extends TestCase {
- /** @var \OCA\DAV\CalDAV\ResourceBooking\ResourcePrincipalBackend|\OCA\DAV\CalDAV\ResourceBooking\RoomPrincipalBackend */
+ /** @var ResourcePrincipalBackend|RoomPrincipalBackend */
protected $principalBackend;
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
diff --git a/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php b/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php
index ae4519e2542ac..0da971dc36b24 100644
--- a/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php
@@ -14,7 +14,7 @@
class SearchPluginTest extends TestCase {
protected $server;
- /** @var \OCA\DAV\CalDAV\Search\SearchPlugin $plugin */
+ /** @var SearchPlugin $plugin */
protected $plugin;
protected function setUp(): void {
diff --git a/apps/dav/tests/unit/Command/ListCalendarsTest.php b/apps/dav/tests/unit/Command/ListCalendarsTest.php
index 2640b4d966bcb..c034bb086edcd 100644
--- a/apps/dav/tests/unit/Command/ListCalendarsTest.php
+++ b/apps/dav/tests/unit/Command/ListCalendarsTest.php
@@ -8,6 +8,7 @@
use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\Command\ListCalendars;
+use OCA\DAV\DAV\Sharing\Plugin;
use OCP\IUserManager;
use Symfony\Component\Console\Tester\CommandTester;
use Test\TestCase;
@@ -99,11 +100,11 @@ public function testWithCorrectUser(bool $readOnly, string $output): void {
'uri' => BirthdayService::BIRTHDAY_CALENDAR_URI,
],
[
- '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => $readOnly,
+ '{' . Plugin::NS_OWNCLOUD . '}read-only' => $readOnly,
'uri' => 'test',
'{DAV:}displayname' => 'dp',
- '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => 'owner-principal',
- '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname' => 'owner-dp',
+ '{' . Plugin::NS_OWNCLOUD . '}owner-principal' => 'owner-principal',
+ '{' . Plugin::NS_NEXTCLOUD . '}owner-displayname' => 'owner-dp',
]
]);
diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php
index 0d4adae250ed9..6996022b607dd 100644
--- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php
@@ -7,9 +7,11 @@
*/
namespace OCA\DAV\Tests\unit\Comments;
+use OCA\DAV\Comments\CommentNode;
use OCA\DAV\Comments\EntityCollection;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
+use OCP\Comments\NotFoundException;
use OCP\IUserManager;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
@@ -43,7 +45,7 @@ protected function setUp(): void {
->disableOriginalConstructor()
->getMock();
- $this->collection = new \OCA\DAV\Comments\EntityCollection(
+ $this->collection = new EntityCollection(
'19',
'files',
$this->commentsManager,
@@ -68,7 +70,7 @@ public function testGetChild(): void {
);
$node = $this->collection->getChild('55');
- $this->assertTrue($node instanceof \OCA\DAV\Comments\CommentNode);
+ $this->assertTrue($node instanceof CommentNode);
}
@@ -78,7 +80,7 @@ public function testGetChildException(): void {
$this->commentsManager->expects($this->once())
->method('get')
->with('55')
- ->will($this->throwException(new \OCP\Comments\NotFoundException()));
+ ->will($this->throwException(new NotFoundException()));
$this->collection->getChild('55');
}
@@ -96,7 +98,7 @@ public function testGetChildren(): void {
$result = $this->collection->getChildren();
$this->assertSame(count($result), 1);
- $this->assertTrue($result[0] instanceof \OCA\DAV\Comments\CommentNode);
+ $this->assertTrue($result[0] instanceof CommentNode);
}
public function testFindChildren(): void {
@@ -113,7 +115,7 @@ public function testFindChildren(): void {
$result = $this->collection->findChildren(5, 15, $dt);
$this->assertSame(count($result), 1);
- $this->assertTrue($result[0] instanceof \OCA\DAV\Comments\CommentNode);
+ $this->assertTrue($result[0] instanceof CommentNode);
}
public function testChildExistsTrue(): void {
@@ -124,7 +126,7 @@ public function testChildExistsFalse(): void {
$this->commentsManager->expects($this->once())
->method('get')
->with('44')
- ->will($this->throwException(new \OCP\Comments\NotFoundException()));
+ ->will($this->throwException(new NotFoundException()));
$this->assertFalse($this->collection->childExists('44'));
}
diff --git a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
index 5ab9c38ecd088..15b8073481cbc 100644
--- a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
@@ -8,6 +8,7 @@
namespace OCA\DAV\Tests\unit\Comments;
use OCA\DAV\Comments\EntityCollection as EntityCollectionImplemantation;
+use OCA\DAV\Comments\EntityTypeCollection;
use OCP\Comments\ICommentsManager;
use OCP\IUserManager;
use OCP\IUserSession;
@@ -21,7 +22,7 @@ class EntityTypeCollectionTest extends \Test\TestCase {
protected $userManager;
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $logger;
- /** @var \OCA\DAV\Comments\EntityTypeCollection */
+ /** @var EntityTypeCollection */
protected $collection;
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
protected $userSession;
@@ -46,7 +47,7 @@ protected function setUp(): void {
$instance = $this;
- $this->collection = new \OCA\DAV\Comments\EntityTypeCollection(
+ $this->collection = new EntityTypeCollection(
'files',
$this->commentsManager,
$this->userManager,
diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php
index 6da96be5818a5..8f58e5c3c5f07 100644
--- a/apps/dav/tests/unit/Comments/RootCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php
@@ -9,6 +9,7 @@
use OC\EventDispatcher\EventDispatcher;
use OCA\DAV\Comments\EntityTypeCollection as EntityTypeCollectionImplementation;
+use OCA\DAV\Comments\RootCollection;
use OCP\Comments\CommentsEntityEvent;
use OCP\Comments\ICommentsManager;
use OCP\EventDispatcher\IEventDispatcher;
@@ -25,7 +26,7 @@ class RootCollectionTest extends \Test\TestCase {
protected $userManager;
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $logger;
- /** @var \OCA\DAV\Comments\RootCollection */
+ /** @var RootCollection */
protected $collection;
/** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject */
protected $userSession;
@@ -59,7 +60,7 @@ protected function setUp(): void {
$this->logger
);
- $this->collection = new \OCA\DAV\Comments\RootCollection(
+ $this->collection = new RootCollection(
$this->commentsManager,
$this->userManager,
$this->userSession,
diff --git a/apps/dav/tests/unit/Connector/LegacyPublicAuthTest.php b/apps/dav/tests/unit/Connector/LegacyPublicAuthTest.php
index 4f3581d607180..2bb683741627e 100644
--- a/apps/dav/tests/unit/Connector/LegacyPublicAuthTest.php
+++ b/apps/dav/tests/unit/Connector/LegacyPublicAuthTest.php
@@ -7,6 +7,7 @@
*/
namespace OCA\DAV\Tests\unit\Connector;
+use OCA\DAV\Connector\LegacyPublicAuth;
use OCP\IRequest;
use OCP\ISession;
use OCP\Security\Bruteforce\IThrottler;
@@ -29,7 +30,7 @@ class LegacyPublicAuthTest extends \Test\TestCase {
private $request;
/** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
private $shareManager;
- /** @var \OCA\DAV\Connector\LegacyPublicAuth */
+ /** @var LegacyPublicAuth */
private $auth;
/** @var IThrottler|\PHPUnit\Framework\MockObject\MockObject */
private $throttler;
@@ -53,7 +54,7 @@ protected function setUp(): void {
->disableOriginalConstructor()
->getMock();
- $this->auth = new \OCA\DAV\Connector\LegacyPublicAuth(
+ $this->auth = new LegacyPublicAuth(
$this->request,
$this->shareManager,
$this->session,
diff --git a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
index de258c9aaec5e..c6d247b395167 100644
--- a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
@@ -7,8 +7,11 @@
*/
namespace OCA\DAV\Tests\unit\Connector\Sabre;
+use OC\Authentication\Exceptions\PasswordLoginForbiddenException;
use OC\Authentication\TwoFactorAuth\Manager;
use OC\User\Session;
+use OCA\DAV\Connector\Sabre\Auth;
+use OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden;
use OCP\IRequest;
use OCP\ISession;
use OCP\IUser;
@@ -28,7 +31,7 @@
class AuthTest extends TestCase {
/** @var ISession&MockObject */
private $session;
- /** @var \OCA\DAV\Connector\Sabre\Auth */
+ /** @var Auth */
private $auth;
/** @var Session&MockObject */
private $userSession;
@@ -53,7 +56,7 @@ protected function setUp(): void {
$this->throttler = $this->getMockBuilder(IThrottler::class)
->disableOriginalConstructor()
->getMock();
- $this->auth = new \OCA\DAV\Connector\Sabre\Auth(
+ $this->auth = new Auth(
$this->session,
$this->userSession,
$this->request,
@@ -201,7 +204,7 @@ public function testValidateUserPassWithInvalidPassword(): void {
public function testValidateUserPassWithPasswordLoginForbidden(): void {
- $this->expectException(\OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden::class);
+ $this->expectException(PasswordLoginForbidden::class);
$this->userSession
->expects($this->once())
@@ -211,7 +214,7 @@ public function testValidateUserPassWithPasswordLoginForbidden(): void {
->expects($this->once())
->method('logClientIn')
->with('MyTestUser', 'MyTestPassword')
- ->will($this->throwException(new \OC\Authentication\Exceptions\PasswordLoginForbiddenException()));
+ ->will($this->throwException(new PasswordLoginForbiddenException()));
$this->session
->expects($this->once())
->method('close');
diff --git a/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php b/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php
index 9922dee5e6eff..06c070454af8b 100644
--- a/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php
@@ -5,6 +5,7 @@
*/
namespace OCA\DAV\Tests\unit\Connector\Sabre;
+use OC\User\Session;
use OCA\DAV\Connector\Sabre\BearerAuth;
use OCP\IRequest;
use OCP\ISession;
@@ -30,7 +31,7 @@ class BearerAuthTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->userSession = $this->createMock(\OC\User\Session::class);
+ $this->userSession = $this->createMock(Session::class);
$this->session = $this->createMock(ISession::class);
$this->request = $this->createMock(IRequest::class);
diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
index 7da38afdf3ad1..3f134745f8692 100644
--- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
@@ -10,6 +10,7 @@
use OCA\DAV\CalDAV\DefaultCalendarValidator;
use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\File;
+use OCA\DAV\DAV\CustomPropertiesBackend;
use OCP\IUser;
use PHPUnit\Framework\MockObject\MockObject;
use Sabre\DAV\Tree;
@@ -34,7 +35,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
private $tree;
/**
- * @var \OCA\DAV\DAV\CustomPropertiesBackend
+ * @var CustomPropertiesBackend
*/
private $plugin;
@@ -64,7 +65,7 @@ protected function setUp(): void {
$this->defaultCalendarValidator = $this->createMock(DefaultCalendarValidator::class);
- $this->plugin = new \OCA\DAV\DAV\CustomPropertiesBackend(
+ $this->plugin = new CustomPropertiesBackend(
$this->server,
$this->tree,
\OC::$server->getDatabaseConnection(),
diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
index fb180b7c65d72..bc74ede4777dc 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
@@ -13,12 +13,16 @@
use OC\Files\Storage\Wrapper\Quota;
use OC\Files\View;
use OCA\DAV\Connector\Sabre\Directory;
+use OCA\DAV\Connector\Sabre\Exception\Forbidden;
+use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
use OCP\Constants;
use OCP\Files\ForbiddenException;
+use OCP\Files\InvalidPathException;
use OCP\Files\Mount\IMountPoint;
+use OCP\Files\StorageNotAvailableException;
use Test\Traits\UserTrait;
-class TestViewDirectory extends \OC\Files\View {
+class TestViewDirectory extends View {
private $updatables;
private $deletables;
private $canRename;
@@ -106,7 +110,7 @@ public function testDeleteRootFolderFails(): void {
public function testDeleteForbidden(): void {
- $this->expectException(\OCA\DAV\Connector\Sabre\Exception\Forbidden::class);
+ $this->expectException(Forbidden::class);
// deletion allowed
$this->info->expects($this->once())
@@ -250,7 +254,7 @@ public function testGetChildThrowStorageNotAvailableException(): void {
$this->view->expects($this->once())
->method('getFileInfo')
- ->willThrowException(new \OCP\Files\StorageNotAvailableException());
+ ->willThrowException(new StorageNotAvailableException());
$dir = new Directory($this->view, $this->info);
$dir->getChild('.');
@@ -258,11 +262,11 @@ public function testGetChildThrowStorageNotAvailableException(): void {
public function testGetChildThrowInvalidPath(): void {
- $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class);
+ $this->expectException(InvalidPath::class);
$this->view->expects($this->once())
->method('verifyPath')
- ->willThrowException(new \OCP\Files\InvalidPathException());
+ ->willThrowException(new InvalidPathException());
$this->view->expects($this->never())
->method('getFileInfo');
@@ -390,7 +394,7 @@ public function testMoveSuccess($source, $destination, $updatables, $deletables)
* @dataProvider moveFailedInvalidCharsProvider
*/
public function testMoveFailedInvalidChars($source, $destination, $updatables, $deletables): void {
- $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class);
+ $this->expectException(InvalidPath::class);
$this->moveTest($source, $destination, $updatables, $deletables);
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php
index 55a6783225d8e..ef02f14537533 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php
@@ -13,16 +13,29 @@
use OC\Files\Storage\Temporary;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OC\Files\View;
+use OCA\DAV\Connector\Sabre\Exception\FileLocked;
+use OCA\DAV\Connector\Sabre\Exception\Forbidden;
+use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
use OCA\DAV\Connector\Sabre\File;
use OCP\Constants;
+use OCP\Encryption\Exceptions\GenericEncryptionException;
+use OCP\Files\EntityTooLargeException;
use OCP\Files\FileInfo;
use OCP\Files\ForbiddenException;
+use OCP\Files\InvalidContentException;
+use OCP\Files\InvalidPathException;
+use OCP\Files\LockNotAcquiredException;
+use OCP\Files\NotPermittedException;
use OCP\Files\Storage\IStorage;
+use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use OCP\IRequestId;
use OCP\ITempManager;
use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
+use OCP\Lock\LockedException;
+use OCP\Server;
+use OCP\Util;
use PHPUnit\Framework\MockObject\MockObject;
use Test\HookHelper;
use Test\TestCase;
@@ -66,7 +79,7 @@ protected function setUp(): void {
}
protected function tearDown(): void {
- $userManager = \OCP\Server::get(IUserManager::class);
+ $userManager = Server::get(IUserManager::class);
$userManager->get($this->user)->delete();
parent::tearDown();
@@ -98,39 +111,39 @@ public function fopenFailuresProvider() {
false
],
[
- new \OCP\Files\NotPermittedException(),
+ new NotPermittedException(),
'Sabre\DAV\Exception\Forbidden'
],
[
- new \OCP\Files\EntityTooLargeException(),
+ new EntityTooLargeException(),
'OCA\DAV\Connector\Sabre\Exception\EntityTooLarge'
],
[
- new \OCP\Files\InvalidContentException(),
+ new InvalidContentException(),
'OCA\DAV\Connector\Sabre\Exception\UnsupportedMediaType'
],
[
- new \OCP\Files\InvalidPathException(),
+ new InvalidPathException(),
'Sabre\DAV\Exception\Forbidden'
],
[
- new \OCP\Files\ForbiddenException('', true),
+ new ForbiddenException('', true),
'OCA\DAV\Connector\Sabre\Exception\Forbidden'
],
[
- new \OCP\Files\LockNotAcquiredException('/test.txt', 1),
+ new LockNotAcquiredException('/test.txt', 1),
'OCA\DAV\Connector\Sabre\Exception\FileLocked'
],
[
- new \OCP\Lock\LockedException('/test.txt'),
+ new LockedException('/test.txt'),
'OCA\DAV\Connector\Sabre\Exception\FileLocked'
],
[
- new \OCP\Encryption\Exceptions\GenericEncryptionException(),
+ new GenericEncryptionException(),
'Sabre\DAV\Exception\ServiceUnavailable'
],
[
- new \OCP\Files\StorageNotAvailableException(),
+ new StorageNotAvailableException(),
'Sabre\DAV\Exception\ServiceUnavailable'
],
[
@@ -152,9 +165,9 @@ public function testSimplePutFails($thrownException, $expectedException, $checkP
// setup
$storage = $this->getMockBuilder(Local::class)
->onlyMethods(['writeStream'])
- ->setConstructorArgs([['datadir' => \OCP\Server::get(ITempManager::class)->getTemporaryFolder()]])
+ ->setConstructorArgs([['datadir' => Server::get(ITempManager::class)->getTemporaryFolder()]])
->getMock();
- \OC\Files\Filesystem::mount($storage, [], $this->user . '/');
+ Filesystem::mount($storage, [], $this->user . '/');
/** @var View | MockObject $view */
$view = $this->getMockBuilder(View::class)
->onlyMethods(['getRelativePath', 'resolvePath'])
@@ -182,11 +195,11 @@ function ($path) use ($storage) {
->willReturnArgument(0);
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
// action
$caughtException = null;
@@ -214,9 +227,9 @@ function ($path) use ($storage) {
* @return null|string of the PUT operation which is usually the etag
*/
private function doPut($path, $viewRoot = null, ?Request $request = null) {
- $view = \OC\Files\Filesystem::getView();
+ $view = Filesystem::getView();
if (!is_null($viewRoot)) {
- $view = new \OC\Files\View($viewRoot);
+ $view = new View($viewRoot);
} else {
$viewRoot = '/' . $this->user . '/files';
}
@@ -226,14 +239,14 @@ private function doPut($path, $viewRoot = null, ?Request $request = null) {
$this->getMockStorage(),
null,
[
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
],
null
);
- /** @var \OCA\DAV\Connector\Sabre\File | MockObject $file */
- $file = $this->getMockBuilder(\OCA\DAV\Connector\Sabre\File::class)
+ /** @var File|MockObject $file */
+ $file = $this->getMockBuilder(File::class)
->setConstructorArgs([$view, $info, null, $request])
->onlyMethods(['header'])
->getMock();
@@ -367,7 +380,7 @@ public function testPutSingleFileTriggersHooks(): void {
* Test that putting a file triggers update hooks
*/
public function testPutOverwriteFileTriggersHooks(): void {
- $view = \OC\Files\Filesystem::getView();
+ $view = Filesystem::getView();
$view->file_put_contents('/foo.txt', 'some content that will be replaced');
HookHelper::setUpHooks();
@@ -403,7 +416,7 @@ public function testPutOverwriteFileTriggersHooks(): void {
* where the root is the share root)
*/
public function testPutSingleFileTriggersHooksDifferentRoot(): void {
- $view = \OC\Files\Filesystem::getView();
+ $view = Filesystem::getView();
$view->mkdir('noderoot');
HookHelper::setUpHooks();
@@ -445,7 +458,7 @@ public static function cancellingHook($params): void {
* Test put file with cancelled hook
*/
public function testPutSingleFileCancelPreHook(): void {
- \OCP\Util::connectHook(
+ Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_create,
'\Test\HookHelper',
@@ -493,11 +506,11 @@ public function testSimplePutFailsSizeCheck(): void {
], $this->requestId, $this->config, null);
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info, null, $request);
+ $file = new File($view, $info, null, $request);
// action
$thrown = false;
@@ -521,17 +534,17 @@ public function testSimplePutFailsSizeCheck(): void {
* Test exception during final rename in simple upload mode
*/
public function testSimplePutFailsMoveFromStorage(): void {
- $view = new \OC\Files\View('/' . $this->user . '/files');
+ $view = new View('/' . $this->user . '/files');
// simulate situation where the target file is locked
$view->lockFile('/test.txt', ILockingProvider::LOCK_EXCLUSIVE);
$info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
// action
$thrown = false;
@@ -543,7 +556,7 @@ public function testSimplePutFailsMoveFromStorage(): void {
// afterMethod unlocks
$view->unlockFile($info->getPath(), ILockingProvider::LOCK_SHARED);
- } catch (\OCA\DAV\Connector\Sabre\Exception\FileLocked $e) {
+ } catch (FileLocked $e) {
$thrown = true;
}
@@ -565,10 +578,10 @@ public function testSimplePutInvalidChars(): void {
->willReturnArgument(0);
$info = new \OC\Files\FileInfo("/i\nvalid", $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
// action
$thrown = false;
@@ -580,7 +593,7 @@ public function testSimplePutInvalidChars(): void {
// afterMethod unlocks
$view->unlockFile($info->getPath(), ILockingProvider::LOCK_SHARED);
- } catch (\OCA\DAV\Connector\Sabre\Exception\InvalidPath $e) {
+ } catch (InvalidPath $e) {
$thrown = true;
}
@@ -593,7 +606,7 @@ public function testSimplePutInvalidChars(): void {
*
*/
public function testSetNameInvalidChars(): void {
- $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class);
+ $this->expectException(InvalidPath::class);
// setup
/** @var View|MockObject */
@@ -606,10 +619,10 @@ public function testSetNameInvalidChars(): void {
->willReturnArgument(0);
$info = new \OC\Files\FileInfo('/valid', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
$file->setName("/i\nvalid");
}
@@ -640,11 +653,11 @@ public function testUploadAbort(): void {
], $this->requestId, $this->config, null);
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info, null, $request);
+ $file = new File($view, $info, null, $request);
// action
$thrown = false;
@@ -676,11 +689,11 @@ public function testDeleteWhenAllowed(): void {
->willReturn(true);
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
// action
$file->delete();
@@ -700,7 +713,7 @@ public function testDeleteThrowsWhenDeletionNotAllowed(): void {
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
// action
$file->delete();
@@ -721,11 +734,11 @@ public function testDeleteThrowsWhenDeletionFailed(): void {
->willReturn(false);
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
// action
$file->delete();
@@ -733,7 +746,7 @@ public function testDeleteThrowsWhenDeletionFailed(): void {
public function testDeleteThrowsWhenDeletionThrows(): void {
- $this->expectException(\OCA\DAV\Connector\Sabre\Exception\Forbidden::class);
+ $this->expectException(Forbidden::class);
// setup
/** @var View|MockObject */
@@ -746,11 +759,11 @@ public function testDeleteThrowsWhenDeletionThrows(): void {
->willThrowException(new ForbiddenException('', true));
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
// action
$file->delete();
@@ -776,7 +789,7 @@ protected function assertHookCall($callData, $signal, $hookPath) {
* Test whether locks are set before and after the operation
*/
public function testPutLocking(): void {
- $view = new \OC\Files\View('/' . $this->user . '/files/');
+ $view = new View('/' . $this->user . '/files/');
$path = 'test-locking.txt';
$info = new \OC\Files\FileInfo(
@@ -784,20 +797,20 @@ public function testPutLocking(): void {
$this->getMockStorage(),
null,
[
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
],
null
);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
$this->assertFalse(
- $this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_SHARED),
+ $this->isFileLocked($view, $path, ILockingProvider::LOCK_SHARED),
'File unlocked before put'
);
$this->assertFalse(
- $this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE),
+ $this->isFileLocked($view, $path, ILockingProvider::LOCK_EXCLUSIVE),
'File unlocked before put'
);
@@ -813,26 +826,26 @@ public function testPutLocking(): void {
->method('writeCallback')
->willReturnCallback(
function () use ($view, $path, &$wasLockedPre): void {
- $wasLockedPre = $this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_SHARED);
- $wasLockedPre = $wasLockedPre && !$this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE);
+ $wasLockedPre = $this->isFileLocked($view, $path, ILockingProvider::LOCK_SHARED);
+ $wasLockedPre = $wasLockedPre && !$this->isFileLocked($view, $path, ILockingProvider::LOCK_EXCLUSIVE);
}
);
$eventHandler->expects($this->once())
->method('postWriteCallback')
->willReturnCallback(
function () use ($view, $path, &$wasLockedPost): void {
- $wasLockedPost = $this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_SHARED);
- $wasLockedPost = $wasLockedPost && !$this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE);
+ $wasLockedPost = $this->isFileLocked($view, $path, ILockingProvider::LOCK_SHARED);
+ $wasLockedPost = $wasLockedPost && !$this->isFileLocked($view, $path, ILockingProvider::LOCK_EXCLUSIVE);
}
);
- \OCP\Util::connectHook(
+ Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_write,
$eventHandler,
'writeCallback'
);
- \OCP\Util::connectHook(
+ Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_post_write,
$eventHandler,
@@ -851,11 +864,11 @@ function () use ($view, $path, &$wasLockedPost): void {
$this->assertTrue($wasLockedPost, 'File was locked during post-hooks');
$this->assertFalse(
- $this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_SHARED),
+ $this->isFileLocked($view, $path, ILockingProvider::LOCK_SHARED),
'File unlocked after put'
);
$this->assertFalse(
- $this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE),
+ $this->isFileLocked($view, $path, ILockingProvider::LOCK_EXCLUSIVE),
'File unlocked after put'
);
}
@@ -868,9 +881,9 @@ function () use ($view, $path, &$wasLockedPost): void {
*
* @return array list of part files
*/
- private function listPartFiles(?\OC\Files\View $userView = null, $path = '') {
+ private function listPartFiles(?View $userView = null, $path = '') {
if ($userView === null) {
- $userView = \OC\Files\Filesystem::getView();
+ $userView = Filesystem::getView();
}
$files = [];
[$storage, $internalPath] = $userView->resolvePath($path);
@@ -919,18 +932,18 @@ public function testGetFopenFails(): void {
->willReturn(false);
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FILE,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
$file->get();
}
public function testGetFopenThrows(): void {
- $this->expectException(\OCA\DAV\Connector\Sabre\Exception\Forbidden::class);
+ $this->expectException(Forbidden::class);
/** @var View|MockObject */
$view = $this->getMockBuilder(View::class)
@@ -941,11 +954,11 @@ public function testGetFopenThrows(): void {
->willThrowException(new ForbiddenException('', true));
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FILE,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
$file->get();
}
@@ -962,11 +975,11 @@ public function testGetThrowsIfNoPermission(): void {
->method('fopen');
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
- 'permissions' => \OCP\Constants::PERMISSION_CREATE, // no read perm
+ 'permissions' => Constants::PERMISSION_CREATE, // no read perm
'type' => FileInfo::TYPE_FOLDER,
], null);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
$file->get();
}
@@ -1003,7 +1016,7 @@ public function testSimplePutNoCreatePermissions(): void {
}
public function testPutLockExpired(): void {
- $view = new \OC\Files\View('/' . $this->user . '/files/');
+ $view = new View('/' . $this->user . '/files/');
$path = 'test-locking.txt';
$info = new \OC\Files\FileInfo(
@@ -1011,13 +1024,13 @@ public function testPutLockExpired(): void {
$this->getMockStorage(),
null,
[
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
],
null
);
- $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $file = new File($view, $info);
// don't lock before the PUT to simulate an expired shared lock
$this->assertNotEmpty($file->put($this->getStream('test data')));
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
index 9d8f4e8d4c4f7..db07165ebf086 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
@@ -123,7 +123,7 @@ private function createTestNode($class, $path = '/dummypath') {
}
public function testGetPropertiesForFile(): void {
- /** @var \OCA\DAV\Connector\Sabre\File | \PHPUnit\Framework\MockObject\MockObject $node */
+ /** @var File|\PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File');
$propFind = new PropFind(
@@ -180,7 +180,7 @@ public function testGetPropertiesForFile(): void {
}
public function testGetPropertiesStorageNotAvailable(): void {
- /** @var \OCA\DAV\Connector\Sabre\File | \PHPUnit\Framework\MockObject\MockObject $node */
+ /** @var File|\PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File');
$propFind = new PropFind(
@@ -227,7 +227,7 @@ public function testGetPublicPermissions(): void {
0
);
- /** @var \OCA\DAV\Connector\Sabre\File | \PHPUnit\Framework\MockObject\MockObject $node */
+ /** @var File|\PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File');
$node->expects($this->any())
->method('getDavPermissions')
@@ -242,7 +242,7 @@ public function testGetPublicPermissions(): void {
}
public function testGetPropertiesForDirectory(): void {
- /** @var \OCA\DAV\Connector\Sabre\Directory | \PHPUnit\Framework\MockObject\MockObject $node */
+ /** @var Directory|\PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\Directory');
$propFind = new PropFind(
@@ -277,7 +277,7 @@ public function testGetPropertiesForDirectory(): void {
}
public function testGetPropertiesForRootDirectory(): void {
- /** @var \OCA\DAV\Connector\Sabre\Directory|\PHPUnit\Framework\MockObject\MockObject $node */
+ /** @var Directory|\PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->getMockBuilder(Directory::class)
->disableOriginalConstructor()
->getMock();
@@ -312,8 +312,7 @@ public function testGetPropertiesWhenNoPermission(): void {
// No read permissions can be caused by files access control.
// But we still want to load the directory list, so this is okay for us.
// $this->expectException(\Sabre\DAV\Exception\NotFound::class);
-
- /** @var \OCA\DAV\Connector\Sabre\Directory|\PHPUnit\Framework\MockObject\MockObject $node */
+ /** @var Directory|\PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->getMockBuilder(Directory::class)
->disableOriginalConstructor()
->getMock();
@@ -614,7 +613,7 @@ public function testDownloadHeaders($isClumsyAgent, $contentDispositionHeader):
}
public function testHasPreview(): void {
- /** @var \OCA\DAV\Connector\Sabre\Directory | \PHPUnit\Framework\MockObject\MockObject $node */
+ /** @var Directory|\PHPUnit\Framework\MockObject\MockObject $node */
$node = $this->createTestNode('\OCA\DAV\Connector\Sabre\Directory');
$propFind = new PropFind(
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
index 76a70a93e1313..8b169dcd46fe7 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
@@ -9,6 +9,7 @@
use OC\Files\View;
use OCA\DAV\Connector\Sabre\Directory;
+use OCA\DAV\Connector\Sabre\FilesPlugin;
use OCA\DAV\Connector\Sabre\FilesReportPlugin as FilesReportPluginImplementation;
use OCP\App\IAppManager;
use OCP\Files\File;
@@ -289,7 +290,7 @@ public function testFindNodesByFileIdsRoot(): void {
$filesNode2,
);
- /** @var \OCA\DAV\Connector\Sabre\Directory&MockObject $reportTargetNode */
+ /** @var Directory&MockObject $reportTargetNode */
$result = $this->plugin->findNodesByFileIds($reportTargetNode, ['111', '222']);
$this->assertCount(2, $result);
@@ -342,7 +343,7 @@ public function testFindNodesByFileIdsSubDir(): void {
$filesNode2,
);
- /** @var \OCA\DAV\Connector\Sabre\Directory&MockObject $reportTargetNode */
+ /** @var Directory&MockObject $reportTargetNode */
$result = $this->plugin->findNodesByFileIds($reportTargetNode, ['111', '222']);
$this->assertCount(2, $result);
@@ -390,7 +391,7 @@ public function testPrepareResponses(): void {
$validator = $this->createMock(IFilenameValidator::class);
$this->server->addPlugin(
- new \OCA\DAV\Connector\Sabre\FilesPlugin(
+ new FilesPlugin(
$this->tree,
$config,
$this->createMock(IRequest::class),
diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
index c5e2b03d8b481..04cd60fbdaa01 100644
--- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
@@ -13,6 +13,7 @@
use OC\Files\Node\Folder;
use OC\Files\View;
use OC\Share20\ShareAttributes;
+use OCA\DAV\Connector\Sabre\File;
use OCA\Files_Sharing\SharedMount;
use OCA\Files_Sharing\SharedStorage;
use OCP\Constants;
@@ -97,7 +98,7 @@ public function testDavPermissions($permissions, $type, $shared, $shareRootPermi
->disableOriginalConstructor()
->getMock();
- $node = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $node = new File($view, $info);
$this->assertEquals($expected, $node->getDavPermissions());
}
@@ -180,7 +181,7 @@ public function testSharePermissions($type, $user, $permissions, $expected): voi
->disableOriginalConstructor()
->getMock();
- $node = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $node = new File($view, $info);
$this->invokePrivate($node, 'shareManager', [$shareManager]);
$this->assertEquals($expected, $node->getSharePermissions($user));
}
@@ -217,7 +218,7 @@ public function testShareAttributes(): void {
->disableOriginalConstructor()
->getMock();
- $node = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $node = new File($view, $info);
$this->invokePrivate($node, 'shareManager', [$shareManager]);
$this->assertEquals($attributes->toArray(), $node->getShareAttributes());
}
@@ -243,7 +244,7 @@ public function testShareAttributesNonShare(): void {
->disableOriginalConstructor()
->getMock();
- $node = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $node = new File($view, $info);
$this->invokePrivate($node, 'shareManager', [$shareManager]);
$this->assertEquals([], $node->getShareAttributes());
}
@@ -266,7 +267,7 @@ public function testSanitizeMtime($mtime, $expected): void {
->disableOriginalConstructor()
->getMock();
- $node = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $node = new File($view, $info);
$result = $this->invokePrivate($node, 'sanitizeMtime', [$mtime]);
$this->assertEquals($expected, $result);
}
@@ -290,7 +291,7 @@ public function testInvalidSanitizeMtime($mtime): void {
->disableOriginalConstructor()
->getMock();
- $node = new \OCA\DAV\Connector\Sabre\File($view, $info);
+ $node = new File($view, $info);
$result = $this->invokePrivate($node, 'sanitizeMtime', [$mtime]);
}
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
index 4f2e5174325db..393f3c72c205b 100644
--- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
@@ -10,9 +10,12 @@
use OC\Files\FileInfo;
use OC\Files\Filesystem;
use OC\Files\Mount\Manager;
+use OC\Files\Storage\Common;
use OC\Files\Storage\Temporary;
use OC\Files\View;
use OCA\DAV\Connector\Sabre\Directory;
+use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
+use OCA\DAV\Connector\Sabre\File;
use OCA\DAV\Connector\Sabre\ObjectTree;
use OCP\Files\Mount\IMountManager;
@@ -73,7 +76,7 @@ public function testCopy($sourcePath, $targetPath, $targetParent): void {
->with($this->identicalTo($sourcePath))
->willReturn(false);
- /** @var \OCA\DAV\Connector\Sabre\ObjectTree $objectTree */
+ /** @var ObjectTree $objectTree */
$mountManager = Filesystem::getMountManager();
$objectTree->init($rootDir, $view, $mountManager);
$objectTree->copy($sourcePath, $targetPath);
@@ -114,7 +117,7 @@ public function testCopyFailNotCreatable($sourcePath, $targetPath, $targetParent
$objectTree->expects($this->never())
->method('getNodeForPath');
- /** @var \OCA\DAV\Connector\Sabre\ObjectTree $objectTree */
+ /** @var ObjectTree $objectTree */
$mountManager = Filesystem::getMountManager();
$objectTree->init($rootDir, $view, $mountManager);
$objectTree->copy($sourcePath, $targetPath);
@@ -146,13 +149,13 @@ public function testGetNodeForPath(
$fileInfo->method('getName')
->willReturn($outputFileName);
$fileInfo->method('getStorage')
- ->willReturn($this->createMock(\OC\Files\Storage\Common::class));
+ ->willReturn($this->createMock(Common::class));
$view->method('getFileInfo')
->with($fileInfoQueryPath)
->willReturn($fileInfo);
- $tree = new \OCA\DAV\Connector\Sabre\ObjectTree();
+ $tree = new ObjectTree();
$tree->init($rootNode, $view, $mountManager);
$node = $tree->getNodeForPath($inputFileName);
@@ -161,9 +164,9 @@ public function testGetNodeForPath(
$this->assertEquals($outputFileName, $node->getName());
if ($type === 'file') {
- $this->assertTrue($node instanceof \OCA\DAV\Connector\Sabre\File);
+ $this->assertTrue($node instanceof File);
} else {
- $this->assertTrue($node instanceof \OCA\DAV\Connector\Sabre\Directory);
+ $this->assertTrue($node instanceof Directory);
}
}
@@ -202,7 +205,7 @@ public function nodeForPathProvider() {
public function testGetNodeForPathInvalidPath(): void {
- $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class);
+ $this->expectException(InvalidPath::class);
$path = '/foo\bar';
@@ -223,7 +226,7 @@ public function testGetNodeForPathInvalidPath(): void {
->getMock();
$mountManager = $this->createMock(IMountManager::class);
- $tree = new \OCA\DAV\Connector\Sabre\ObjectTree();
+ $tree = new ObjectTree();
$tree->init($rootNode, $view, $mountManager);
$tree->getNodeForPath($path);
@@ -249,7 +252,7 @@ public function testGetNodeForPathRoot(): void {
->getMock();
$mountManager = $this->createMock(IMountManager::class);
- $tree = new \OCA\DAV\Connector\Sabre\ObjectTree();
+ $tree = new ObjectTree();
$tree->init($rootNode, $view, $mountManager);
$this->assertInstanceOf('\Sabre\DAV\INode', $tree->getNodeForPath($path));
diff --git a/apps/dav/tests/unit/Connector/Sabre/PublicAuthTest.php b/apps/dav/tests/unit/Connector/Sabre/PublicAuthTest.php
index b6c91cd7ae505..00bddf2e69cd4 100644
--- a/apps/dav/tests/unit/Connector/Sabre/PublicAuthTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/PublicAuthTest.php
@@ -7,6 +7,7 @@
*/
namespace OCA\DAV\Tests\unit\Connector;
+use OCA\DAV\Connector\Sabre\PublicAuth;
use OCP\IRequest;
use OCP\ISession;
use OCP\Security\Bruteforce\IThrottler;
@@ -49,7 +50,7 @@ protected function setUp(): void {
$this->throttler = $this->createMock(IThrottler::class);
$this->logger = $this->createMock(LoggerInterface::class);
- $this->auth = new \OCA\DAV\Connector\Sabre\PublicAuth(
+ $this->auth = new PublicAuth(
$this->request,
$this->shareManager,
$this->session,
diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
index 815837799fd24..c370e0fb0f762 100644
--- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
@@ -16,7 +16,7 @@ class QuotaPluginTest extends TestCase {
/** @var \Sabre\DAV\Server | \PHPUnit\Framework\MockObject\MockObject */
private $server;
- /** @var \OCA\DAV\Connector\Sabre\QuotaPlugin | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var QuotaPlugin|\PHPUnit\Framework\MockObject\MockObject */
private $plugin;
private function init($quota, $checkedPath = ''): void {
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/ExceptionPlugin.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/ExceptionPlugin.php
index 9b20b2f86304a..b1e68f9597b22 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/ExceptionPlugin.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/ExceptionPlugin.php
@@ -7,7 +7,9 @@
*/
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
-class ExceptionPlugin extends \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin {
+use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
+
+class ExceptionPlugin extends ExceptionLoggerPlugin {
/**
* @var \Throwable[]
*/
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
index 29574d53bca25..67c2aa61430a8 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
@@ -25,7 +25,7 @@ abstract class RequestTestCase extends TestCase {
use MountProviderTrait;
/**
- * @var \OCA\DAV\Connector\Sabre\ServerFactory
+ * @var ServerFactory
*/
protected $serverFactory;
diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
index 546be840cd8f9..125fe3959bbde 100644
--- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
@@ -10,6 +10,7 @@
use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\File;
use OCA\DAV\Connector\Sabre\Node;
+use OCA\DAV\Connector\Sabre\SharesPlugin;
use OCA\DAV\Upload\UploadFile;
use OCP\Files\Folder;
use OCP\IUser;
@@ -19,7 +20,7 @@
use Sabre\DAV\Tree;
class SharesPluginTest extends \Test\TestCase {
- public const SHARETYPES_PROPERTYNAME = \OCA\DAV\Connector\Sabre\SharesPlugin::SHARETYPES_PROPERTYNAME;
+ public const SHARETYPES_PROPERTYNAME = SharesPlugin::SHARETYPES_PROPERTYNAME;
/**
* @var \Sabre\DAV\Server
@@ -42,7 +43,7 @@ class SharesPluginTest extends \Test\TestCase {
private $userFolder;
/**
- * @var \OCA\DAV\Connector\Sabre\SharesPlugin
+ * @var SharesPlugin
*/
private $plugin;
@@ -61,7 +62,7 @@ protected function setUp(): void {
->willReturn($user);
$this->userFolder = $this->createMock(Folder::class);
- $this->plugin = new \OCA\DAV\Connector\Sabre\SharesPlugin(
+ $this->plugin = new SharesPlugin(
$this->tree,
$userSession,
$this->userFolder,
diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
index 635f62dac8733..59fd1e569634a 100644
--- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
@@ -10,15 +10,17 @@
use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\File;
use OCA\DAV\Connector\Sabre\Node;
+use OCA\DAV\Connector\Sabre\TagList;
+use OCA\DAV\Connector\Sabre\TagsPlugin;
use OCA\DAV\Upload\UploadFile;
use OCP\ITagManager;
use OCP\ITags;
use Sabre\DAV\Tree;
class TagsPluginTest extends \Test\TestCase {
- public const TAGS_PROPERTYNAME = \OCA\DAV\Connector\Sabre\TagsPlugin::TAGS_PROPERTYNAME;
- public const FAVORITE_PROPERTYNAME = \OCA\DAV\Connector\Sabre\TagsPlugin::FAVORITE_PROPERTYNAME;
- public const TAG_FAVORITE = \OCA\DAV\Connector\Sabre\TagsPlugin::TAG_FAVORITE;
+ public const TAGS_PROPERTYNAME = TagsPlugin::TAGS_PROPERTYNAME;
+ public const FAVORITE_PROPERTYNAME = TagsPlugin::FAVORITE_PROPERTYNAME;
+ public const TAG_FAVORITE = TagsPlugin::TAG_FAVORITE;
/**
* @var \Sabre\DAV\Server
@@ -41,7 +43,7 @@ class TagsPluginTest extends \Test\TestCase {
private $tagger;
/**
- * @var \OCA\DAV\Connector\Sabre\TagsPlugin
+ * @var TagsPlugin
*/
private $plugin;
@@ -61,7 +63,7 @@ protected function setUp(): void {
->method('load')
->with('files')
->willReturn($this->tagger);
- $this->plugin = new \OCA\DAV\Connector\Sabre\TagsPlugin($this->tree, $this->tagManager);
+ $this->plugin = new TagsPlugin($this->tree, $this->tagManager);
$this->plugin->initialize($this->server);
}
@@ -194,7 +196,7 @@ public function tagsGetPropertiesDataProvider() {
[self::TAGS_PROPERTYNAME, self::FAVORITE_PROPERTYNAME],
[
200 => [
- self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2']),
+ self::TAGS_PROPERTYNAME => new TagList(['tag1', 'tag2']),
self::FAVORITE_PROPERTYNAME => true,
]
]
@@ -205,7 +207,7 @@ public function tagsGetPropertiesDataProvider() {
[self::TAGS_PROPERTYNAME],
[
200 => [
- self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2']),
+ self::TAGS_PROPERTYNAME => new TagList(['tag1', 'tag2']),
]
]
],
@@ -233,7 +235,7 @@ public function tagsGetPropertiesDataProvider() {
[self::TAGS_PROPERTYNAME, self::FAVORITE_PROPERTYNAME],
[
200 => [
- self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList([]),
+ self::TAGS_PROPERTYNAME => new TagList([]),
self::FAVORITE_PROPERTYNAME => false,
]
]
@@ -296,7 +298,7 @@ public function testUpdateTags(): void {
// properties to set
$propPatch = new \Sabre\DAV\PropPatch([
- self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2', 'tagkeep'])
+ self::TAGS_PROPERTYNAME => new TagList(['tag1', 'tag2', 'tagkeep'])
]);
$this->plugin->handleUpdateProperties(
@@ -342,7 +344,7 @@ public function testUpdateTagsFromScratch(): void {
// properties to set
$propPatch = new \Sabre\DAV\PropPatch([
- self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2'])
+ self::TAGS_PROPERTYNAME => new TagList(['tag1', 'tag2'])
]);
$this->plugin->handleUpdateProperties(
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
index 308950cef341f..ed830685b7a8a 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
@@ -8,6 +8,7 @@
namespace OCA\DAV\Tests\unit\SystemTag;
use OC\SystemTag\SystemTag;
+use OCA\DAV\SystemTag\SystemTagMappingNode;
use OCP\IUser;
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
@@ -34,7 +35,7 @@ public function getMappingNode($tag = null, array $writableNodeIds = []) {
if ($tag === null) {
$tag = new SystemTag(1, 'Test', true, true);
}
- return new \OCA\DAV\SystemTag\SystemTagMappingNode(
+ return new SystemTagMappingNode(
$tag,
123,
'files',
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
index 82aa81674dfa2..7ad1d34d94fc3 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
@@ -8,6 +8,7 @@
namespace OCA\DAV\Tests\unit\SystemTag;
use OC\SystemTag\SystemTag;
+use OCA\DAV\SystemTag\SystemTagNode;
use OCP\IUser;
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
@@ -40,7 +41,7 @@ protected function getTagNode($isAdmin = true, $tag = null) {
if ($tag === null) {
$tag = new SystemTag(1, 'Test', true, true);
}
- return new \OCA\DAV\SystemTag\SystemTagNode(
+ return new SystemTagNode(
$tag,
$this->user,
$isAdmin,
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php
index 67e7afa9c548a..91dab4ecf1138 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php
@@ -9,6 +9,7 @@
use OC\SystemTag\SystemTag;
use OCA\DAV\SystemTag\SystemTagNode;
+use OCA\DAV\SystemTag\SystemTagPlugin;
use OCA\DAV\SystemTag\SystemTagsByIdCollection;
use OCA\DAV\SystemTag\SystemTagsObjectMappingCollection;
use OCP\IGroupManager;
@@ -23,12 +24,12 @@
use Sabre\HTTP\ResponseInterface;
class SystemTagPluginTest extends \Test\TestCase {
- public const ID_PROPERTYNAME = \OCA\DAV\SystemTag\SystemTagPlugin::ID_PROPERTYNAME;
- public const DISPLAYNAME_PROPERTYNAME = \OCA\DAV\SystemTag\SystemTagPlugin::DISPLAYNAME_PROPERTYNAME;
- public const USERVISIBLE_PROPERTYNAME = \OCA\DAV\SystemTag\SystemTagPlugin::USERVISIBLE_PROPERTYNAME;
- public const USERASSIGNABLE_PROPERTYNAME = \OCA\DAV\SystemTag\SystemTagPlugin::USERASSIGNABLE_PROPERTYNAME;
- public const CANASSIGN_PROPERTYNAME = \OCA\DAV\SystemTag\SystemTagPlugin::CANASSIGN_PROPERTYNAME;
- public const GROUPS_PROPERTYNAME = \OCA\DAV\SystemTag\SystemTagPlugin::GROUPS_PROPERTYNAME;
+ public const ID_PROPERTYNAME = SystemTagPlugin::ID_PROPERTYNAME;
+ public const DISPLAYNAME_PROPERTYNAME = SystemTagPlugin::DISPLAYNAME_PROPERTYNAME;
+ public const USERVISIBLE_PROPERTYNAME = SystemTagPlugin::USERVISIBLE_PROPERTYNAME;
+ public const USERASSIGNABLE_PROPERTYNAME = SystemTagPlugin::USERASSIGNABLE_PROPERTYNAME;
+ public const CANASSIGN_PROPERTYNAME = SystemTagPlugin::CANASSIGN_PROPERTYNAME;
+ public const GROUPS_PROPERTYNAME = SystemTagPlugin::GROUPS_PROPERTYNAME;
/**
* @var \Sabre\DAV\Server
@@ -61,7 +62,7 @@ class SystemTagPluginTest extends \Test\TestCase {
private $user;
/**
- * @var \OCA\DAV\SystemTag\SystemTagPlugin
+ * @var SystemTagPlugin
*/
private $plugin;
@@ -97,7 +98,7 @@ protected function setUp(): void {
$this->tagMapper = $this->getMockBuilder(ISystemTagObjectMapper::class)
->getMock();
- $this->plugin = new \OCA\DAV\SystemTag\SystemTagPlugin(
+ $this->plugin = new SystemTagPlugin(
$this->tagManager,
$this->groupManager,
$this->userSession,
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php
index db55d82adc98a..2ffbc1cf01fda 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php
@@ -8,6 +8,7 @@
namespace OCA\DAV\Tests\unit\SystemTag;
use OC\SystemTag\SystemTag;
+use OCA\DAV\SystemTag\SystemTagsByIdCollection;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
@@ -50,7 +51,7 @@ public function getNode($isAdmin = true) {
->method('isAdmin')
->with('testuser')
->willReturn($isAdmin);
- return new \OCA\DAV\SystemTag\SystemTagsByIdCollection(
+ return new SystemTagsByIdCollection(
$this->tagManager,
$userSession,
$groupManager
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php
index c2e62f73828f8..66052847f162d 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php
@@ -8,6 +8,7 @@
namespace OCA\DAV\Tests\unit\SystemTag;
use OC\SystemTag\SystemTag;
+use OCA\DAV\SystemTag\SystemTagsObjectMappingCollection;
use OCP\IUser;
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
@@ -31,7 +32,7 @@ protected function setUp(): void {
}
public function getNode(array $writableNodeIds = []) {
- return new \OCA\DAV\SystemTag\SystemTagsObjectMappingCollection(
+ return new SystemTagsObjectMappingCollection(
111,
'files',
$this->user,
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php
index b202f340e328f..62f6963e2025d 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php
@@ -7,7 +7,9 @@
*/
namespace OCA\DAV\Tests\unit\SystemTag;
+use OCA\DAV\SystemTag\SystemTagsObjectTypeCollection;
use OCP\Files\Folder;
+use OCP\Files\Node;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
@@ -17,7 +19,7 @@
class SystemTagsObjectTypeCollectionTest extends \Test\TestCase {
/**
- * @var \OCA\DAV\SystemTag\SystemTagsObjectTypeCollection
+ * @var SystemTagsObjectTypeCollection
*/
private $node;
@@ -79,7 +81,7 @@ protected function setUp(): void {
return false;
};
- $this->node = new \OCA\DAV\SystemTag\SystemTagsObjectTypeCollection(
+ $this->node = new SystemTagsObjectTypeCollection(
'files',
$this->tagManager,
$this->tagMapper,
@@ -108,7 +110,7 @@ public function testGetChild(): void {
$this->userFolder->expects($this->once())
->method('getFirstNodeById')
->with('555')
- ->willReturn($this->createMock(\OCP\Files\Node::class));
+ ->willReturn($this->createMock(Node::class));
$childNode = $this->node->getChild('555');
$this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection', $childNode);
@@ -137,7 +139,7 @@ public function testChildExists(): void {
$this->userFolder->expects($this->once())
->method('getFirstNodeById')
->with('123')
- ->willReturn($this->createMock(\OCP\Files\Node::class));
+ ->willReturn($this->createMock(Node::class));
$this->assertTrue($this->node->childExists('123'));
}
diff --git a/apps/dav/tests/unit/Upload/AssemblyStreamTest.php b/apps/dav/tests/unit/Upload/AssemblyStreamTest.php
index a8517bf757c78..51c53fb262f25 100644
--- a/apps/dav/tests/unit/Upload/AssemblyStreamTest.php
+++ b/apps/dav/tests/unit/Upload/AssemblyStreamTest.php
@@ -7,6 +7,7 @@
*/
namespace OCA\DAV\Tests\unit\Upload;
+use OCA\DAV\Upload\AssemblyStream;
use Sabre\DAV\File;
class AssemblyStreamTest extends \Test\TestCase {
@@ -15,7 +16,7 @@ class AssemblyStreamTest extends \Test\TestCase {
* @dataProvider providesNodes()
*/
public function testGetContents($expected, $nodes): void {
- $stream = \OCA\DAV\Upload\AssemblyStream::wrap($nodes);
+ $stream = AssemblyStream::wrap($nodes);
$content = stream_get_contents($stream);
$this->assertEquals($expected, $content);
@@ -25,7 +26,7 @@ public function testGetContents($expected, $nodes): void {
* @dataProvider providesNodes()
*/
public function testGetContentsFread($expected, $nodes): void {
- $stream = \OCA\DAV\Upload\AssemblyStream::wrap($nodes);
+ $stream = AssemblyStream::wrap($nodes);
$content = '';
while (!feof($stream)) {
@@ -39,7 +40,7 @@ public function testGetContentsFread($expected, $nodes): void {
* @dataProvider providesNodes()
*/
public function testSeek($expected, $nodes): void {
- $stream = \OCA\DAV\Upload\AssemblyStream::wrap($nodes);
+ $stream = AssemblyStream::wrap($nodes);
$offset = floor(strlen($expected) * 0.6);
if (fseek($stream, $offset) === -1) {
diff --git a/apps/dav/tests/unit/Upload/FutureFileTest.php b/apps/dav/tests/unit/Upload/FutureFileTest.php
index 9ec455a959503..750670992eb87 100644
--- a/apps/dav/tests/unit/Upload/FutureFileTest.php
+++ b/apps/dav/tests/unit/Upload/FutureFileTest.php
@@ -8,6 +8,7 @@
namespace OCA\DAV\Tests\unit\Upload;
use OCA\DAV\Connector\Sabre\Directory;
+use OCA\DAV\Upload\FutureFile;
class FutureFileTest extends \Test\TestCase {
public function testGetContentType(): void {
@@ -50,7 +51,7 @@ public function testDelete(): void {
$d->expects($this->once())
->method('delete');
- $f = new \OCA\DAV\Upload\FutureFile($d, 'foo.txt');
+ $f = new FutureFile($d, 'foo.txt');
$f->delete();
}
@@ -71,7 +72,7 @@ public function testSetName(): void {
}
/**
- * @return \OCA\DAV\Upload\FutureFile
+ * @return FutureFile
*/
private function mockFutureFile() {
$d = $this->getMockBuilder(Directory::class)
@@ -91,6 +92,6 @@ private function mockFutureFile() {
->method('getChildren')
->willReturn([]);
- return new \OCA\DAV\Upload\FutureFile($d, 'foo.txt');
+ return new FutureFile($d, 'foo.txt');
}
}
diff --git a/apps/encryption/lib/AppInfo/Application.php b/apps/encryption/lib/AppInfo/Application.php
index d683c82286ac7..05032535d5035 100644
--- a/apps/encryption/lib/AppInfo/Application.php
+++ b/apps/encryption/lib/AppInfo/Application.php
@@ -7,6 +7,7 @@
*/
namespace OCA\Encryption\AppInfo;
+use OC\Encryption\Manager;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Crypto\DecryptAll;
use OCA\Encryption\Crypto\EncryptAll;
@@ -40,7 +41,7 @@ public function boot(IBootContext $context): void {
\OCP\Util::addScript(self::APP_ID, 'encryption');
$context->injectFn(function (IManager $encryptionManager) use ($context): void {
- if (!($encryptionManager instanceof \OC\Encryption\Manager)) {
+ if (!($encryptionManager instanceof Manager)) {
return;
}
diff --git a/apps/encryption/lib/Crypto/DecryptAll.php b/apps/encryption/lib/Crypto/DecryptAll.php
index e153712fb9959..ea5671f9ec9c5 100644
--- a/apps/encryption/lib/Crypto/DecryptAll.php
+++ b/apps/encryption/lib/Crypto/DecryptAll.php
@@ -7,6 +7,7 @@
*/
namespace OCA\Encryption\Crypto;
+use OCA\Encryption\Exceptions\PrivateKeyMissingException;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Session;
use OCA\Encryption\Util;
@@ -118,7 +119,7 @@ public function prepare(InputInterface $input, OutputInterface $output, $user) {
* @param string $user
* @param string $password
* @return bool|string
- * @throws \OCA\Encryption\Exceptions\PrivateKeyMissingException
+ * @throws PrivateKeyMissingException
*/
protected function getPrivateKey($user, $password) {
$recoveryKeyId = $this->keyManager->getRecoveryKeyId();
diff --git a/apps/encryption/lib/Crypto/Encryption.php b/apps/encryption/lib/Crypto/Encryption.php
index f5b6a40aecc18..18639308ea46f 100644
--- a/apps/encryption/lib/Crypto/Encryption.php
+++ b/apps/encryption/lib/Crypto/Encryption.php
@@ -10,6 +10,7 @@
use OC\Encryption\Exceptions\DecryptionFailedException;
use OC\Files\Cache\Scanner;
use OC\Files\View;
+use OCA\Encryption\Exceptions\MultiKeyEncryptException;
use OCA\Encryption\Exceptions\PublicKeyMissingException;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Session;
@@ -187,7 +188,7 @@ public function begin($path, $user, $mode, array $header, array $accessList) {
* of a write operation
* @throws PublicKeyMissingException
* @throws \Exception
- * @throws \OCA\Encryption\Exceptions\MultiKeyEncryptException
+ * @throws MultiKeyEncryptException
*/
public function end($path, $position = '0') {
$result = '';
diff --git a/apps/encryption/lib/Hooks/UserHooks.php b/apps/encryption/lib/Hooks/UserHooks.php
index 2424370e47f56..3d4485d01abb7 100644
--- a/apps/encryption/lib/Hooks/UserHooks.php
+++ b/apps/encryption/lib/Hooks/UserHooks.php
@@ -94,7 +94,7 @@ public function addHooks() {
*/
public function login($params) {
// ensure filesystem is loaded
- if (!\OC\Files\Filesystem::$loaded) {
+ if (!Filesystem::$loaded) {
$this->setupFS($params['uid']);
}
if ($this->util->isMasterKeyEnabled() === false) {
diff --git a/apps/encryption/lib/Session.php b/apps/encryption/lib/Session.php
index e16396e8fafab..4b759618eb273 100644
--- a/apps/encryption/lib/Session.php
+++ b/apps/encryption/lib/Session.php
@@ -68,7 +68,7 @@ public function isReady() {
public function getPrivateKey() {
$key = $this->session->get('privateKey');
if (is_null($key)) {
- throw new Exceptions\PrivateKeyMissingException('please try to log-out and log-in again', 0);
+ throw new PrivateKeyMissingException('please try to log-out and log-in again', 0);
}
return $key;
}
diff --git a/apps/encryption/tests/Controller/RecoveryControllerTest.php b/apps/encryption/tests/Controller/RecoveryControllerTest.php
index 8398a22039be4..57015975cfc37 100644
--- a/apps/encryption/tests/Controller/RecoveryControllerTest.php
+++ b/apps/encryption/tests/Controller/RecoveryControllerTest.php
@@ -24,7 +24,7 @@ class RecoveryControllerTest extends TestCase {
private $configMock;
/** @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject */
private $l10nMock;
- /** @var \OCA\Encryption\Recovery|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Recovery|\PHPUnit\Framework\MockObject\MockObject */
private $recoveryMock;
public function adminRecoveryProvider() {
diff --git a/apps/encryption/tests/Controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php
index dcad23cd759aa..830536dc8358d 100644
--- a/apps/encryption/tests/Controller/SettingsControllerTest.php
+++ b/apps/encryption/tests/Controller/SettingsControllerTest.php
@@ -39,13 +39,13 @@ class SettingsControllerTest extends TestCase {
/** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject */
private $userSessionMock;
- /** @var \OCA\Encryption\KeyManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var KeyManager|\PHPUnit\Framework\MockObject\MockObject */
private $keyManagerMock;
- /** @var \OCA\Encryption\Crypto\Crypt|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Crypt|\PHPUnit\Framework\MockObject\MockObject */
private $cryptMock;
- /** @var \OCA\Encryption\Session|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Session|\PHPUnit\Framework\MockObject\MockObject */
private $sessionMock;
/** @var MockObject|IUser */
private $user;
@@ -53,7 +53,7 @@ class SettingsControllerTest extends TestCase {
/** @var \OCP\ISession|\PHPUnit\Framework\MockObject\MockObject */
private $ocSessionMock;
- /** @var \OCA\Encryption\Util|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Util|\PHPUnit\Framework\MockObject\MockObject */
private $utilMock;
protected function setUp(): void {
diff --git a/apps/encryption/tests/Controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php
index c88b0497abfa4..e52aaba30c10a 100644
--- a/apps/encryption/tests/Controller/StatusControllerTest.php
+++ b/apps/encryption/tests/Controller/StatusControllerTest.php
@@ -22,7 +22,7 @@ class StatusControllerTest extends TestCase {
/** @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject */
private $l10nMock;
- /** @var \OCA\Encryption\Session | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var Session|\PHPUnit\Framework\MockObject\MockObject */
protected $sessionMock;
/** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php
index a9869af99d96c..20c9b863aeca8 100644
--- a/apps/encryption/tests/Crypto/CryptTest.php
+++ b/apps/encryption/tests/Crypto/CryptTest.php
@@ -8,6 +8,7 @@
namespace OCA\Encryption\Tests\Crypto;
use OCA\Encryption\Crypto\Crypt;
+use OCP\Encryption\Exceptions\GenericEncryptionException;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUserSession;
@@ -233,7 +234,7 @@ public function dataTestHasSignature() {
* @dataProvider dataTestHasSignatureFail
*/
public function testHasSignatureFail($cipher): void {
- $this->expectException(\OCP\Encryption\Exceptions\GenericEncryptionException::class);
+ $this->expectException(GenericEncryptionException::class);
$data = 'encryptedContent00iv001234567890123456xx';
$this->invokePrivate($this->crypt, 'hasSignature', [$data, $cipher]);
@@ -378,7 +379,7 @@ public function testDecryptPrivateKey($header, $privateKey, $expectedCipher, $is
['encryption.use_legacy_base64_encoding', false])
->willReturnOnConsecutiveCalls(true, false);
- /** @var \OCA\Encryption\Crypto\Crypt | \PHPUnit\Framework\MockObject\MockObject $crypt */
+ /** @var Crypt|\PHPUnit\Framework\MockObject\MockObject $crypt */
$crypt = $this->getMockBuilder(Crypt::class)
->setConstructorArgs(
[
diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php
index f58ea2119e68c..9de4f6c2c67c8 100644
--- a/apps/encryption/tests/Crypto/EncryptAllTest.php
+++ b/apps/encryption/tests/Crypto/EncryptAllTest.php
@@ -29,16 +29,16 @@
class EncryptAllTest extends TestCase {
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OCA\Encryption\KeyManager */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|KeyManager */
protected $keyManager;
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OCA\Encryption\Util */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|Util */
protected $util;
/** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IUserManager */
protected $userManager;
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OCA\Encryption\Users\Setup */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|Setup */
protected $setupUser;
/** @var \PHPUnit\Framework\MockObject\MockObject | \OC\Files\View */
diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php
index 70c9899cf81b5..2390012a97afc 100644
--- a/apps/encryption/tests/Crypto/EncryptionTest.php
+++ b/apps/encryption/tests/Crypto/EncryptionTest.php
@@ -7,6 +7,8 @@
*/
namespace OCA\Encryption\Tests\Crypto;
+use OC\Encryption\Exceptions\DecryptionFailedException;
+use OC\Files\View;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Crypto\DecryptAll;
use OCA\Encryption\Crypto\EncryptAll;
@@ -27,22 +29,22 @@ class EncryptionTest extends TestCase {
/** @var Encryption */
private $instance;
- /** @var \OCA\Encryption\KeyManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var KeyManager|\PHPUnit\Framework\MockObject\MockObject */
private $keyManagerMock;
- /** @var \OCA\Encryption\Crypto\EncryptAll|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var EncryptAll|\PHPUnit\Framework\MockObject\MockObject */
private $encryptAllMock;
- /** @var \OCA\Encryption\Crypto\DecryptAll|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var DecryptAll|\PHPUnit\Framework\MockObject\MockObject */
private $decryptAllMock;
- /** @var \OCA\Encryption\Session|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Session|\PHPUnit\Framework\MockObject\MockObject */
private $sessionMock;
- /** @var \OCA\Encryption\Crypto\Crypt|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Crypt|\PHPUnit\Framework\MockObject\MockObject */
private $cryptMock;
- /** @var \OCA\Encryption\Util|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Util|\PHPUnit\Framework\MockObject\MockObject */
private $utilMock;
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
@@ -120,7 +122,7 @@ public function testEndUser2(): void {
->method('decryptAllModeActivated')
->willReturn(false);
- $this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class);
+ $this->expectException(PublicKeyMissingException::class);
$this->instance->begin('/foo/bar', 'user2', 'r', [], ['users' => ['user1', 'user2', 'user3']]);
$this->endTest();
@@ -320,7 +322,7 @@ public function testUpdateNoUsers(): void {
->willReturnCallback(function ($path, $version, $view): void {
$this->assertSame('path', $path);
$this->assertSame(2, $version);
- $this->assertTrue($view instanceof \OC\Files\View);
+ $this->assertTrue($view instanceof View);
});
$this->instance->update('path', 'user1', []);
}
@@ -403,7 +405,7 @@ public function dataTestShouldEncrypt() {
public function testDecrypt(): void {
- $this->expectException(\OC\Encryption\Exceptions\DecryptionFailedException::class);
+ $this->expectException(DecryptionFailedException::class);
$this->expectExceptionMessage('Cannot decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.');
$this->instance->decrypt('abc');
diff --git a/apps/encryption/tests/HookManagerTest.php b/apps/encryption/tests/HookManagerTest.php
index ad1fac3407f8c..f831690580f14 100644
--- a/apps/encryption/tests/HookManagerTest.php
+++ b/apps/encryption/tests/HookManagerTest.php
@@ -43,7 +43,7 @@ public static function setUpBeforeClass(): void {
public function testRegisterHooksWithInstance(): void {
$mock = $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock();
- /** @var \OCA\Encryption\Hooks\Contracts\IHook $mock */
+ /** @var IHook $mock */
self::$instance->registerHook($mock);
$hookInstances = self::invokePrivate(self::$instance, 'hookInstances');
diff --git a/apps/encryption/tests/Hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php
index f59a2fd8d01b4..072a20de846d4 100644
--- a/apps/encryption/tests/Hooks/UserHooksTest.php
+++ b/apps/encryption/tests/Hooks/UserHooksTest.php
@@ -305,7 +305,7 @@ public function XtestSetPasswordNoUser() {
]
)->setMethods(['initMountPoints'])->getMock();
- /** @var \OCA\Encryption\Hooks\UserHooks $userHooks */
+ /** @var UserHooks $userHooks */
$this->assertNull($userHooks->setPassphrase($this->params));
}
diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php
index 869e5e2cf96b5..54c1bc2295a88 100644
--- a/apps/encryption/tests/KeyManagerTest.php
+++ b/apps/encryption/tests/KeyManagerTest.php
@@ -10,6 +10,9 @@
use OC\Files\FileInfo;
use OC\Files\View;
use OCA\Encryption\Crypto\Crypt;
+use OCA\Encryption\Crypto\Encryption;
+use OCA\Encryption\Exceptions\PrivateKeyMissingException;
+use OCA\Encryption\Exceptions\PublicKeyMissingException;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Session;
use OCA\Encryption\Util;
@@ -40,19 +43,19 @@ class KeyManagerTest extends TestCase {
/** @var \OCP\Encryption\Keys\IStorage|\PHPUnit\Framework\MockObject\MockObject */
private $keyStorageMock;
- /** @var \OCA\Encryption\Crypto\Crypt|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Crypt|\PHPUnit\Framework\MockObject\MockObject */
private $cryptMock;
/** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject */
private $userMock;
- /** @var \OCA\Encryption\Session|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Session|\PHPUnit\Framework\MockObject\MockObject */
private $sessionMock;
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
private $logMock;
- /** @var \OCA\Encryption\Util|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Util|\PHPUnit\Framework\MockObject\MockObject */
private $utilMock;
/** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */
@@ -207,7 +210,7 @@ public function dataTestUserHasKeys() {
public function testUserHasKeysMissingPrivateKey(): void {
- $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
+ $this->expectException(PrivateKeyMissingException::class);
$this->keyStorageMock->expects($this->exactly(2))
->method('getUserKey')
@@ -223,7 +226,7 @@ public function testUserHasKeysMissingPrivateKey(): void {
public function testUserHasKeysMissingPublicKey(): void {
- $this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class);
+ $this->expectException(PublicKeyMissingException::class);
$this->keyStorageMock->expects($this->exactly(2))
->method('getUserKey')
@@ -243,7 +246,7 @@ public function testUserHasKeysMissingPublicKey(): void {
* @param bool $useMasterKey
*/
public function testInit($useMasterKey): void {
- /** @var \OCA\Encryption\KeyManager|\PHPUnit\Framework\MockObject\MockObject $instance */
+ /** @var KeyManager|\PHPUnit\Framework\MockObject\MockObject $instance */
$instance = $this->getMockBuilder(KeyManager::class)
->setConstructorArgs(
[
@@ -527,7 +530,7 @@ public function testGetMasterKeyId(): void {
public function testGetPublicMasterKey(): void {
$this->keyStorageMock->expects($this->once())->method('getSystemUserKey')
- ->with('systemKeyId.publicKey', \OCA\Encryption\Crypto\Encryption::ID)
+ ->with('systemKeyId.publicKey', Encryption::ID)
->willReturn(true);
$this->assertTrue(
@@ -560,7 +563,7 @@ public function testGetMasterKeyPasswordException(): void {
* @param $masterKey
*/
public function testValidateMasterKey($masterKey): void {
- /** @var \OCA\Encryption\KeyManager | \PHPUnit\Framework\MockObject\MockObject $instance */
+ /** @var KeyManager|\PHPUnit\Framework\MockObject\MockObject $instance */
$instance = $this->getMockBuilder(KeyManager::class)
->setConstructorArgs(
[
@@ -589,7 +592,7 @@ public function testValidateMasterKey($masterKey): void {
$this->cryptMock->expects($this->once())->method('createKeyPair')
->willReturn(['publicKey' => 'public', 'privateKey' => 'private']);
$this->keyStorageMock->expects($this->once())->method('setSystemUserKey')
- ->with('systemKeyId.publicKey', 'public', \OCA\Encryption\Crypto\Encryption::ID);
+ ->with('systemKeyId.publicKey', 'public', Encryption::ID);
$this->cryptMock->expects($this->once())->method('encryptPrivateKey')
->with('private', 'masterKeyPassword', 'systemKeyId')
->willReturn('EncryptedKey');
@@ -608,7 +611,7 @@ public function testValidateMasterKey($masterKey): void {
}
public function testValidateMasterKeyLocked(): void {
- /** @var \OCA\Encryption\KeyManager | \PHPUnit_Framework_MockObject_MockObject $instance */
+ /** @var KeyManager|\PHPUnit_Framework_MockObject_MockObject $instance */
$instance = $this->getMockBuilder(KeyManager::class)
->setConstructorArgs(
[
diff --git a/apps/encryption/tests/RecoveryTest.php b/apps/encryption/tests/RecoveryTest.php
index 4b28d40884469..725e16342e73f 100644
--- a/apps/encryption/tests/RecoveryTest.php
+++ b/apps/encryption/tests/RecoveryTest.php
@@ -37,7 +37,7 @@ class RecoveryTest extends TestCase {
*/
private $user;
/**
- * @var \OCA\Encryption\KeyManager|\PHPUnit\Framework\MockObject\MockObject
+ * @var KeyManager|\PHPUnit\Framework\MockObject\MockObject
*/
private $keyManagerMock;
/**
@@ -45,7 +45,7 @@ class RecoveryTest extends TestCase {
*/
private $configMock;
/**
- * @var \OCA\Encryption\Crypto\Crypt|\PHPUnit\Framework\MockObject\MockObject
+ * @var Crypt|\PHPUnit\Framework\MockObject\MockObject
*/
private $cryptMock;
/**
diff --git a/apps/encryption/tests/SessionTest.php b/apps/encryption/tests/SessionTest.php
index 10c699898fce5..c9486658bcb66 100644
--- a/apps/encryption/tests/SessionTest.php
+++ b/apps/encryption/tests/SessionTest.php
@@ -7,6 +7,7 @@
*/
namespace OCA\Encryption\Tests;
+use OCA\Encryption\Exceptions\PrivateKeyMissingException;
use OCA\Encryption\Session;
use OCP\ISession;
use Test\TestCase;
@@ -22,7 +23,7 @@ class SessionTest extends TestCase {
public function testThatGetPrivateKeyThrowsExceptionWhenNotSet(): void {
- $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
+ $this->expectException(PrivateKeyMissingException::class);
$this->expectExceptionMessage('Private Key missing for user: please try to log-out and log-in again');
$this->instance->getPrivateKey();
@@ -84,7 +85,7 @@ public function testGetDecryptAllUidException2(): void {
* @expectExceptionMessage 'Please activate decrypt all mode first'
*/
public function testGetDecryptAllKeyException(): void {
- $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
+ $this->expectException(PrivateKeyMissingException::class);
$this->instance->getDecryptAllKey();
}
@@ -93,7 +94,7 @@ public function testGetDecryptAllKeyException(): void {
* @expectExceptionMessage 'No key found while in decrypt all mode'
*/
public function testGetDecryptAllKeyException2(): void {
- $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
+ $this->expectException(PrivateKeyMissingException::class);
$this->instance->prepareDecryptAll('user', null);
$this->instance->getDecryptAllKey();
diff --git a/apps/encryption/tests/Users/SetupTest.php b/apps/encryption/tests/Users/SetupTest.php
index 92f24a0627c37..7a6beaf359498 100644
--- a/apps/encryption/tests/Users/SetupTest.php
+++ b/apps/encryption/tests/Users/SetupTest.php
@@ -14,11 +14,11 @@
class SetupTest extends TestCase {
/**
- * @var \OCA\Encryption\KeyManager|\PHPUnit\Framework\MockObject\MockObject
+ * @var KeyManager|\PHPUnit\Framework\MockObject\MockObject
*/
private $keyManagerMock;
/**
- * @var \OCA\Encryption\Crypto\Crypt|\PHPUnit\Framework\MockObject\MockObject
+ * @var Crypt|\PHPUnit\Framework\MockObject\MockObject
*/
private $cryptMock;
/**
diff --git a/apps/encryption/tests/UtilTest.php b/apps/encryption/tests/UtilTest.php
index f2e6f406c3507..5571a9483dbd5 100644
--- a/apps/encryption/tests/UtilTest.php
+++ b/apps/encryption/tests/UtilTest.php
@@ -64,7 +64,7 @@ protected function setUp(): void {
$this->filesMock = $this->createMock(View::class);
$this->userManagerMock = $this->createMock(IUserManager::class);
- /** @var \OCA\Encryption\Crypto\Crypt $cryptMock */
+ /** @var Crypt $cryptMock */
$cryptMock = $this->getMockBuilder(Crypt::class)
->disableOriginalConstructor()
->getMock();
diff --git a/apps/federatedfilesharing/lib/AddressHandler.php b/apps/federatedfilesharing/lib/AddressHandler.php
index d96c956eb1154..a2986618729bd 100644
--- a/apps/federatedfilesharing/lib/AddressHandler.php
+++ b/apps/federatedfilesharing/lib/AddressHandler.php
@@ -11,6 +11,7 @@
use OCP\HintException;
use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\Util;
/**
* Class AddressHandler - parse, modify and construct federated sharing addresses
@@ -86,12 +87,12 @@ public function compareAddresses($user1, $server1, $user2, $server2) {
if (rtrim($normalizedServer1, '/') === rtrim($normalizedServer2, '/')) {
// FIXME this should be a method in the user management instead
- \OCP\Util::emitHook(
+ Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$user1]
);
- \OCP\Util::emitHook(
+ Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$user2]
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
index 8d4f6fd3af857..7ae66c06bddd7 100644
--- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
+++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
@@ -15,6 +15,7 @@
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\Attribute\PublicPage;
+use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCSController;
@@ -29,8 +30,10 @@
use OCP\IRequest;
use OCP\IUserManager;
use OCP\Log\Audit\CriticalActionPerformedEvent;
+use OCP\Server;
use OCP\Share;
use OCP\Share\Exceptions\ShareNotFound;
+use OCP\Share\IManager;
use Psr\Log\LoggerInterface;
#[OpenAPI(scope: OpenAPI::SCOPE_FEDERATION)]
@@ -76,7 +79,7 @@ public function __construct(string $appName,
IRequest $request,
FederatedShareProvider $federatedShareProvider,
IDBConnection $connection,
- Share\IManager $shareManager,
+ IManager $shareManager,
Notifications $notifications,
AddressHandler $addressHandler,
IUserManager $userManager,
@@ -170,7 +173,7 @@ public function createShare(
throw new OCSException('internal server error, was not able to add share from ' . $remote, 500);
}
- return new Http\DataResponse();
+ return new DataResponse();
}
/**
@@ -206,7 +209,7 @@ public function reShare(int $id, ?string $token = null, ?string $shareWith = nul
try {
$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
[$newToken, $localId] = $provider->notificationReceived('REQUEST_RESHARE', $id, $notification);
- return new Http\DataResponse([
+ return new DataResponse([
'token' => $newToken,
'remoteId' => $localId
]);
@@ -254,7 +257,7 @@ public function acceptShare(int $id, ?string $token = null) {
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage(), ['exception' => $e]);
}
- return new Http\DataResponse();
+ return new DataResponse();
}
/**
@@ -287,7 +290,7 @@ public function declineShare(int $id, ?string $token = null) {
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage(), ['exception' => $e]);
}
- return new Http\DataResponse();
+ return new DataResponse();
}
/**
@@ -316,7 +319,7 @@ public function unshare(int $id, ?string $token = null) {
$this->logger->debug('processing unshare notification failed: ' . $e->getMessage(), ['exception' => $e]);
}
- return new Http\DataResponse();
+ return new DataResponse();
}
private function cleanupRemote($remote) {
@@ -343,7 +346,7 @@ public function revoke(int $id, ?string $token = null) {
$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
$notification = ['sharedSecret' => $token];
$provider->notificationReceived('RESHARE_UNDO', $id, $notification);
- return new Http\DataResponse();
+ return new DataResponse();
} catch (\Exception $e) {
throw new OCSBadRequestException();
}
@@ -356,7 +359,7 @@ public function revoke(int $id, ?string $token = null) {
* @return bool
*/
private function isS2SEnabled($incoming = false) {
- $result = \OCP\Server::get(IAppManager::class)->isEnabledForUser('files_sharing');
+ $result = Server::get(IAppManager::class)->isEnabledForUser('files_sharing');
if ($incoming) {
$result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();
@@ -394,7 +397,7 @@ public function updatePermissions(int $id, ?string $token = null, ?int $permissi
throw new OCSBadRequestException();
}
- return new Http\DataResponse();
+ return new DataResponse();
}
/**
@@ -454,7 +457,7 @@ public function move(int $id, ?string $token = null, ?string $remote = null, ?st
$affected = $query->executeStatement();
if ($affected > 0) {
- return new Http\DataResponse(['remote' => $cloudId->getRemote(), 'owner' => $cloudId->getUser()]);
+ return new DataResponse(['remote' => $cloudId->getRemote(), 'owner' => $cloudId->getUser()]);
} else {
throw new OCSBadRequestException('Share not found or token invalid');
}
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index 025a4c7d737f8..f349bb2a6fc36 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -1043,8 +1043,8 @@ public function getAllShares(): iterable {
->from('share')
->where(
$qb->expr()->orX(
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share\IShare::TYPE_REMOTE)),
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share\IShare::TYPE_REMOTE_GROUP))
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE_GROUP))
)
);
diff --git a/apps/federatedfilesharing/lib/Listeners/LoadAdditionalScriptsListener.php b/apps/federatedfilesharing/lib/Listeners/LoadAdditionalScriptsListener.php
index 73f0cd34f3fe3..34fbd85db5ac5 100644
--- a/apps/federatedfilesharing/lib/Listeners/LoadAdditionalScriptsListener.php
+++ b/apps/federatedfilesharing/lib/Listeners/LoadAdditionalScriptsListener.php
@@ -14,6 +14,7 @@
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
+use OCP\Util;
/** @template-implements IEventListener */
class LoadAdditionalScriptsListener implements IEventListener {
@@ -34,7 +35,7 @@ public function handle(Event $event): void {
if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled()) {
$this->initialState->provideInitialState('notificationsEnabled', $this->appManager->isEnabledForUser('notifications'));
- \OCP\Util::addInitScript('federatedfilesharing', 'external');
+ Util::addInitScript('federatedfilesharing', 'external');
}
}
}
diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
index 8aa8ba67a2a31..64e8b0e4fa50b 100644
--- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
+++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
@@ -11,6 +11,7 @@
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Sharing\Activity\Providers\RemoteShares;
use OCA\Files_Sharing\External\Manager;
+use OCA\GlobalSiteSelector\Service\SlaveService;
use OCP\Activity\IManager as IActivityManager;
use OCP\App\IAppManager;
use OCP\Constants;
@@ -734,7 +735,7 @@ public function getUserDisplayName(string $userId): string {
}
try {
- $slaveService = Server::get(\OCA\GlobalSiteSelector\Service\SlaveService::class);
+ $slaveService = Server::get(SlaveService::class);
} catch (\Throwable $e) {
Server::get(LoggerInterface::class)->error(
$e->getMessage(),
diff --git a/apps/federatedfilesharing/tests/AddressHandlerTest.php b/apps/federatedfilesharing/tests/AddressHandlerTest.php
index e235314e00845..ffb34d965ceac 100644
--- a/apps/federatedfilesharing/tests/AddressHandlerTest.php
+++ b/apps/federatedfilesharing/tests/AddressHandlerTest.php
@@ -11,6 +11,7 @@
use OCA\FederatedFileSharing\AddressHandler;
use OCP\Contacts\IManager;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\HintException;
use OCP\ICacheFactory;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -130,7 +131,7 @@ public function dataTestSplitUserRemoteError() {
* @param string $id
*/
public function testSplitUserRemoteError($id): void {
- $this->expectException(\OCP\HintException::class);
+ $this->expectException(HintException::class);
$this->addressHandler->splitUserRemote($id);
}
diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
index 9caafb35bb3ab..8222f25bb49de 100644
--- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
+++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
@@ -7,6 +7,7 @@
namespace OCA\FederatedFileSharing\Tests\Controller;
use OC\Federation\CloudIdManager;
+use OC\Share20\Share;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\Controller\MountPublicLinkController;
use OCA\FederatedFileSharing\FederatedShareProvider;
@@ -83,7 +84,7 @@ protected function setUp(): void {
->disableOriginalConstructor()->getMock();
$this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->disableOriginalConstructor()->getMock();
$this->userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock();
- $this->share = new \OC\Share20\Share($this->rootFolder, $this->userManager);
+ $this->share = new Share($this->rootFolder, $this->userManager);
$this->session = $this->getMockBuilder(ISession::class)->disableOriginalConstructor()->getMock();
$this->l10n = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock();
$this->userSession = $this->getMockBuilder(IUserSession::class)->disableOriginalConstructor()->getMock();
diff --git a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php
index cce1ee8830aa5..01cb198b14dfb 100644
--- a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php
+++ b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php
@@ -7,7 +7,10 @@
*/
namespace OCA\FederatedFileSharing\Tests;
+use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\Controller\RequestHandlerController;
+use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCA\FederatedFileSharing\Notifications;
use OCP\AppFramework\Http\DataResponse;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
@@ -19,6 +22,7 @@
use OCP\IRequest;
use OCP\IUserManager;
use OCP\Share;
+use OCP\Share\IManager;
use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
@@ -39,13 +43,13 @@ class RequestHandlerControllerTest extends \Test\TestCase {
/** @var RequestHandlerController */
private $requestHandler;
- /** @var \OCA\FederatedFileSharing\FederatedShareProvider|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var FederatedShareProvider|\PHPUnit\Framework\MockObject\MockObject */
private $federatedShareProvider;
- /** @var \OCA\FederatedFileSharing\Notifications|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Notifications|\PHPUnit\Framework\MockObject\MockObject */
private $notifications;
- /** @var \OCA\FederatedFileSharing\AddressHandler|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var AddressHandler|\PHPUnit\Framework\MockObject\MockObject */
private $addressHandler;
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
@@ -103,7 +107,7 @@ protected function setUp(): void {
$this->cloudIdManager = $this->createMock(ICloudIdManager::class);
$this->request = $this->createMock(IRequest::class);
$this->connection = $this->createMock(IDBConnection::class);
- $this->shareManager = $this->createMock(Share\IManager::class);
+ $this->shareManager = $this->createMock(IManager::class);
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
$this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class);
$this->cloudFederationProvider = $this->createMock(ICloudFederationProvider::class);
diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
index 5255a84b46115..77e10b7a61a5d 100644
--- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
+++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
@@ -12,6 +12,7 @@
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\FederatedFileSharing\Notifications;
use OCA\FederatedFileSharing\TokenHandler;
+use OCP\Constants;
use OCP\Contacts\IManager as IContactsManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationProviderManager;
@@ -895,7 +896,7 @@ public function testGetSharesInFolder(): void {
$share1->setSharedWith('user@server.com')
->setSharedBy($u1->getUID())
->setShareOwner($u1->getUID())
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setShareType(IShare::TYPE_REMOTE)
->setNode($file1);
$this->provider->create($share1);
@@ -904,7 +905,7 @@ public function testGetSharesInFolder(): void {
$share2->setSharedWith('user@server.com')
->setSharedBy($u2->getUID())
->setShareOwner($u1->getUID())
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setShareType(IShare::TYPE_REMOTE)
->setNode($file2);
$this->provider->create($share2);
@@ -955,7 +956,7 @@ public function testGetAccessList(): void {
$share1->setSharedWith('user@server.com')
->setSharedBy($u1->getUID())
->setShareOwner($u1->getUID())
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setShareType(IShare::TYPE_REMOTE)
->setNode($file1);
$this->provider->create($share1);
@@ -964,7 +965,7 @@ public function testGetAccessList(): void {
$share2->setSharedWith('foobar@localhost')
->setSharedBy($u1->getUID())
->setShareOwner($u1->getUID())
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setShareType(IShare::TYPE_REMOTE)
->setNode($file1);
$this->provider->create($share2);
diff --git a/apps/federatedfilesharing/tests/Settings/AdminTest.php b/apps/federatedfilesharing/tests/Settings/AdminTest.php
index 031d19c2cb8cc..d821eee55b039 100644
--- a/apps/federatedfilesharing/tests/Settings/AdminTest.php
+++ b/apps/federatedfilesharing/tests/Settings/AdminTest.php
@@ -17,7 +17,7 @@
class AdminTest extends TestCase {
/** @var Admin */
private $admin;
- /** @var \OCA\FederatedFileSharing\FederatedShareProvider */
+ /** @var FederatedShareProvider */
private $federatedShareProvider;
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
private $gsConfig;
diff --git a/apps/federatedfilesharing/tests/TestCase.php b/apps/federatedfilesharing/tests/TestCase.php
index 9564cb7ec09b6..a53025c5a6258 100644
--- a/apps/federatedfilesharing/tests/TestCase.php
+++ b/apps/federatedfilesharing/tests/TestCase.php
@@ -90,7 +90,7 @@ protected static function loginHelper($user, $create = false, $password = false)
\OC_Util::tearDownFS();
\OC::$server->getUserSession()->setUser(null);
- \OC\Files\Filesystem::tearDown();
+ Filesystem::tearDown();
\OC::$server->getUserSession()->login($user, $password);
\OC::$server->getUserFolder($user);
diff --git a/apps/federation/lib/DAV/FedAuth.php b/apps/federation/lib/DAV/FedAuth.php
index 7dc63dca2aff8..09e558cb2ea17 100644
--- a/apps/federation/lib/DAV/FedAuth.php
+++ b/apps/federation/lib/DAV/FedAuth.php
@@ -8,6 +8,7 @@
namespace OCA\Federation\DAV;
use OCA\Federation\DbHandler;
+use OCP\Defaults;
use Sabre\DAV\Auth\Backend\AbstractBasic;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
@@ -27,7 +28,7 @@ public function __construct(DbHandler $db) {
$this->principalPrefix = 'principals/system/';
// setup realm
- $defaults = new \OCP\Defaults();
+ $defaults = new Defaults();
$this->realm = $defaults->getName();
}
diff --git a/apps/federation/tests/Controller/SettingsControllerTest.php b/apps/federation/tests/Controller/SettingsControllerTest.php
index 0eb15e40d8fd8..c2156bac3dc94 100644
--- a/apps/federation/tests/Controller/SettingsControllerTest.php
+++ b/apps/federation/tests/Controller/SettingsControllerTest.php
@@ -10,6 +10,7 @@
use OCA\Federation\Controller\SettingsController;
use OCA\Federation\TrustedServers;
use OCP\AppFramework\Http\DataResponse;
+use OCP\HintException;
use OCP\IL10N;
use OCP\IRequest;
use Test\TestCase;
@@ -23,7 +24,7 @@ class SettingsControllerTest extends TestCase {
/** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IL10N */
private $l10n;
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OCA\Federation\TrustedServers */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|TrustedServers */
private $trustedServers;
protected function setUp(): void {
@@ -67,7 +68,7 @@ public function testAddServer(): void {
* @dataProvider checkServerFails
*/
public function testAddServerFail(bool $isTrustedServer, bool $isNextcloud): void {
- $this->expectException(\OCP\HintException::class);
+ $this->expectException(HintException::class);
$this->trustedServers
->expects($this->any())
@@ -113,7 +114,7 @@ public function testCheckServer(): void {
* @dataProvider checkServerFails
*/
public function testCheckServerFail(bool $isTrustedServer, bool $isNextcloud): void {
- $this->expectException(\OCP\HintException::class);
+ $this->expectException(HintException::class);
$this->trustedServers
->expects($this->any())
diff --git a/apps/federation/tests/SyncFederationAddressbooksTest.php b/apps/federation/tests/SyncFederationAddressbooksTest.php
index b78a98b6ae23c..39274a11ade1d 100644
--- a/apps/federation/tests/SyncFederationAddressbooksTest.php
+++ b/apps/federation/tests/SyncFederationAddressbooksTest.php
@@ -8,8 +8,10 @@
namespace OCA\Federation\Tests;
use OC\OCS\DiscoveryService;
+use OCA\DAV\CardDAV\SyncService;
use OCA\Federation\DbHandler;
use OCA\Federation\SyncFederationAddressBooks;
+use OCA\Federation\TrustedServers;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
@@ -55,7 +57,7 @@ public function testSync(): void {
$syncService->expects($this->once())->method('syncRemoteAddressBook')
->willReturn('1');
- /** @var \OCA\DAV\CardDAV\SyncService $syncService */
+ /** @var SyncService $syncService */
$s = new SyncFederationAddressBooks($dbHandler, $syncService, $this->discoveryService, $this->logger);
$s->syncThemAll(function ($url, $ex): void {
$this->callBacks[] = [$url, $ex];
@@ -83,7 +85,7 @@ public function testException(): void {
$syncService->expects($this->once())->method('syncRemoteAddressBook')
->willThrowException(new \Exception('something did not work out'));
- /** @var \OCA\DAV\CardDAV\SyncService $syncService */
+ /** @var SyncService $syncService */
$s = new SyncFederationAddressBooks($dbHandler, $syncService, $this->discoveryService, $this->logger);
$s->syncThemAll(function ($url, $ex): void {
$this->callBacks[] = [$url, $ex];
@@ -105,7 +107,7 @@ public function testSuccessfulSyncWithoutChangesAfterFailure(): void {
'sync_token' => '0'
]
]);
- $dbHandler->method('getServerStatus')->willReturn(\OCA\Federation\TrustedServers::STATUS_FAILURE);
+ $dbHandler->method('getServerStatus')->willReturn(TrustedServers::STATUS_FAILURE);
$dbHandler->expects($this->once())->method('setServerStatus')->
with('https://cloud.drop.box', 1);
$syncService = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService')
@@ -114,7 +116,7 @@ public function testSuccessfulSyncWithoutChangesAfterFailure(): void {
$syncService->expects($this->once())->method('syncRemoteAddressBook')
->willReturn('0');
- /** @var \OCA\DAV\CardDAV\SyncService $syncService */
+ /** @var SyncService $syncService */
$s = new SyncFederationAddressBooks($dbHandler, $syncService, $this->discoveryService, $this->logger);
$s->syncThemAll(function ($url, $ex): void {
$this->callBacks[] = [$url, $ex];
diff --git a/apps/federation/tests/TrustedServersTest.php b/apps/federation/tests/TrustedServersTest.php
index 63ce589903172..c3f0368858bc3 100644
--- a/apps/federation/tests/TrustedServersTest.php
+++ b/apps/federation/tests/TrustedServersTest.php
@@ -12,6 +12,8 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Federation\Events\TrustedServerRemovedEvent;
+use OCP\HintException;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
@@ -145,7 +147,7 @@ public function testRemoveServer(): void {
$this->dispatcher->expects($this->once())->method('dispatchTyped')
->willReturnCallback(
function ($event): void {
- $this->assertSame(get_class($event), \OCP\Federation\Events\TrustedServerRemovedEvent::class);
+ $this->assertSame(get_class($event), TrustedServerRemovedEvent::class);
/** @var \OCP\Federated\Events\TrustedServerRemovedEvent $event */
$this->assertSame('url_hash', $event->getUrlHash());
}
@@ -277,7 +279,7 @@ public function dataTestCheckNextcloudVersion(): array {
* @dataProvider dataTestCheckNextcloudVersionTooLow
*/
public function testCheckNextcloudVersionTooLow(string $status): void {
- $this->expectException(\OCP\HintException::class);
+ $this->expectException(HintException::class);
$this->expectExceptionMessage('Remote server version is too low. 9.0 is required.');
$this->invokePrivate($this->trustedServers, 'checkNextcloudVersion', [$status]);
diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php
index 283ce17cd8570..cf1cb04b9afe3 100644
--- a/apps/files/lib/Command/Scan.php
+++ b/apps/files/lib/Command/Scan.php
@@ -11,6 +11,7 @@
use OC\Core\Command\InterruptedException;
use OC\DB\Connection;
use OC\DB\ConnectionAdapter;
+use OC\Files\Utils\Scanner;
use OC\FilesMetadata\FilesMetadataManager;
use OC\ForbiddenException;
use OCP\EventDispatcher\IEventDispatcher;
@@ -98,7 +99,7 @@ protected function configure(): void {
protected function scanFiles(string $user, string $path, ?string $scanMetadata, OutputInterface $output, bool $backgroundScan = false, bool $recursive = true, bool $homeOnly = false): void {
$connection = $this->reconnectToDatabase($output);
- $scanner = new \OC\Files\Utils\Scanner(
+ $scanner = new Scanner(
$user,
new ConnectionAdapter($connection),
\OC::$server->get(IEventDispatcher::class),
diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php
index 4d89389fe32b6..4c52297003f62 100644
--- a/apps/files/lib/Command/ScanAppData.php
+++ b/apps/files/lib/Command/ScanAppData.php
@@ -9,6 +9,7 @@
use OC\Core\Command\InterruptedException;
use OC\DB\Connection;
use OC\DB\ConnectionAdapter;
+use OC\Files\Utils\Scanner;
use OC\ForbiddenException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
@@ -65,7 +66,7 @@ protected function scanFiles(OutputInterface $output, string $folder): int {
}
$connection = $this->reconnectToDatabase($output);
- $scanner = new \OC\Files\Utils\Scanner(
+ $scanner = new Scanner(
null,
new ConnectionAdapter($connection),
\OC::$server->query(IEventDispatcher::class),
diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php
index 0ca4a1efd4b5c..118a4fcb9e2ae 100644
--- a/apps/files/lib/Controller/ApiController.php
+++ b/apps/files/lib/Controller/ApiController.php
@@ -8,6 +8,7 @@
namespace OCA\Files\Controller;
use OC\Files\Node\Node;
+use OCA\Files\Helper;
use OCA\Files\ResponseDefinitions;
use OCA\Files\Service\TagService;
use OCA\Files\Service\UserConfig;
@@ -30,6 +31,7 @@
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
+use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IPreview;
@@ -124,11 +126,11 @@ public function updateFileTags($path, $tags = null) {
if (!is_null($tags)) {
try {
$this->tagService->updateFileTags($path, $tags);
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
return new DataResponse([
'message' => $e->getMessage()
], Http::STATUS_NOT_FOUND);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
+ } catch (StorageNotAvailableException $e) {
return new DataResponse([
'message' => $e->getMessage()
], Http::STATUS_SERVICE_UNAVAILABLE);
@@ -150,7 +152,7 @@ private function formatNodes(array $nodes) {
$shareTypesForNodes = $this->getShareTypesForNodes($nodes);
return array_values(array_map(function (Node $node) use ($shareTypesForNodes) {
$shareTypes = $shareTypesForNodes[$node->getId()] ?? [];
- $file = \OCA\Files\Helper::formatFileInfo($node->getFileInfo());
+ $file = Helper::formatFileInfo($node->getFileInfo());
$file['hasPreview'] = $this->previewManager->isAvailable($node);
$parts = explode('/', dirname($node->getPath()), 4);
if (isset($parts[3])) {
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index b5c61aaa5f4e4..b6aeb079add9b 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -8,6 +8,7 @@
namespace OCA\Files\Controller;
use OC\Files\FilenameValidator;
+use OC\Files\Filesystem;
use OCA\Files\AppInfo\Application;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSearchPlugins;
@@ -36,6 +37,7 @@
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserSession;
+use OCP\Util;
/**
* @package OCA\Files\Controller
@@ -69,7 +71,7 @@ public function __construct(
* @throws \OCP\Files\NotFoundException
*/
protected function getStorageInfo(string $dir = '/') {
- $rootInfo = \OC\Files\Filesystem::getFileInfo('/', false);
+ $rootInfo = Filesystem::getFileInfo('/', false);
return \OC_Helper::getStorageInfo($dir, $rootInfo ?: null);
}
@@ -138,8 +140,8 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
}
// Load the files we need
- \OCP\Util::addInitScript('files', 'init');
- \OCP\Util::addScript('files', 'main');
+ Util::addInitScript('files', 'init');
+ Util::addScript('files', 'main');
$userId = $this->userSession->getUser()->getUID();
diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php
index 6126c1270ebad..4ddab45d44150 100644
--- a/apps/files/lib/Helper.php
+++ b/apps/files/lib/Helper.php
@@ -7,8 +7,10 @@
*/
namespace OCA\Files;
+use OC\Files\Filesystem;
use OCP\Files\FileInfo;
use OCP\ITagManager;
+use OCP\Util;
/**
* Helper class for manipulating file information
@@ -22,9 +24,9 @@ class Helper {
public static function buildFileStorageStatistics($dir) {
// information about storage capacities
$storageInfo = \OC_Helper::getStorageInfo($dir);
- $l = \OCP\Util::getL10N('files');
- $maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
- $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
+ $l = Util::getL10N('files');
+ $maxUploadFileSize = Util::maxUploadFilesize($dir, $storageInfo['free']);
+ $maxHumanFileSize = Util::humanFileSize($maxUploadFileSize);
$maxHumanFileSize = $l->t('Upload (max. %s)', [$maxHumanFileSize]);
return [
@@ -80,7 +82,7 @@ public static function compareFileNames(FileInfo $a, FileInfo $b) {
} elseif ($aType !== 'dir' and $bType === 'dir') {
return 1;
} else {
- return \OCP\Util::naturalSortCompare($a->getName(), $b->getName());
+ return Util::naturalSortCompare($a->getName(), $b->getName());
}
}
@@ -181,7 +183,7 @@ public static function formatFileInfos($fileInfos) {
* @return \OCP\Files\FileInfo[] files
*/
public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false, $mimetypeFilter = '') {
- $content = \OC\Files\Filesystem::getDirectoryContent($dir, $mimetypeFilter);
+ $content = Filesystem::getDirectoryContent($dir, $mimetypeFilter);
return self::sortFiles($content, $sortAttribute, $sortDescending);
}
diff --git a/apps/files/lib/Listener/LoadSearchPluginsListener.php b/apps/files/lib/Listener/LoadSearchPluginsListener.php
index c9792242b2c4c..4cc4ca22f831c 100644
--- a/apps/files/lib/Listener/LoadSearchPluginsListener.php
+++ b/apps/files/lib/Listener/LoadSearchPluginsListener.php
@@ -11,6 +11,7 @@
use OCA\Files\Event\LoadSearchPlugins;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
+use OCP\Util;
/** @template-implements IEventListener */
class LoadSearchPluginsListener implements IEventListener {
@@ -19,6 +20,6 @@ public function handle(Event $event): void {
return;
}
- \OCP\Util::addScript('files', 'search');
+ Util::addScript('files', 'search');
}
}
diff --git a/apps/files/lib/Listener/RenderReferenceEventListener.php b/apps/files/lib/Listener/RenderReferenceEventListener.php
index fc8b4d08aebc6..b7470e5acf511 100644
--- a/apps/files/lib/Listener/RenderReferenceEventListener.php
+++ b/apps/files/lib/Listener/RenderReferenceEventListener.php
@@ -11,6 +11,7 @@
use OCP\Collaboration\Reference\RenderReferenceEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
+use OCP\Util;
/** @template-implements IEventListener */
class RenderReferenceEventListener implements IEventListener {
@@ -19,6 +20,6 @@ public function handle(Event $event): void {
return;
}
- \OCP\Util::addScript('files', 'reference-files');
+ Util::addScript('files', 'reference-files');
}
}
diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php
index 14cbe882245f5..f8a3498ac09f6 100644
--- a/apps/files/lib/Service/OwnershipTransferService.php
+++ b/apps/files/lib/Service/OwnershipTransferService.php
@@ -13,6 +13,7 @@
use OC\Encryption\Manager as EncryptionManager;
use OC\Files\Filesystem;
use OC\Files\View;
+use OCA\Encryption\Util;
use OCA\Files\Exception\TransferOwnershipException;
use OCP\Encryption\IManager as IEncryptionManager;
use OCP\Files\Config\IUserMountCache;
@@ -21,9 +22,11 @@
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
+use OCP\Files\NotFoundException;
use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
+use OCP\Server;
use OCP\Share\IManager as IShareManager;
use OCP\Share\IShare;
use Symfony\Component\Console\Helper\ProgressBar;
@@ -227,7 +230,7 @@ protected function analyse(string $sourceUid,
$progress->start();
if ($this->encryptionManager->isEnabled()) {
- $masterKeyEnabled = \OCP\Server::get(\OCA\Encryption\Util::class)->isMasterKeyEnabled();
+ $masterKeyEnabled = Server::get(Util::class)->isMasterKeyEnabled();
} else {
$masterKeyEnabled = false;
}
@@ -416,7 +419,7 @@ private function restoreShares(
):void {
$output->writeln('Restoring shares ...');
$progress = new ProgressBar($output, count($shares));
- $rootFolder = \OCP\Server::get(IRootFolder::class);
+ $rootFolder = Server::get(IRootFolder::class);
foreach ($shares as ['share' => $share, 'suffix' => $suffix]) {
try {
@@ -452,7 +455,7 @@ private function restoreShares(
// Normally the ID is preserved,
// but for transferes between different storages the ID might change
$newNodeId = $share->getNode()->getId();
- } catch (\OCP\Files\NotFoundException) {
+ } catch (NotFoundException) {
// ID has changed due to transfer between different storages
// Try to get the new ID from the target path and suffix of the share
$node = $rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix));
@@ -463,7 +466,7 @@ private function restoreShares(
$this->shareManager->updateShare($share);
}
}
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
$output->writeln('Share with id ' . $share->getId() . ' points at deleted file, skipping');
} catch (\Throwable $e) {
$output->writeln('Could not restore share with id ' . $share->getId() . ':' . $e->getMessage() . ' : ' . $e->getTraceAsString() . '');
@@ -543,7 +546,7 @@ private function transferIncomingShares(string $sourceUid,
$this->shareManager->moveShare($share, $destinationUid);
continue;
}
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
$output->writeln('Share with id ' . $share->getId() . ' points at deleted file, skipping');
} catch (\Throwable $e) {
$output->writeln('Could not restore share with id ' . $share->getId() . ':' . $e->getTraceAsString() . '');
diff --git a/apps/files/lib/Settings/PersonalSettings.php b/apps/files/lib/Settings/PersonalSettings.php
index 484e4bde2b821..fe43265bc13d1 100644
--- a/apps/files/lib/Settings/PersonalSettings.php
+++ b/apps/files/lib/Settings/PersonalSettings.php
@@ -11,10 +11,11 @@
use OCA\Files\AppInfo\Application;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Settings\ISettings;
+use OCP\Util;
class PersonalSettings implements ISettings {
public function getForm(): TemplateResponse {
- \OCP\Util::addScript(Application::APP_ID, 'settings-personal');
+ Util::addScript(Application::APP_ID, 'settings-personal');
return new TemplateResponse(Application::APP_ID, 'settings-personal');
}
diff --git a/apps/files/tests/Command/DeleteOrphanedFilesTest.php b/apps/files/tests/Command/DeleteOrphanedFilesTest.php
index 6e9fbead34e79..e480f7b632ede 100644
--- a/apps/files/tests/Command/DeleteOrphanedFilesTest.php
+++ b/apps/files/tests/Command/DeleteOrphanedFilesTest.php
@@ -12,6 +12,7 @@
use OCP\Files\IRootFolder;
use OCP\Files\StorageNotAvailableException;
use OCP\IDBConnection;
+use OCP\Server;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
@@ -32,7 +33,7 @@ class DeleteOrphanedFilesTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->connection = \OCP\Server::get(IDBConnection::class);
+ $this->connection = Server::get(IDBConnection::class);
$this->user1 = $this->getUniqueID('user1_');
@@ -81,7 +82,7 @@ public function testClearFiles(): void {
->disableOriginalConstructor()
->getMock();
- $rootFolder = \OCP\Server::get(IRootFolder::class);
+ $rootFolder = Server::get(IRootFolder::class);
// scan home storage so that mounts are properly setup
$rootFolder->getUserFolder($this->user1)->getStorage()->getScanner()->scan('');
diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php
index ad2a6a15b2b44..e7f8b962a4594 100644
--- a/apps/files/tests/Controller/ApiControllerTest.php
+++ b/apps/files/tests/Controller/ApiControllerTest.php
@@ -12,6 +12,8 @@
use OCA\Files\Service\ViewConfig;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http\FileDisplayResponse;
+use OCP\AppFramework\Http\Response;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
@@ -211,7 +213,7 @@ public function testGetThumbnail(): void {
$ret = $this->apiController->getThumbnail(10, 10, 'known.jpg');
$this->assertEquals(Http::STATUS_OK, $ret->getStatus());
- $this->assertInstanceOf(Http\FileDisplayResponse::class, $ret);
+ $this->assertInstanceOf(FileDisplayResponse::class, $ret);
}
public function testShowHiddenFiles(): void {
@@ -221,7 +223,7 @@ public function testShowHiddenFiles(): void {
->method('setUserValue')
->with($this->user->getUID(), 'files', 'show_hidden', '0');
- $expected = new Http\Response();
+ $expected = new Response();
$actual = $this->apiController->showHiddenFiles($show);
$this->assertEquals($expected, $actual);
@@ -234,7 +236,7 @@ public function testCropImagePreviews(): void {
->method('setUserValue')
->with($this->user->getUID(), 'files', 'crop_image_previews', '1');
- $expected = new Http\Response();
+ $expected = new Response();
$actual = $this->apiController->cropImagePreviews($crop);
$this->assertEquals($expected, $actual);
diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php
index a6eba1f9eaf48..0c0647cc415bf 100644
--- a/apps/files/tests/Controller/ViewControllerTest.php
+++ b/apps/files/tests/Controller/ViewControllerTest.php
@@ -12,7 +12,9 @@
use OCA\Files\Service\UserConfig;
use OCA\Files\Service\ViewConfig;
use OCP\App\IAppManager;
-use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\ContentSecurityPolicy;
+use OCP\AppFramework\Http\RedirectResponse;
+use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\File;
@@ -133,11 +135,11 @@ public function testIndexWithRegularBrowser(): void {
->method('getAppValue')
->willReturnArgument(2);
- $expected = new Http\TemplateResponse(
+ $expected = new TemplateResponse(
'files',
'index',
);
- $policy = new Http\ContentSecurityPolicy();
+ $policy = new ContentSecurityPolicy();
$policy->addAllowedWorkerSrcDomain('\'self\'');
$policy->addAllowedFrameDomain('\'self\'');
$expected->setContentSecurityPolicy($policy);
@@ -193,7 +195,7 @@ public function testShowFileRouteWithTrashedFile(): void {
->with('files.view.indexViewFileid', ['view' => 'trashbin', 'dir' => '/test.d1462861890/sub', 'fileid' => '123'])
->willReturn('/apps/files/trashbin/123?dir=/test.d1462861890/sub');
- $expected = new Http\RedirectResponse('/apps/files/trashbin/123?dir=/test.d1462861890/sub');
+ $expected = new RedirectResponse('/apps/files/trashbin/123?dir=/test.d1462861890/sub');
$this->assertEquals($expected, $this->viewController->index('', '', '123'));
}
}
diff --git a/apps/files/tests/HelperTest.php b/apps/files/tests/HelperTest.php
index fdcef8f7125c0..27b1de1322f55 100644
--- a/apps/files/tests/HelperTest.php
+++ b/apps/files/tests/HelperTest.php
@@ -1,5 +1,10 @@
markTestSkipped('Skip mtime sorting on 32bit');
}
$files = self::getTestFileList();
- $files = \OCA\Files\Helper::sortFiles($files, $sort, $sortDescending);
+ $files = Helper::sortFiles($files, $sort, $sortDescending);
$fileNames = [];
foreach ($files as $fileInfo) {
$fileNames[] = $fileInfo->getName();
@@ -91,8 +96,8 @@ public function testSortByName(string $sort, bool $sortDescending, array $expect
}
public function testPopulateTags(): void {
- $tagManager = $this->createMock(\OCP\ITagManager::class);
- $tagger = $this->createMock(\OCP\ITags::class);
+ $tagManager = $this->createMock(ITagManager::class);
+ $tagger = $this->createMock(ITags::class);
$tagManager->method('load')
->with('files')
@@ -113,7 +118,7 @@ public function testPopulateTags(): void {
->with([10, 22, 42])
->willReturn($tags);
- $result = \OCA\Files\Helper::populateTags($data, 'id', $tagManager);
+ $result = Helper::populateTags($data, 'id', $tagManager);
$this->assertSame([
['id' => 10, 'tags' => ['tag3']],
diff --git a/apps/files/tests/Service/TagServiceTest.php b/apps/files/tests/Service/TagServiceTest.php
index 7922c45a63983..0e3ac66ef388e 100644
--- a/apps/files/tests/Service/TagServiceTest.php
+++ b/apps/files/tests/Service/TagServiceTest.php
@@ -10,6 +10,7 @@
use OCA\Files\Service\TagService;
use OCP\Activity\IManager;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\NotFoundException;
use OCP\ITags;
use OCP\IUser;
use OCP\IUserSession;
@@ -43,7 +44,7 @@ class TagServiceTest extends \Test\TestCase {
private $dispatcher;
/**
- * @var \OCA\Files\Service\TagService|\PHPUnit\Framework\MockObject\MockObject
+ * @var TagService|\PHPUnit\Framework\MockObject\MockObject
*/
private $tagService;
@@ -134,7 +135,7 @@ public function testUpdateFileTags(): void {
$caught = false;
try {
$this->tagService->updateFileTags('subdir/unexist.txt', [$tag1]);
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
$caught = true;
}
$this->assertTrue($caught);
diff --git a/apps/files_external/lib/Command/Verify.php b/apps/files_external/lib/Command/Verify.php
index 25b09fa111602..1fe5af9198471 100644
--- a/apps/files_external/lib/Command/Verify.php
+++ b/apps/files_external/lib/Command/Verify.php
@@ -9,6 +9,7 @@
use OC\Core\Command\Base;
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\Files\StorageNotAvailableException;
@@ -92,7 +93,7 @@ private function updateStorageStatus(StorageConfig &$storage, $configInput, Outp
$backend = $storage->getBackend();
// update status (can be time-consuming)
$storage->setStatus(
- \OCA\Files_External\MountConfig::getBackendStatus(
+ MountConfig::getBackendStatus(
$backend->getStorageClass(),
$storage->getBackendOptions(),
false
diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php
index b2246226d33ba..ab9bd42833468 100644
--- a/apps/files_external/lib/Config/ConfigAdapter.php
+++ b/apps/files_external/lib/Config/ConfigAdapter.php
@@ -6,11 +6,13 @@
*/
namespace OCA\Files_External\Config;
+use OC\Files\Cache\Storage;
use OC\Files\Storage\FailedStorage;
use OC\Files\Storage\Wrapper\Availability;
use OC\Files\Storage\Wrapper\KnownMtime;
use OCA\Files_External\Lib\PersonalMount;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\Service\UserGlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\Files\Config\IMountProvider;
@@ -20,6 +22,7 @@
use OCP\Files\Storage\IStorageFactory;
use OCP\Files\StorageNotAvailableException;
use OCP\IUser;
+use OCP\Server;
use Psr\Clock\ClockInterface;
use Psr\Log\LoggerInterface;
@@ -41,7 +44,7 @@ public function __construct(
*/
private function prepareStorageConfig(StorageConfig &$storage, IUser $user): void {
foreach ($storage->getBackendOptions() as $option => $value) {
- $storage->setBackendOption($option, \OCA\Files_External\MountConfig::substitutePlaceholdersInConfig($value, $user->getUID()));
+ $storage->setBackendOption($option, MountConfig::substitutePlaceholdersInConfig($value, $user->getUID()));
}
$objectStore = $storage->getBackendOption('objectstore');
@@ -65,7 +68,7 @@ private function prepareStorageConfig(StorageConfig &$storage, IUser $user): voi
private function constructStorage(StorageConfig $storageConfig): IStorage {
$class = $storageConfig->getBackend()->getStorageClass();
if (!$class instanceof IConstructableStorage) {
- \OCP\Server::get(LoggerInterface::class)->warning('Building a storage not implementing IConstructableStorage is deprecated since 31.0.0', ['class' => $class]);
+ Server::get(LoggerInterface::class)->warning('Building a storage not implementing IConstructableStorage is deprecated since 31.0.0', ['class' => $class]);
}
$storage = new $class($storageConfig->getBackendOptions());
@@ -98,7 +101,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
}, $storageConfigs);
- \OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function (IStorage $storage) {
+ Storage::getGlobalCache()->loadForStorageIds(array_map(function (IStorage $storage) {
return $storage->getId();
}, $storages));
diff --git a/apps/files_external/lib/Controller/ApiController.php b/apps/files_external/lib/Controller/ApiController.php
index d326e1f7f444b..cb8d8cbb0ffa9 100644
--- a/apps/files_external/lib/Controller/ApiController.php
+++ b/apps/files_external/lib/Controller/ApiController.php
@@ -17,6 +17,7 @@
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
+use OCP\Constants;
use OCP\IRequest;
/**
@@ -55,10 +56,10 @@ private function formatMount(string $mountPoint, StorageConfig $mountConfig): ar
$isSystemMount = $mountConfig->getType() === StorageConfig::MOUNT_TYPE_ADMIN;
- $permissions = \OCP\Constants::PERMISSION_READ;
+ $permissions = Constants::PERMISSION_READ;
// personal mounts can be deleted
if (!$isSystemMount) {
- $permissions |= \OCP\Constants::PERMISSION_DELETE;
+ $permissions |= Constants::PERMISSION_DELETE;
}
$entry = [
diff --git a/apps/files_external/lib/Controller/StoragesController.php b/apps/files_external/lib/Controller/StoragesController.php
index fcd3863e65888..9144b766d5d9d 100644
--- a/apps/files_external/lib/Controller/StoragesController.php
+++ b/apps/files_external/lib/Controller/StoragesController.php
@@ -10,6 +10,7 @@
use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\StoragesService;
use OCP\AppFramework\Controller;
@@ -220,7 +221,7 @@ protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true
$backend = $storage->getBackend();
// update status (can be time-consuming)
$storage->setStatus(
- \OCA\Files_External\MountConfig::getBackendStatus(
+ MountConfig::getBackendStatus(
$backend->getStorageClass(),
$storage->getBackendOptions(),
false,
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 5325b25a66b40..4c4a1fb6fdd05 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -13,6 +13,7 @@
use OC\Files\Cache\CacheEntry;
use OC\Files\ObjectStore\S3ConnectionTrait;
use OC\Files\ObjectStore\S3ObjectTrait;
+use OC\Files\Storage\Common;
use OCP\Cache\CappedMemoryCache;
use OCP\Constants;
use OCP\Files\FileInfo;
@@ -22,7 +23,7 @@
use OCP\Server;
use Psr\Log\LoggerInterface;
-class AmazonS3 extends \OC\Files\Storage\Common {
+class AmazonS3 extends Common {
use S3ConnectionTrait;
use S3ObjectTrait;
diff --git a/apps/files_external/lib/Lib/Storage/OwnCloud.php b/apps/files_external/lib/Lib/Storage/OwnCloud.php
index fb5c720748663..729f2ec059dcd 100644
--- a/apps/files_external/lib/Lib/Storage/OwnCloud.php
+++ b/apps/files_external/lib/Lib/Storage/OwnCloud.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_External\Lib\Storage;
+use OC\Files\Storage\DAV;
use OCP\Files\Storage\IDisableEncryptionStorage;
use Sabre\DAV\Client;
@@ -16,7 +17,7 @@
* http://%host/%context/remote.php/webdav/%root
*
*/
-class OwnCloud extends \OC\Files\Storage\DAV implements IDisableEncryptionStorage {
+class OwnCloud extends DAV implements IDisableEncryptionStorage {
public const OC_URL_SUFFIX = 'remote.php/webdav';
public function __construct($params) {
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index a6a282452142c..0cf2d0b029d21 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -10,6 +10,7 @@
use Icewind\Streams\IteratorDirectory;
use Icewind\Streams\RetryWrapper;
use OC\Files\Storage\Common;
+use OC\Files\View;
use OCP\Constants;
use OCP\Files\FileInfo;
use OCP\Files\IMimeTypeDetector;
@@ -199,7 +200,7 @@ private function hostKeysPath() {
return false;
}
- $view = new \OC\Files\View('/' . $userId . '/files_external');
+ $view = new View('/' . $userId . '/files_external');
return $view->getLocalFile('ssh_hostKeys');
} catch (\Exception $e) {
diff --git a/apps/files_external/lib/Lib/Storage/StreamWrapper.php b/apps/files_external/lib/Lib/Storage/StreamWrapper.php
index 2928c081505c5..ec9bb43b6e85a 100644
--- a/apps/files_external/lib/Lib/Storage/StreamWrapper.php
+++ b/apps/files_external/lib/Lib/Storage/StreamWrapper.php
@@ -6,7 +6,9 @@
*/
namespace OCA\Files_External\Lib\Storage;
-abstract class StreamWrapper extends \OC\Files\Storage\Common {
+use OC\Files\Storage\Common;
+
+abstract class StreamWrapper extends Common {
/**
* @param string $path
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php
index 9aabf5b56b4c1..45a2535314ae1 100644
--- a/apps/files_external/lib/Lib/Storage/Swift.php
+++ b/apps/files_external/lib/Lib/Storage/Swift.php
@@ -12,14 +12,17 @@
use GuzzleHttp\Psr7\Uri;
use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\IteratorDirectory;
+use OC\Files\Filesystem;
use OC\Files\ObjectStore\SwiftFactory;
+use OC\Files\Storage\Common;
+use OCP\Cache\CappedMemoryCache;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\StorageBadConfigException;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\ObjectStore\v1\Models\StorageObject;
use Psr\Log\LoggerInterface;
-class Swift extends \OC\Files\Storage\Common {
+class Swift extends Common {
/** @var SwiftFactory */
private $connectionFactory;
/**
@@ -168,7 +171,7 @@ public function __construct($params) {
$this->params = $params;
// FIXME: private class...
- $this->objectCache = new \OCP\Cache\CappedMemoryCache();
+ $this->objectCache = new CappedMemoryCache();
$this->connectionFactory = new SwiftFactory(
\OC::$server->getMemCacheFactory()->createDistributed('swift/'),
$this->params,
@@ -229,7 +232,7 @@ public function rmdir($path) {
$dh = $this->opendir($path);
while (($file = readdir($dh)) !== false) {
- if (\OC\Files\Filesystem::isIgnoredDir($file)) {
+ if (Filesystem::isIgnoredDir($file)) {
continue;
}
@@ -495,7 +498,7 @@ public function copy($source, $target) {
$dh = $this->opendir($source);
while (($file = readdir($dh)) !== false) {
- if (\OC\Files\Filesystem::isIgnoredDir($file)) {
+ if (Filesystem::isIgnoredDir($file)) {
continue;
}
diff --git a/apps/files_external/lib/Lib/StorageConfig.php b/apps/files_external/lib/Lib/StorageConfig.php
index 682516c73bae3..12523937071b3 100644
--- a/apps/files_external/lib/Lib/StorageConfig.php
+++ b/apps/files_external/lib/Lib/StorageConfig.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_External\Lib;
+use OC\Files\Filesystem;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Auth\IUserProvided;
use OCA\Files_External\Lib\Backend\Backend;
@@ -152,7 +153,7 @@ public function getMountPoint() {
* @param string $mountPoint path
*/
public function setMountPoint($mountPoint) {
- $this->mountPoint = \OC\Files\Filesystem::normalizePath($mountPoint);
+ $this->mountPoint = Filesystem::normalizePath($mountPoint);
}
/**
@@ -203,7 +204,7 @@ public function setBackendOptions($backendOptions) {
foreach ($backendOptions as $key => $value) {
if (isset($parameters[$key])) {
switch ($parameters[$key]->getType()) {
- case \OCA\Files_External\Lib\DefinitionParameter::VALUE_BOOLEAN:
+ case DefinitionParameter::VALUE_BOOLEAN:
$value = (bool)$value;
break;
}
diff --git a/apps/files_external/lib/MountConfig.php b/apps/files_external/lib/MountConfig.php
index 1cbd6e14ebea2..744bdcacef339 100644
--- a/apps/files_external/lib/MountConfig.php
+++ b/apps/files_external/lib/MountConfig.php
@@ -14,6 +14,8 @@
use OCA\Files_External\Service\UserGlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\Files\StorageNotAvailableException;
+use OCP\IL10N;
+use OCP\Util;
use phpseclib\Crypt\AES;
use Psr\Log\LoggerInterface;
@@ -119,7 +121,7 @@ public static function getBackendStatus($class, $options, $isPersonal, $testOnly
* @param Backend[] $backends
*/
public static function dependencyMessage(array $backends): string {
- $l = \OCP\Util::getL10N('files_external');
+ $l = Util::getL10N('files_external');
$message = '';
$dependencyGroups = [];
@@ -147,7 +149,7 @@ public static function dependencyMessage(array $backends): string {
/**
* Returns a dependency missing message
*/
- private static function getSingleDependencyMessage(\OCP\IL10N $l, string $module, string $backend): string {
+ private static function getSingleDependencyMessage(IL10N $l, string $module, string $backend): string {
switch (strtolower($module)) {
case 'curl':
return $l->t('The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', [$backend]);
diff --git a/apps/files_external/lib/Service/GlobalStoragesService.php b/apps/files_external/lib/Service/GlobalStoragesService.php
index c799007cc6dd4..92961d732287e 100644
--- a/apps/files_external/lib/Service/GlobalStoragesService.php
+++ b/apps/files_external/lib/Service/GlobalStoragesService.php
@@ -8,6 +8,7 @@
use OC\Files\Filesystem;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
/**
* Service class to manage global external storage
@@ -29,7 +30,7 @@ protected function triggerHooks(StorageConfig $storage, $signal) {
$this->triggerApplicableHooks(
$signal,
$storage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
['all']
);
return;
@@ -38,13 +39,13 @@ protected function triggerHooks(StorageConfig $storage, $signal) {
$this->triggerApplicableHooks(
$signal,
$storage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$applicableUsers
);
$this->triggerApplicableHooks(
$signal,
$storage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
$applicableGroups
);
}
@@ -78,7 +79,7 @@ protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $
$this->triggerApplicableHooks(
Filesystem::signal_delete_mount,
$oldStorage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
['all']
);
}
@@ -87,7 +88,7 @@ protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $
$this->triggerApplicableHooks(
Filesystem::signal_delete_mount,
$oldStorage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$userDeletions
);
@@ -95,7 +96,7 @@ protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $
$this->triggerApplicableHooks(
Filesystem::signal_delete_mount,
$oldStorage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
$groupDeletions
);
@@ -103,7 +104,7 @@ protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $
$this->triggerApplicableHooks(
Filesystem::signal_create_mount,
$newStorage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$userAdditions
);
@@ -111,7 +112,7 @@ protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $
$this->triggerApplicableHooks(
Filesystem::signal_create_mount,
$newStorage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
$groupAdditions
);
@@ -123,7 +124,7 @@ protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $
$this->triggerApplicableHooks(
Filesystem::signal_create_mount,
$newStorage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
['all']
);
}
diff --git a/apps/files_external/lib/Service/LegacyStoragesService.php b/apps/files_external/lib/Service/LegacyStoragesService.php
index 1f5cf8cdf2881..20a26a07e8b19 100644
--- a/apps/files_external/lib/Service/LegacyStoragesService.php
+++ b/apps/files_external/lib/Service/LegacyStoragesService.php
@@ -7,6 +7,7 @@
namespace OCA\Files_External\Service;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
use Psr\Log\LoggerInterface;
/**
@@ -62,13 +63,13 @@ protected function populateStorageConfigWithLegacyOptions(
$storageOptions['priority'] = $backend->getPriority();
}
$storageConfig->setPriority($storageOptions['priority']);
- if ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_USER) {
+ if ($mountType === MountConfig::MOUNT_TYPE_USER) {
$applicableUsers = $storageConfig->getApplicableUsers();
if ($applicable !== 'all') {
$applicableUsers[] = $applicable;
$storageConfig->setApplicableUsers($applicableUsers);
}
- } elseif ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP) {
+ } elseif ($mountType === MountConfig::MOUNT_TYPE_GROUP) {
$applicableGroups = $storageConfig->getApplicableGroups();
$applicableGroups[] = $applicable;
$storageConfig->setApplicableGroups($applicableGroups);
@@ -129,7 +130,7 @@ public function getAllStorages() {
$relativeMountPath = rtrim($parts[2], '/');
// note: we cannot do this after the loop because the decrypted config
// options might be needed for the config hash
- $storageOptions['options'] = \OCA\Files_External\MountConfig::decryptPasswords($storageOptions['options']);
+ $storageOptions['options'] = MountConfig::decryptPasswords($storageOptions['options']);
if (!isset($storageOptions['backend'])) {
$storageOptions['backend'] = $storageOptions['class']; // legacy compat
}
@@ -147,7 +148,7 @@ public function getAllStorages() {
// but at this point we don't know the max-id, so use
// first group it by config hash
$storageOptions['mountpoint'] = $rootMountPath;
- $configId = \OCA\Files_External\MountConfig::makeConfigHash($storageOptions);
+ $configId = MountConfig::makeConfigHash($storageOptions);
if (isset($storagesWithConfigHash[$configId])) {
$currentStorage = $storagesWithConfigHash[$configId];
}
diff --git a/apps/files_external/lib/Service/StoragesService.php b/apps/files_external/lib/Service/StoragesService.php
index 40bf5bfe1a80a..12bf074a0958f 100644
--- a/apps/files_external/lib/Service/StoragesService.php
+++ b/apps/files_external/lib/Service/StoragesService.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_External\Service;
+use OC\Files\Cache\Storage;
use OC\Files\Filesystem;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Auth\InvalidAuth;
@@ -18,6 +19,7 @@
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\StorageNotAvailableException;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
@@ -324,7 +326,7 @@ public function createStorage(
protected function triggerApplicableHooks($signal, $mountPoint, $mountType, $applicableArray): void {
$this->eventDispatcher->dispatchTyped(new InvalidateMountCacheEvent(null));
foreach ($applicableArray as $applicable) {
- \OCP\Util::emitHook(
+ Util::emitHook(
Filesystem::CLASSNAME,
$signal,
[
@@ -463,7 +465,7 @@ public function removeStorage($id) {
$this->triggerHooks($deletedStorage, Filesystem::signal_delete_mount);
// delete oc_storages entries and oc_filecache
- \OC\Files\Cache\Storage::cleanByMountId($id);
+ Storage::cleanByMountId($id);
}
/**
diff --git a/apps/files_external/lib/Service/UserStoragesService.php b/apps/files_external/lib/Service/UserStoragesService.php
index b461451389b38..defa97451cd87 100644
--- a/apps/files_external/lib/Service/UserStoragesService.php
+++ b/apps/files_external/lib/Service/UserStoragesService.php
@@ -8,6 +8,7 @@
use OC\Files\Filesystem;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\NotFoundException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\IUserMountCache;
@@ -58,7 +59,7 @@ protected function triggerHooks(StorageConfig $storage, $signal) {
$this->triggerApplicableHooks(
$signal,
$storage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
[$user]
);
}
diff --git a/apps/files_external/lib/Settings/Admin.php b/apps/files_external/lib/Settings/Admin.php
index 707f7704702c3..41f2c43b5f1b3 100644
--- a/apps/files_external/lib/Settings/Admin.php
+++ b/apps/files_external/lib/Settings/Admin.php
@@ -6,6 +6,7 @@
namespace OCA\Files_External\Settings;
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\AppFramework\Http\TemplateResponse;
@@ -48,7 +49,7 @@ public function getForm() {
'storages' => $this->globalStoragesService->getStorages(),
'backends' => $this->backendService->getAvailableBackends(),
'authMechanisms' => $this->backendService->getAuthMechanisms(),
- 'dependencies' => \OCA\Files_External\MountConfig::dependencyMessage($this->backendService->getBackends()),
+ 'dependencies' => MountConfig::dependencyMessage($this->backendService->getBackends()),
'allowUserMounting' => $this->backendService->isUserMountingAllowed(),
'globalCredentials' => $this->globalAuth->getAuth(''),
'globalCredentialsUid' => '',
diff --git a/apps/files_external/lib/Settings/Personal.php b/apps/files_external/lib/Settings/Personal.php
index f84051626a222..186b2638e1fa7 100644
--- a/apps/files_external/lib/Settings/Personal.php
+++ b/apps/files_external/lib/Settings/Personal.php
@@ -6,6 +6,7 @@
namespace OCA\Files_External\Settings;
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\UserGlobalStoragesService;
use OCP\AppFramework\Http\TemplateResponse;
@@ -56,7 +57,7 @@ public function getForm() {
'storages' => $this->userGlobalStoragesService->getStorages(),
'backends' => $this->backendService->getAvailableBackends(),
'authMechanisms' => $this->backendService->getAuthMechanisms(),
- 'dependencies' => \OCA\Files_External\MountConfig::dependencyMessage($this->backendService->getBackends()),
+ 'dependencies' => MountConfig::dependencyMessage($this->backendService->getBackends()),
'allowUserMounting' => $this->backendService->isUserMountingAllowed(),
'globalCredentials' => $this->globalAuth->getAuth($uid),
'globalCredentialsUid' => $uid,
diff --git a/apps/files_external/tests/Auth/Password/GlobalAuth.php b/apps/files_external/tests/Auth/Password/GlobalAuth.php
index 823b66702ab9c..aa28083e09ea7 100644
--- a/apps/files_external/tests/Auth/Password/GlobalAuth.php
+++ b/apps/files_external/tests/Auth/Password/GlobalAuth.php
@@ -7,6 +7,7 @@
namespace OCA\Files_External\Tests\Auth\Password;
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
+use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
use OCA\Files_external\Lib\StorageConfig;
use OCP\IL10N;
use OCP\Security\ICredentialsManager;
@@ -90,7 +91,7 @@ public function testSavedCredentials(): void {
public function testNoCredentialsPersonal(): void {
- $this->expectException(\OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException::class);
+ $this->expectException(InsufficientDataForMeaningfulAnswerException::class);
$this->credentialsManager->expects($this->never())
->method('retrieve');
diff --git a/apps/files_external/tests/Command/CommandTest.php b/apps/files_external/tests/Command/CommandTest.php
index eb47fe08ac4dc..ed991fd784df0 100644
--- a/apps/files_external/tests/Command/CommandTest.php
+++ b/apps/files_external/tests/Command/CommandTest.php
@@ -8,6 +8,7 @@
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;
+use OCA\Files_External\Service\GlobalStoragesService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\Input;
@@ -17,7 +18,7 @@
abstract class CommandTest extends TestCase {
/**
* @param StorageConfig[] $mounts
- * @return \OCA\Files_External\Service\GlobalStoragesService|\PHPUnit\Framework\MockObject\MockObject
+ * @return GlobalStoragesService|\PHPUnit\Framework\MockObject\MockObject
*/
protected function getGlobalStorageService(array $mounts = []) {
$mock = $this->getMockBuilder('OCA\Files_External\Service\GlobalStoragesService')
diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php
index 94512c56cadc8..e18a24852bb18 100644
--- a/apps/files_external/tests/Controller/StoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/StoragesControllerTest.php
@@ -9,8 +9,9 @@
use OCA\Files_External\Controller\GlobalStoragesController;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Backend\Backend;
-
use OCA\Files_External\Lib\StorageConfig;
+
+use OCA\Files_External\MountConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
@@ -30,15 +31,15 @@ abstract class StoragesControllerTest extends \Test\TestCase {
protected $service;
protected function setUp(): void {
- \OCA\Files_External\MountConfig::$skipTest = true;
+ MountConfig::$skipTest = true;
}
protected function tearDown(): void {
- \OCA\Files_External\MountConfig::$skipTest = false;
+ MountConfig::$skipTest = false;
}
/**
- * @return \OCA\Files_External\Lib\Backend\Backend|MockObject
+ * @return Backend|MockObject
*/
protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') {
$backend = $this->getMockBuilder(Backend::class)
@@ -54,7 +55,7 @@ protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB'
}
/**
- * @return \OCA\Files_External\Lib\Auth\AuthMechanism|MockObject
+ * @return AuthMechanism|MockObject
*/
protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') {
$authMech = $this->getMockBuilder(AuthMechanism::class)
diff --git a/apps/files_external/tests/OwnCloudFunctionsTest.php b/apps/files_external/tests/OwnCloudFunctionsTest.php
index 99cb0cf94dee2..3488195d3e87a 100644
--- a/apps/files_external/tests/OwnCloudFunctionsTest.php
+++ b/apps/files_external/tests/OwnCloudFunctionsTest.php
@@ -6,6 +6,8 @@
*/
namespace OCA\Files_External\Tests;
+use OCA\Files_External\Lib\Storage\OwnCloud;
+
/**
* Class OwnCloudFunctions
*
@@ -89,7 +91,7 @@ public function configUrlProvider() {
public function testConfig($config, $expectedUri): void {
$config['user'] = 'someuser';
$config['password'] = 'somepassword';
- $instance = new \OCA\Files_External\Lib\Storage\OwnCloud($config);
+ $instance = new OwnCloud($config);
$this->assertEquals($expectedUri, $instance->createBaseUri());
}
}
diff --git a/apps/files_external/tests/PersonalMountTest.php b/apps/files_external/tests/PersonalMountTest.php
index 2d8f41c3e5004..b268d3b51428a 100644
--- a/apps/files_external/tests/PersonalMountTest.php
+++ b/apps/files_external/tests/PersonalMountTest.php
@@ -10,12 +10,13 @@
use OC\Files\SetupManagerFactory;
use OCA\Files_External\Lib\PersonalMount;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\Service\UserStoragesService;
use Test\TestCase;
class PersonalMountTest extends TestCase {
public function testFindByStorageId(): void {
$storageConfig = $this->createMock(StorageConfig::class);
- /** @var \OCA\Files_External\Service\UserStoragesService $storageService */
+ /** @var UserStoragesService $storageService */
$storageService = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService')
->disableOriginalConstructor()
->getMock();
diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php
index 74a4b223a96d2..e6ad660cb9368 100644
--- a/apps/files_external/tests/Service/BackendServiceTest.php
+++ b/apps/files_external/tests/Service/BackendServiceTest.php
@@ -26,7 +26,7 @@ protected function setUp(): void {
/**
* @param string $class
*
- * @return \OCA\Files_External\Lib\Backend\Backend|\PHPUnit\Framework\MockObject\MockObject
+ * @return Backend|\PHPUnit\Framework\MockObject\MockObject
*/
protected function getBackendMock($class) {
$backend = $this->getMockBuilder(Backend::class)
@@ -40,7 +40,7 @@ protected function getBackendMock($class) {
/**
* @param string $class
*
- * @return \OCA\Files_External\Lib\Auth\AuthMechanism|\PHPUnit\Framework\MockObject\MockObject
+ * @return AuthMechanism|\PHPUnit\Framework\MockObject\MockObject
*/
protected function getAuthMechanismMock($class) {
$backend = $this->getMockBuilder(AuthMechanism::class)
@@ -56,7 +56,7 @@ public function testRegisterBackend(): void {
$backend = $this->getBackendMock('\Foo\Bar');
- /** @var \OCA\Files_External\Lib\Backend\Backend|\PHPUnit\Framework\MockObject\MockObject $backendAlias */
+ /** @var Backend|\PHPUnit\Framework\MockObject\MockObject $backendAlias */
$backendAlias = $this->getMockBuilder(Backend::class)
->disableOriginalConstructor()
->getMock();
diff --git a/apps/files_external/tests/Service/GlobalStoragesServiceTest.php b/apps/files_external/tests/Service/GlobalStoragesServiceTest.php
index 0c9df2e858bb2..b4907f7f00f8e 100644
--- a/apps/files_external/tests/Service/GlobalStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/GlobalStoragesServiceTest.php
@@ -7,6 +7,7 @@
namespace OCA\Files_External\Tests\Service;
use OC\Files\Filesystem;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\Service\GlobalStoragesService;
@@ -181,7 +182,7 @@ public function hooksAddStorageDataProvider() {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'all'
],
],
@@ -194,7 +195,7 @@ public function hooksAddStorageDataProvider() {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
],
@@ -207,7 +208,7 @@ public function hooksAddStorageDataProvider() {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1',
],
],
@@ -219,12 +220,12 @@ public function hooksAddStorageDataProvider() {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
],
@@ -237,12 +238,12 @@ public function hooksAddStorageDataProvider() {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1'
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -255,22 +256,22 @@ public function hooksAddStorageDataProvider() {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1'
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -313,27 +314,27 @@ public function hooksUpdateStorageDataProvider() {
// delete the "all entry"
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'all',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1'
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -348,12 +349,12 @@ public function hooksUpdateStorageDataProvider() {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -368,12 +369,12 @@ public function hooksUpdateStorageDataProvider() {
[
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -388,18 +389,18 @@ public function hooksUpdateStorageDataProvider() {
[
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1'
],
// create the "all" entry
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'all'
],
],
@@ -470,50 +471,50 @@ public function testHooksRenameMountPoint(): void {
[
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1',
],
[
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2',
],
// creates new one
[
Filesystem::signal_create_mount,
'/renamedMountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_create_mount,
'/renamedMountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_create_mount,
'/renamedMountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1',
],
[
Filesystem::signal_create_mount,
'/renamedMountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2',
],
];
@@ -540,22 +541,22 @@ public function hooksDeleteStorageDataProvider() {
[
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1'
],
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -567,7 +568,7 @@ public function hooksDeleteStorageDataProvider() {
[
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'all',
],
],
diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php
index 40cba73a74fe2..a4e823ab6f010 100644
--- a/apps/files_external/tests/Service/StoragesServiceTest.php
+++ b/apps/files_external/tests/Service/StoragesServiceTest.php
@@ -6,13 +6,15 @@
*/
namespace OCA\Files_External\Tests\Service;
+use OC\Files\Cache\Storage;
use OC\Files\Filesystem;
-
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Auth\InvalidAuth;
+
use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\Backend\InvalidBackend;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\DBConfigService;
@@ -26,6 +28,7 @@
use OCP\IDBConnection;
use OCP\IUser;
use OCP\Server;
+use OCP\Util;
class CleaningDBConfig extends DBConfigService {
private $mountIds = [];
@@ -91,7 +94,7 @@ protected function setUp(): void {
'datadirectory',
\OC::$SERVERROOT . '/data/'
);
- \OCA\Files_External\MountConfig::$skipTest = true;
+ MountConfig::$skipTest = true;
$this->mountCache = $this->createMock(IUserMountCache::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
@@ -143,11 +146,11 @@ protected function setUp(): void {
->willReturn($backends);
$this->overwriteService(BackendService::class, $this->backendService);
- \OCP\Util::connectHook(
+ Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_create_mount,
get_class($this), 'createHookCallback');
- \OCP\Util::connectHook(
+ Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_delete_mount,
get_class($this), 'deleteHookCallback');
@@ -162,7 +165,7 @@ protected function setUp(): void {
}
protected function tearDown(): void {
- \OCA\Files_External\MountConfig::$skipTest = false;
+ MountConfig::$skipTest = false;
self::$hookCalls = [];
if ($this->dbConfig) {
$this->dbConfig->clean();
@@ -249,7 +252,7 @@ protected function ActualNonExistingStorageTest() {
}
public function testNonExistingStorage(): void {
- $this->expectException(\OCA\Files_External\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$this->ActualNonExistingStorageTest();
}
@@ -295,7 +298,7 @@ public function testDeleteStorage($backendOptions, $rustyStorageId): void {
// manually trigger storage entry because normally it happens on first
// access, which isn't possible within this test
- $storageCache = new \OC\Files\Cache\Storage($rustyStorageId, true, Server::get(IDBConnection::class));
+ $storageCache = new Storage($rustyStorageId, true, Server::get(IDBConnection::class));
/** @var IUserMountCache $mountCache */
$mountCache = \OC::$server->get(IUserMountCache::class);
@@ -353,7 +356,7 @@ protected function actualDeletedUnexistingStorageTest() {
}
public function testDeleteUnexistingStorage(): void {
- $this->expectException(\OCA\Files_External\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$this->actualDeletedUnexistingStorageTest();
}
diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
index ff8d5f4e49492..7aef65cebee3e 100644
--- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_External\Tests\Service;
+use OC\User\User;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\StoragesService;
@@ -46,7 +47,7 @@ protected function setUp(): void {
$this->globalStoragesService = $this->service;
- $this->user = new \OC\User\User(self::USER_ID, null, \OC::$server->get(IEventDispatcher::class));
+ $this->user = new User(self::USER_ID, null, \OC::$server->get(IEventDispatcher::class));
/** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */
$userSession = $this->createMock(IUserSession::class);
$userSession
diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php
index cb7abfaf7251d..4a4404839a468 100644
--- a/apps/files_external/tests/Service/UserStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php
@@ -7,8 +7,10 @@
namespace OCA\Files_External\Tests\Service;
use OC\Files\Filesystem;
-
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
+
+use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserStoragesService;
@@ -85,7 +87,7 @@ public function testAddStorage(): void {
current(self::$hookCalls),
Filesystem::signal_create_mount,
$storage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$this->userId
);
@@ -136,7 +138,7 @@ public function testDeleteStorage($backendOptions, $rustyStorageId): void {
self::$hookCalls[1],
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$this->userId
);
}
@@ -157,21 +159,21 @@ public function testHooksRenameMountPoint(): void {
self::$hookCalls[0],
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$this->userId
);
$this->assertHookCall(
self::$hookCalls[1],
Filesystem::signal_create_mount,
'/renamedMountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$this->userId
);
}
public function testGetAdminStorage(): void {
- $this->expectException(\OCA\Files_External\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
diff --git a/apps/files_external/tests/Settings/AdminTest.php b/apps/files_external/tests/Settings/AdminTest.php
index 602e0124950ec..aceb8d2e915bd 100644
--- a/apps/files_external/tests/Settings/AdminTest.php
+++ b/apps/files_external/tests/Settings/AdminTest.php
@@ -6,6 +6,7 @@
namespace OCA\Files_External\Tests\Settings;
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Settings\Admin;
@@ -76,7 +77,7 @@ public function testGetForm(): void {
'storages' => ['a', 'b', 'c'],
'backends' => ['d', 'e', 'f'],
'authMechanisms' => ['g', 'h', 'i'],
- 'dependencies' => \OCA\Files_External\MountConfig::dependencyMessage($this->backendService->getBackends()),
+ 'dependencies' => MountConfig::dependencyMessage($this->backendService->getBackends()),
'allowUserMounting' => true,
'globalCredentials' => 'asdf:asdf',
'globalCredentialsUid' => '',
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index e95723a7b11f2..6c0d5ca078148 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -120,9 +120,9 @@ public function registerMountProviders(IMountProviderCollection $mountProviderCo
public function registerEventsScripts(IEventDispatcher $dispatcher): void {
$dispatcher->addListener(ResourcesLoadAdditionalScriptsEvent::class, function (): void {
- \OCP\Util::addScript('files_sharing', 'collaboration');
+ Util::addScript('files_sharing', 'collaboration');
});
- $dispatcher->addListener(\OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent::class, function (): void {
+ $dispatcher->addListener(BeforeTemplateRenderedEvent::class, function (): void {
/**
* Always add main sharing script
*/
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php
index 94427f7a97974..ac44ae7c6ccf0 100644
--- a/apps/files_sharing/lib/Cache.php
+++ b/apps/files_sharing/lib/Cache.php
@@ -122,7 +122,7 @@ public function remove($file) {
parent::remove($file);
}
- public function moveFromCache(\OCP\Files\Cache\ICache $sourceCache, $sourcePath, $targetPath) {
+ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
$this->rootUnchanged = false;
return parent::moveFromCache($sourceCache, $sourcePath, $targetPath);
}
diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
index b61f9995c02f1..ce30cf373ec0c 100644
--- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
@@ -17,6 +17,7 @@
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\QueryException;
+use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IGroupManager;
@@ -105,7 +106,7 @@ private function formatShare(IShare $share): array {
}
$result['path'] = $userFolder->getRelativePath($node->getPath());
- if ($node instanceof \OCP\Files\Folder) {
+ if ($node instanceof Folder) {
$result['item_type'] = 'folder';
} else {
$result['item_type'] = 'file';
diff --git a/apps/files_sharing/lib/Controller/ExternalSharesController.php b/apps/files_sharing/lib/Controller/ExternalSharesController.php
index 70e9eb5c46514..210f174d89b65 100644
--- a/apps/files_sharing/lib/Controller/ExternalSharesController.php
+++ b/apps/files_sharing/lib/Controller/ExternalSharesController.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_Sharing\Controller;
+use OCA\Files_Sharing\External\Manager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
@@ -24,7 +25,7 @@ class ExternalSharesController extends Controller {
public function __construct(
string $appName,
IRequest $request,
- private \OCA\Files_Sharing\External\Manager $externalManager,
+ private Manager $externalManager,
private IClientService $clientService,
private IConfig $config,
) {
diff --git a/apps/files_sharing/lib/Controller/RemoteController.php b/apps/files_sharing/lib/Controller/RemoteController.php
index fd3bdf15613a7..cdac35e0d9ccb 100644
--- a/apps/files_sharing/lib/Controller/RemoteController.php
+++ b/apps/files_sharing/lib/Controller/RemoteController.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_Sharing\Controller;
+use OC\Files\View;
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\AppFramework\Http;
@@ -96,7 +97,7 @@ public function declineShare($id) {
* @return array enriched share info with data from the filecache
*/
private static function extendShareInfo($share) {
- $view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/');
+ $view = new View('/' . \OC_User::getUser() . '/files/');
$info = $view->getFileInfo($share['mountpoint']);
if ($info === false) {
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index cf83587467724..4cff998724207 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -12,11 +12,13 @@
use Exception;
use OC\Files\FileInfo;
use OC\Files\Storage\Wrapper\Wrapper;
+use OCA\Circles\Api\v1\Circles;
use OCA\Files\Helper;
use OCA\Files_Sharing\Exceptions\SharingRightsException;
use OCA\Files_Sharing\External\Storage;
use OCA\Files_Sharing\ResponseDefinitions;
use OCA\Files_Sharing\SharedStorage;
+use OCA\GlobalSiteSelector\Service\SlaveService;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
@@ -29,6 +31,7 @@
use OCP\AppFramework\OCSController;
use OCP\AppFramework\QueryException;
use OCP\Constants;
+use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
@@ -410,7 +413,7 @@ private function retrieveFederatedDisplayName(array $userIds, bool $cacheOnly =
}
try {
- $slaveService = Server::get(\OCA\GlobalSiteSelector\Service\SlaveService::class);
+ $slaveService = Server::get(SlaveService::class);
} catch (\Throwable $e) {
$this->logger->error(
$e->getMessage(),
@@ -619,7 +622,7 @@ public function createShare(
$permissions |= Constants::PERMISSION_READ;
}
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
// Single file shares should never have delete or create permissions
$permissions &= ~Constants::PERMISSION_DELETE;
$permissions &= ~Constants::PERMISSION_CREATE;
@@ -695,7 +698,7 @@ public function createShare(
}
// Public upload can only be set for folders
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
throw new OCSNotFoundException($this->l->t('Public upload is only possible for publicly shared folders'));
}
@@ -766,7 +769,7 @@ public function createShare(
throw new OCSNotFoundException($this->l->t('You cannot share to a Team if the app is not enabled'));
}
- $circle = \OCA\Circles\Api\v1\Circles::detailsCircle($shareWith);
+ $circle = Circles::detailsCircle($shareWith);
// Valid team is required to share
if ($circle === null) {
@@ -864,7 +867,7 @@ private function getSharedWithMe($node, bool $includeTags): array {
* @throws NotFoundException
*/
private function getSharesInDir(Node $folder): array {
- if (!($folder instanceof \OCP\Files\Folder)) {
+ if (!($folder instanceof Folder)) {
throw new OCSBadRequestException($this->l->t('Not a directory'));
}
@@ -1066,7 +1069,7 @@ public function getInheritedShares(string $path): DataResponse {
try {
$node = $userFolder->get($path);
$this->lock($node);
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
throw new OCSNotFoundException($this->l->t('Wrong path, file/folder does not exist'));
} catch (LockedException $e) {
throw new OCSNotFoundException($this->l->t('Could not lock path'));
@@ -1287,7 +1290,7 @@ public function updateShare(
throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
}
- if (!($share->getNode() instanceof \OCP\Files\Folder)) {
+ if (!($share->getNode() instanceof Folder)) {
throw new OCSBadRequestException($this->l->t('Public upload is only possible for publicly shared folders'));
}
@@ -1458,7 +1461,7 @@ public function acceptShare(string $id): DataResponse {
*
* @suppress PhanUndeclaredClassMethod
*/
- protected function canAccessShare(\OCP\Share\IShare $share, bool $checkGroups = true): bool {
+ protected function canAccessShare(IShare $share, bool $checkGroups = true): bool {
// A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) {
return false;
@@ -1531,7 +1534,7 @@ protected function canAccessShare(\OCP\Share\IShare $share, bool $checkGroups =
* @param \OCP\Share\IShare $share the share to check
* @return boolean
*/
- protected function canEditShare(\OCP\Share\IShare $share): bool {
+ protected function canEditShare(IShare $share): bool {
// A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) {
return false;
@@ -1558,7 +1561,7 @@ protected function canEditShare(\OCP\Share\IShare $share): bool {
* @param \OCP\Share\IShare $share the share to check
* @return boolean
*/
- protected function canDeleteShare(\OCP\Share\IShare $share): bool {
+ protected function canDeleteShare(IShare $share): bool {
// A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) {
return false;
@@ -1595,7 +1598,7 @@ protected function canDeleteShare(\OCP\Share\IShare $share): bool {
*
* @suppress PhanUndeclaredClassMethod
*/
- protected function canDeleteShareFromSelf(\OCP\Share\IShare $share): bool {
+ protected function canDeleteShareFromSelf(IShare $share): bool {
if ($share->getShareType() !== IShare::TYPE_GROUP &&
$share->getShareType() !== IShare::TYPE_ROOM &&
$share->getShareType() !== IShare::TYPE_DECK &&
@@ -1746,7 +1749,7 @@ private function getShareById(string $id): IShare {
* @param \OCP\Files\Node $node
* @throws LockedException
*/
- private function lock(\OCP\Files\Node $node) {
+ private function lock(Node $node) {
$node->lock(ILockingProvider::LOCK_SHARED);
$this->lockedNode = $node;
}
@@ -1923,7 +1926,7 @@ private function shareProviderResharingRights(string $userId, IShare $share, $no
return true;
}
- if ((\OCP\Constants::PERMISSION_SHARE & $share->getPermissions()) === 0) {
+ if ((Constants::PERMISSION_SHARE & $share->getPermissions()) === 0) {
return false;
}
@@ -1946,7 +1949,7 @@ private function shareProviderResharingRights(string $userId, IShare $share, $no
$sharedWith = substr($share->getSharedWith(), $shareWithStart, $shareWithLength);
}
try {
- $member = \OCA\Circles\Api\v1\Circles::getMember($sharedWith, $userId, 1);
+ $member = Circles::getMember($sharedWith, $userId, 1);
if ($member->getLevel() >= 4) {
return true;
}
@@ -2065,7 +2068,7 @@ private function checkInheritedAttributes(IShare $share): void {
} else {
throw new \RuntimeException('Should not happen, instanceOfStorage but not a wrapper');
}
- /** @var \OCA\Files_Sharing\SharedStorage $storage */
+ /** @var SharedStorage $storage */
$inheritedAttributes = $storage->getShare()->getAttributes();
if ($inheritedAttributes !== null && $inheritedAttributes->getAttribute('permissions', 'download') === false) {
$share->setHideDownload(true);
diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php
index 17b9c2a2196e1..fed4bccb656ef 100644
--- a/apps/files_sharing/lib/Controller/ShareController.php
+++ b/apps/files_sharing/lib/Controller/ShareController.php
@@ -19,12 +19,16 @@
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\Attribute\PublicPage;
+use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Constants;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
+use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IL10N;
@@ -47,7 +51,7 @@
*/
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
class ShareController extends AuthPublicShareController {
- protected ?Share\IShare $share = null;
+ protected ?IShare $share = null;
public const SHARE_ACCESS = 'access';
public const SHARE_AUTH = 'auth';
@@ -218,7 +222,7 @@ protected function emitAccessShareHook($share, int $errorCode = 200, string $err
$itemType = $itemSource = $uidOwner = '';
$token = $share;
$exception = null;
- if ($share instanceof \OCP\Share\IShare) {
+ if ($share instanceof IShare) {
try {
$token = $share->getToken();
$uidOwner = $share->getSharedBy();
@@ -262,7 +266,7 @@ protected function emitShareAccessEvent(IShare $share, string $step = '', int $e
* @param Share\IShare $share
* @return bool
*/
- private function validateShare(\OCP\Share\IShare $share) {
+ private function validateShare(IShare $share) {
// If the owner is disabled no access to the link is granted
$owner = $this->userManager->get($share->getShareOwner());
if ($owner === null || !$owner->isEnabled()) {
@@ -315,7 +319,7 @@ public function showShare($path = ''): TemplateResponse {
// We can't get the path of a file share
try {
- if ($shareNode instanceof \OCP\Files\File && $path !== '') {
+ if ($shareNode instanceof File && $path !== '') {
$this->emitAccessShareHook($share, 404, 'Share not found');
$this->emitShareAccessEvent($share, self::SHARE_ACCESS, 404, 'Share not found');
throw new NotFoundException($this->l10n->t('This share does not exist or is no longer available'));
@@ -350,8 +354,8 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS
$share = $this->shareManager->getShareByToken($token);
- if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
- return new \OCP\AppFramework\Http\DataResponse('Share has no read permission');
+ if (!($share->getPermissions() & Constants::PERMISSION_READ)) {
+ return new DataResponse('Share has no read permission');
}
$files_list = null;
@@ -376,7 +380,7 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS
// Single file share
- if ($share->getNode() instanceof \OCP\Files\File) {
+ if ($share->getNode() instanceof File) {
// Single file download
$this->singleFileDownloaded($share, $share->getNode());
}
@@ -398,7 +402,7 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS
$originalSharePath = $userFolder->getRelativePath($node->getPath());
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
// Single file download
$this->singleFileDownloaded($share, $share->getNode());
} else {
@@ -465,7 +469,7 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS
* @param \OCP\Files\Folder $node
* @throws NotFoundException when trying to download a folder or multiple files of a "hide download" share
*/
- protected function fileListDownloaded(Share\IShare $share, array $files_list, \OCP\Files\Folder $node) {
+ protected function fileListDownloaded(IShare $share, array $files_list, Folder $node) {
if ($share->getHideDownload() && count($files_list) > 1) {
throw new NotFoundException('Downloading more than 1 file');
}
@@ -482,7 +486,7 @@ protected function fileListDownloaded(Share\IShare $share, array $files_list, \O
* @param Share\IShare $share
* @throws NotFoundException when trying to download a folder of a "hide download" share
*/
- protected function singleFileDownloaded(Share\IShare $share, \OCP\Files\Node $node) {
+ protected function singleFileDownloaded(IShare $share, Node $node) {
if ($share->getHideDownload() && $node instanceof Folder) {
throw new NotFoundException('Downloading a folder');
}
@@ -502,14 +506,14 @@ protected function singleFileDownloaded(Share\IShare $share, \OCP\Files\Node $no
$parameters = [$userPath];
if ($share->getShareType() === IShare::TYPE_EMAIL) {
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
$subject = Downloads::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED;
} else {
$subject = Downloads::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED;
}
$parameters[] = $share->getSharedWith();
} else {
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
$subject = Downloads::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED;
$parameters[] = $remoteAddressHash;
} else {
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index f177cb9d1ee3a..606a3d11de6dd 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -10,6 +10,7 @@
use Generator;
use OC\Collaboration\Collaborators\SearchResult;
+use OC\Share\Share;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
@@ -362,7 +363,7 @@ public function findRecommended(string $itemType, $shareType = null): DataRespon
protected function isRemoteSharingAllowed(string $itemType): bool {
try {
// FIXME: static foo makes unit testing unnecessarily difficult
- $backend = \OC\Share\Share::getBackend($itemType);
+ $backend = Share::getBackend($itemType);
return $backend->isShareTypeAllowed(IShare::TYPE_REMOTE);
} catch (\Exception $e) {
return false;
@@ -372,7 +373,7 @@ protected function isRemoteSharingAllowed(string $itemType): bool {
protected function isRemoteGroupSharingAllowed(string $itemType): bool {
try {
// FIXME: static foo makes unit testing unnecessarily difficult
- $backend = \OC\Share\Share::getBackend($itemType);
+ $backend = Share::getBackend($itemType);
return $backend->isShareTypeAllowed(IShare::TYPE_REMOTE_GROUP);
} catch (\Exception $e) {
return false;
diff --git a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
index bea48f28dee0f..dad1f3324588b 100644
--- a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
+++ b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
@@ -20,6 +20,7 @@
use OCP\AppFramework\Http\Template\SimpleMenuAction;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
+use OCP\Constants;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\File;
@@ -78,8 +79,8 @@ public function renderPage(IShare $share, string $token, string $path): Template
if ($shareNode instanceof File) {
$view = 'public-file-share';
$this->initialState->provideInitialState('fileId', $shareNode->getId());
- } elseif (($share->getPermissions() & \OCP\Constants::PERMISSION_CREATE)
- && !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)
+ } elseif (($share->getPermissions() & Constants::PERMISSION_CREATE)
+ && !($share->getPermissions() & Constants::PERMISSION_READ)
) {
// share is a folder with create but no read permissions -> file drop only
$view = 'public-file-drop';
@@ -97,10 +98,10 @@ public function renderPage(IShare $share, string $token, string $path): Template
$this->initialState->provideInitialState('view', $view);
// Load scripts and styles for UI
- \OCP\Util::addInitScript('files', 'init');
- \OCP\Util::addInitScript(Application::APP_ID, 'init');
- \OCP\Util::addInitScript(Application::APP_ID, 'init-public');
- \OCP\Util::addScript('files', 'main');
+ Util::addInitScript('files', 'init');
+ Util::addInitScript(Application::APP_ID, 'init');
+ Util::addInitScript(Application::APP_ID, 'init-public');
+ Util::addScript('files', 'main');
// Add file-request script if needed
$attributes = $share->getAttributes();
@@ -171,7 +172,7 @@ public function renderPage(IShare $share, string $token, string $path): Template
if ($shareNode->getMimePart() === 'image') {
// If this is a file and especially an image directly point to the image preview
$directLink = $this->urlGenerator->linkToRouteAbsolute('files_sharing.publicpreview.directLink', ['token' => $token]);
- } elseif (($share->getPermissions() & \OCP\Constants::PERMISSION_READ) && !$share->getHideDownload()) {
+ } elseif (($share->getPermissions() & Constants::PERMISSION_READ) && !$share->getHideDownload()) {
// Can read and no download restriction, so just download it
$directLink = $downloadUrl ?? $shareUrl;
}
diff --git a/apps/files_sharing/lib/External/Cache.php b/apps/files_sharing/lib/External/Cache.php
index 7fad71b9084cc..deef16c0f1a7e 100644
--- a/apps/files_sharing/lib/External/Cache.php
+++ b/apps/files_sharing/lib/External/Cache.php
@@ -16,7 +16,7 @@ class Cache extends \OC\Files\Cache\Cache {
private $storage;
/**
- * @param \OCA\Files_Sharing\External\Storage $storage
+ * @param Storage $storage
* @param ICloudId $cloudId
*/
public function __construct($storage, ICloudId $cloudId) {
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php
index 86c9ae830e4ab..58e24a96338bb 100644
--- a/apps/files_sharing/lib/External/Manager.php
+++ b/apps/files_sharing/lib/External/Manager.php
@@ -16,6 +16,7 @@
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Files;
+use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorageFactory;
use OCP\Http\Client\IClientService;
@@ -347,7 +348,7 @@ public function acceptShare($id) {
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept');
$event = new FederatedShareAddedEvent($share['remote']);
$this->eventDispatcher->dispatchTyped($event);
- $this->eventDispatcher->dispatchTyped(new Files\Events\InvalidateMountCacheEvent($this->userManager->get($this->uid)));
+ $this->eventDispatcher->dispatchTyped(new InvalidateMountCacheEvent($this->userManager->get($this->uid)));
$result = true;
}
}
@@ -567,7 +568,7 @@ public function setMountPoint($source, $target) {
');
$result = (bool)$query->execute([$target, $targetHash, $sourceHash, $this->uid]);
- $this->eventDispatcher->dispatchTyped(new Files\Events\InvalidateMountCacheEvent($this->userManager->get($this->uid)));
+ $this->eventDispatcher->dispatchTyped(new InvalidateMountCacheEvent($this->userManager->get($this->uid)));
return $result;
}
diff --git a/apps/files_sharing/lib/External/Mount.php b/apps/files_sharing/lib/External/Mount.php
index 685e931e3bc1f..fd615ac5b023b 100644
--- a/apps/files_sharing/lib/External/Mount.php
+++ b/apps/files_sharing/lib/External/Mount.php
@@ -13,7 +13,7 @@
class Mount extends MountPoint implements MoveableMount, ISharedMountPoint {
/**
- * @var \OCA\Files_Sharing\External\Manager
+ * @var Manager
*/
protected $manager;
@@ -21,7 +21,7 @@ class Mount extends MountPoint implements MoveableMount, ISharedMountPoint {
* @param string|\OC\Files\Storage\Storage $storage
* @param string $mountpoint
* @param array $options
- * @param \OCA\Files_Sharing\External\Manager $manager
+ * @param Manager $manager
* @param \OC\Files\Storage\StorageFactory $loader
*/
public function __construct($storage, $mountpoint, $options, $manager, $loader = null) {
diff --git a/apps/files_sharing/lib/External/Scanner.php b/apps/files_sharing/lib/External/Scanner.php
index 63757d44f4618..d3b54e0f0f6fc 100644
--- a/apps/files_sharing/lib/External/Scanner.php
+++ b/apps/files_sharing/lib/External/Scanner.php
@@ -12,7 +12,7 @@
use OCP\Files\StorageNotAvailableException;
class Scanner extends \OC\Files\Cache\Scanner {
- /** @var \OCA\Files_Sharing\External\Storage */
+ /** @var Storage */
protected $storage;
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php
index ba237f6c5efde..3c1731cd7fa17 100644
--- a/apps/files_sharing/lib/External/Storage.php
+++ b/apps/files_sharing/lib/External/Storage.php
@@ -13,6 +13,7 @@
use GuzzleHttp\Exception\RequestException;
use OC\Files\Storage\DAV;
use OC\ForbiddenException;
+use OC\Share\Share;
use OCA\Files_Sharing\External\Manager as ExternalShareManager;
use OCA\Files_Sharing\ISharedStorage;
use OCP\AppFramework\Http;
@@ -31,6 +32,7 @@
use OCP\OCM\Exceptions\OCMProviderException;
use OCP\OCM\IOCMDiscoveryService;
use OCP\Server;
+use OCP\Util;
use Psr\Log\LoggerInterface;
class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, IReliableEtagStorage {
@@ -144,7 +146,7 @@ public function getScanner($path = '', $storage = null) {
if (!isset($this->scanner)) {
$this->scanner = new Scanner($storage);
}
- /** @var \OCA\Files_Sharing\External\Scanner */
+ /** @var Scanner */
return $this->scanner;
}
@@ -337,7 +339,7 @@ public function getOwner($path): string|false {
}
public function isSharable($path): bool {
- if (\OCP\Util::isSharingDisabledForUser() || !\OC\Share\Share::isResharingAllowed()) {
+ if (Util::isSharingDisabledForUser() || !Share::isResharingAllowed()) {
return false;
}
return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE);
diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php
index 8efcb7cae7b5b..538e37fa88e6f 100644
--- a/apps/files_sharing/lib/Helper.php
+++ b/apps/files_sharing/lib/Helper.php
@@ -9,13 +9,14 @@
use OC\Files\Filesystem;
use OC\Files\View;
use OCA\Files_Sharing\AppInfo\Application;
+use OCP\Util;
class Helper {
public static function registerHooks() {
- \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook');
- \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
+ Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook');
+ Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
- \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser');
+ Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser');
}
/**
diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php
index a6ab3f16f29d7..a3581c111dd07 100644
--- a/apps/files_sharing/lib/Hooks.php
+++ b/apps/files_sharing/lib/Hooks.php
@@ -7,20 +7,22 @@
namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
+use OC\Files\View;
+use OCA\Files_Sharing\External\Manager;
class Hooks {
public static function deleteUser($params) {
- $manager = \OC::$server->get(External\Manager::class);
+ $manager = \OC::$server->get(Manager::class);
$manager->removeUserShares($params['uid']);
}
public static function unshareChildren($params) {
$path = Filesystem::getView()->getAbsolutePath($params['path']);
- $view = new \OC\Files\View('/');
+ $view = new View('/');
// find share mount points within $path and unmount them
- $mountManager = \OC\Files\Filesystem::getMountManager();
+ $mountManager = Filesystem::getMountManager();
$mountedShares = $mountManager->findIn($path);
foreach ($mountedShares as $mount) {
if ($mount->getStorage()->instanceOfStorage(ISharedStorage::class)) {
diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php
index 5313f40ff6bbe..06e3ed1e147e2 100644
--- a/apps/files_sharing/lib/MountProvider.php
+++ b/apps/files_sharing/lib/MountProvider.php
@@ -51,7 +51,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
// filter out excluded shares and group shares that includes self
- $shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) {
+ $shares = array_filter($shares, function (IShare $share) use ($user) {
return $share->getPermissions() > 0 && $share->getShareOwner() !== $user->getUID();
});
@@ -165,7 +165,7 @@ private function groupShares(array $shares) {
* @param \OCP\IUser $user user
* @return array Tuple of [superShare, groupedShares]
*/
- private function buildSuperShares(array $allShares, \OCP\IUser $user) {
+ private function buildSuperShares(array $allShares, IUser $user) {
$result = [];
$groupedShares = $this->groupShares($allShares);
diff --git a/apps/files_sharing/lib/Scanner.php b/apps/files_sharing/lib/Scanner.php
index 1ff1046bce778..ec0959088ce6b 100644
--- a/apps/files_sharing/lib/Scanner.php
+++ b/apps/files_sharing/lib/Scanner.php
@@ -14,7 +14,7 @@
*/
class Scanner extends \OC\Files\Cache\Scanner {
/**
- * @var \OCA\Files_Sharing\SharedStorage $storage
+ * @var SharedStorage $storage
*/
protected $storage;
diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php
index 4d93232b6389e..0b7ec58aef33d 100644
--- a/apps/files_sharing/lib/ShareBackend/File.php
+++ b/apps/files_sharing/lib/ShareBackend/File.php
@@ -6,11 +6,17 @@
*/
namespace OCA\Files_Sharing\ShareBackend;
+use OC\Files\Filesystem;
+use OC\Files\View;
use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCA\Files_Sharing\Helper;
+use OCP\Files\NotFoundException;
+use OCP\Server;
use OCP\Share\IShare;
+use OCP\Share_Backend_File_Dependent;
use Psr\Log\LoggerInterface;
-class File implements \OCP\Share_Backend_File_Dependent {
+class File implements Share_Backend_File_Dependent {
public const FORMAT_SHARED_STORAGE = 0;
public const FORMAT_GET_FOLDER_CONTENTS = 1;
public const FORMAT_FILE_APP_ROOT = 2;
@@ -34,13 +40,13 @@ public function __construct(?FederatedShareProvider $federatedShareProvider = nu
public function isValidSource($itemSource, $uidOwner) {
try {
- $path = \OC\Files\Filesystem::getPath($itemSource);
+ $path = Filesystem::getPath($itemSource);
// FIXME: attributes should not be set here,
// keeping this pattern for now to avoid unexpected
// regressions
- $this->path = \OC\Files\Filesystem::normalizePath(basename($path));
+ $this->path = Filesystem::normalizePath(basename($path));
return true;
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
return false;
}
}
@@ -52,9 +58,9 @@ public function getFilePath($itemSource, $uidOwner) {
return $path;
} else {
try {
- $path = \OC\Files\Filesystem::getPath($itemSource);
+ $path = Filesystem::getPath($itemSource);
return $path;
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
return false;
}
}
@@ -68,11 +74,11 @@ public function getFilePath($itemSource, $uidOwner) {
* @return string
*/
public function generateTarget($itemSource, $shareWith) {
- $shareFolder = \OCA\Files_Sharing\Helper::getShareFolder();
- $target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . basename($itemSource));
+ $shareFolder = Helper::getShareFolder();
+ $target = Filesystem::normalizePath($shareFolder . '/' . basename($itemSource));
- \OC\Files\Filesystem::initMountPoints($shareWith);
- $view = new \OC\Files\View('/' . $shareWith . '/files');
+ Filesystem::initMountPoints($shareWith);
+ $view = new View('/' . $shareWith . '/files');
if (!$view->is_dir($shareFolder)) {
$dir = '';
@@ -85,7 +91,7 @@ public function generateTarget($itemSource, $shareWith) {
}
}
- return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $view);
+ return Helper::generateUniqueTarget($target, $view);
}
public function formatItems($items, $format, $parameters = null) {
@@ -116,7 +122,7 @@ public function formatItems($items, $format, $parameters = null) {
$file['uid_owner'] = $item['uid_owner'];
$file['displayname_owner'] = $item['displayname_owner'];
- $storage = \OC\Files\Filesystem::getStorage('/');
+ $storage = Filesystem::getStorage('/');
$cache = $storage->getCache();
$file['size'] = $item['size'];
$files[] = $file;
@@ -199,7 +205,7 @@ protected static function resolveReshares($source) {
if (isset($fileOwner)) {
$source['fileOwner'] = $fileOwner;
} else {
- \OCP\Server::get(LoggerInterface::class)->error('No owner found for reshare', ['app' => 'files_sharing']);
+ Server::get(LoggerInterface::class)->error('No owner found for reshare', ['app' => 'files_sharing']);
}
return $source;
diff --git a/apps/files_sharing/lib/ShareBackend/Folder.php b/apps/files_sharing/lib/ShareBackend/Folder.php
index f64d44faefcee..fefdd7f667ce8 100644
--- a/apps/files_sharing/lib/ShareBackend/Folder.php
+++ b/apps/files_sharing/lib/ShareBackend/Folder.php
@@ -6,7 +6,9 @@
*/
namespace OCA\Files_Sharing\ShareBackend;
-class Folder extends File implements \OCP\Share_Backend_Collection {
+use OCP\Share_Backend_Collection;
+
+class Folder extends File implements Share_Backend_Collection {
public function getChildren($itemSource) {
$children = [];
$parents = [$itemSource];
diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php
index ddd6af3845da6..420de6889bf36 100644
--- a/apps/files_sharing/lib/SharedMount.php
+++ b/apps/files_sharing/lib/SharedMount.php
@@ -11,13 +11,16 @@
use OC\Files\Mount\MountPoint;
use OC\Files\Mount\MoveableMount;
use OC\Files\View;
+use OCA\Files_Sharing\Exceptions\BrokenPath;
use OCP\Cache\CappedMemoryCache;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\Storage\IStorageFactory;
use OCP\ICache;
use OCP\IUser;
+use OCP\Server;
use OCP\Share\Events\VerifyMountPointEvent;
+use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
/**
@@ -25,7 +28,7 @@
*/
class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint {
/**
- * @var \OCA\Files_Sharing\SharedStorage $storage
+ * @var SharedStorage $storage
*/
protected $storage = null;
@@ -79,7 +82,7 @@ public function __construct(
* @return string
*/
private function verifyMountPoint(
- \OCP\Share\IShare $share,
+ IShare $share,
array $mountpoints,
CappedMemoryCache $folderExistCache,
) {
@@ -108,7 +111,7 @@ private function verifyMountPoint(
}
$newMountPoint = $this->generateUniqueTarget(
- \OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint),
+ Filesystem::normalizePath($parent . '/' . $mountPoint),
$this->recipientView,
$mountpoints
);
@@ -169,7 +172,7 @@ private function generateUniqueTarget($path, $view, array $mountpoints) {
*
* @param string $path the absolute path
* @return string e.g. turns '/admin/files/test.txt' into '/test.txt'
- * @throws \OCA\Files_Sharing\Exceptions\BrokenPath
+ * @throws BrokenPath
*/
protected function stripUserFilesPath($path) {
$trimmed = ltrim($path, '/');
@@ -177,8 +180,8 @@ protected function stripUserFilesPath($path) {
// it is not a file relative to data/user/files
if (count($split) < 3 || $split[1] !== 'files') {
- \OCP\Server::get(LoggerInterface::class)->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']);
- throw new \OCA\Files_Sharing\Exceptions\BrokenPath('Path does not start with /user/files', 10);
+ Server::get(LoggerInterface::class)->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']);
+ throw new BrokenPath('Path does not start with /user/files', 10);
}
// skip 'user' and 'files'
@@ -205,7 +208,7 @@ public function moveMount($target) {
$this->setMountPoint($target);
$this->storage->setMountPoint($relTargetPath);
} catch (\Exception $e) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"',
[
'app' => 'files_sharing',
@@ -223,8 +226,8 @@ public function moveMount($target) {
* @return bool
*/
public function removeMount() {
- $mountManager = \OC\Files\Filesystem::getMountManager();
- /** @var \OCA\Files_Sharing\SharedStorage $storage */
+ $mountManager = Filesystem::getMountManager();
+ /** @var SharedStorage $storage */
$storage = $this->getStorage();
$result = $storage->unshareStorage();
$mountManager->removeMount($this->mountPoint);
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index 0a6a068c44156..66c2540418b0c 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -14,8 +14,10 @@
use OC\Files\Storage\Common;
use OC\Files\Storage\FailedStorage;
use OC\Files\Storage\Home;
+use OC\Files\Storage\Wrapper\Jail;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OC\Files\Storage\Wrapper\Wrapper;
+use OC\Share\Share;
use OC\User\NoUserException;
use OCA\Files_External\Config\ConfigAdapter;
use OCA\Files_Sharing\ISharedStorage as LegacyISharedStorage;
@@ -32,12 +34,13 @@
use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider;
use OCP\Share\IShare;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
* Convert target path to source path and pass the function call to the correct storage provider
*/
-class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISharedStorage, ISharedStorage, IDisableEncryptionStorage {
+class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage, IDisableEncryptionStorage {
/** @var \OCP\Share\IShare */
private $superShare;
@@ -253,18 +256,18 @@ public function getPermissions($path = ''): int {
// part files and the mount point always have delete permissions
if ($path === '' || pathinfo($path, PATHINFO_EXTENSION) === 'part') {
- $permissions |= \OCP\Constants::PERMISSION_DELETE;
+ $permissions |= Constants::PERMISSION_DELETE;
}
if ($this->sharingDisabledForUser) {
- $permissions &= ~\OCP\Constants::PERMISSION_SHARE;
+ $permissions &= ~Constants::PERMISSION_SHARE;
}
return $permissions;
}
public function isCreatable($path): bool {
- return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_CREATE);
+ return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE);
}
public function isReadable($path): bool {
@@ -281,18 +284,18 @@ public function isReadable($path): bool {
}
public function isUpdatable($path): bool {
- return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_UPDATE);
+ return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE);
}
public function isDeletable($path): bool {
- return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_DELETE);
+ return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE);
}
public function isSharable($path): bool {
- if (\OCP\Util::isSharingDisabledForUser() || !\OC\Share\Share::isResharingAllowed()) {
+ if (Util::isSharingDisabledForUser() || !Share::isResharingAllowed()) {
return false;
}
- return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE);
+ return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE);
}
public function fopen($path, $mode) {
@@ -343,7 +346,7 @@ public function fopen($path, $mode) {
'source' => $source,
'mode' => $mode,
];
- \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info);
+ Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info);
return $this->nonMaskedStorage->fopen($this->getUnjailedPath($path), $mode);
}
@@ -430,7 +433,7 @@ public function getCache($path = '', $storage = null) {
return new FailedCache();
}
- $this->cache = new \OCA\Files_Sharing\Cache(
+ $this->cache = new Cache(
$storage,
$sourceRoot,
\OC::$server->get(CacheDependencies::class),
@@ -443,7 +446,7 @@ public function getScanner($path = '', $storage = null) {
if (!$storage) {
$storage = $this;
}
- return new \OCA\Files_Sharing\Scanner($storage);
+ return new Scanner($storage);
}
public function getOwner($path): string|false {
@@ -559,7 +562,7 @@ public function file_get_contents($path) {
'target' => $this->getMountPoint() . '/' . $path,
'source' => $this->getUnjailedPath($path),
];
- \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_get_contents', $info);
+ Util::emitHook('\OC\Files\Storage\Shared', 'file_get_contents', $info);
return parent::file_get_contents($path);
}
@@ -568,7 +571,7 @@ public function file_put_contents($path, $data) {
'target' => $this->getMountPoint() . '/' . $path,
'source' => $this->getUnjailedPath($path),
];
- \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_put_contents', $info);
+ Util::emitHook('\OC\Files\Storage\Shared', 'file_put_contents', $info);
return parent::file_put_contents($path, $data);
}
diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php
index 3a3813287b906..82075fb9ba5ca 100644
--- a/apps/files_sharing/lib/Updater.php
+++ b/apps/files_sharing/lib/Updater.php
@@ -7,6 +7,7 @@
namespace OCA\Files_Sharing;
use OC\Files\Cache\FileAccess;
+use OC\Files\Filesystem;
use OC\Files\Mount\MountPoint;
use OCP\Constants;
use OCP\Files\Folder;
@@ -96,7 +97,7 @@ private static function moveShareInOrOutOfShare($path): void {
continue;
}
- if ($dstMount instanceof \OCA\Files_Sharing\SharedMount) {
+ if ($dstMount instanceof SharedMount) {
if (!($dstMount->getShare()->getPermissions() & Constants::PERMISSION_SHARE)) {
$shareManager->deleteShare($share);
continue;
@@ -121,10 +122,10 @@ private static function moveShareInOrOutOfShare($path): void {
* @param string $newPath new path relative to data/user/files
*/
private static function renameChildren($oldPath, $newPath) {
- $absNewPath = \OC\Files\Filesystem::normalizePath('/' . \OC_User::getUser() . '/files/' . $newPath);
- $absOldPath = \OC\Files\Filesystem::normalizePath('/' . \OC_User::getUser() . '/files/' . $oldPath);
+ $absNewPath = Filesystem::normalizePath('/' . \OC_User::getUser() . '/files/' . $newPath);
+ $absOldPath = Filesystem::normalizePath('/' . \OC_User::getUser() . '/files/' . $oldPath);
- $mountManager = \OC\Files\Filesystem::getMountManager();
+ $mountManager = Filesystem::getMountManager();
$mountedShares = $mountManager->findIn('/' . \OC_User::getUser() . '/files/' . $oldPath);
foreach ($mountedShares as $mount) {
/** @var MountPoint $mount */
diff --git a/apps/files_sharing/lib/ViewOnly.php b/apps/files_sharing/lib/ViewOnly.php
index 7b52d79f4d047..2a837b627af84 100644
--- a/apps/files_sharing/lib/ViewOnly.php
+++ b/apps/files_sharing/lib/ViewOnly.php
@@ -88,7 +88,7 @@ private function checkFileInfo(Node $fileInfo): bool {
}
// Extract extra permissions
- /** @var \OCA\Files_Sharing\SharedStorage $storage */
+ /** @var SharedStorage $storage */
$share = $storage->getShare();
$canDownload = true;
diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php
index 4d50fb4065eba..d549d441df4ec 100644
--- a/apps/files_sharing/tests/ApiTest.php
+++ b/apps/files_sharing/tests/ApiTest.php
@@ -7,13 +7,17 @@
namespace OCA\Files_Sharing\Tests;
use OC\Files\Cache\Scanner;
+use OC\Files\FileInfo;
use OC\Files\Filesystem;
+use OC\Files\Storage\Temporary;
+use OC\Files\View;
use OCA\Files_Sharing\Controller\ShareAPIController;
use OCP\App\IAppManager;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCS\OCSNotFoundException;
+use OCP\Constants;
use OCP\IConfig;
use OCP\IDateTimeZone;
use OCP\IL10N;
@@ -72,7 +76,7 @@ protected function setUp(): void {
}
protected function tearDown(): void {
- if ($this->view instanceof \OC\Files\View) {
+ if ($this->view instanceof View) {
$this->view->unlink($this->filename);
$this->view->deleteAll($this->folder);
}
@@ -84,7 +88,7 @@ protected function tearDown(): void {
/**
* @param string $userId The userId of the caller
- * @return \OCA\Files_Sharing\Controller\ShareAPIController
+ * @return ShareAPIController
*/
private function createOCS($userId) {
$l = $this->getMockBuilder(IL10N::class)->getMock();
@@ -128,7 +132,7 @@ private function createOCS($userId) {
public function testCreateShareUserFile(): void {
$this->setUp(); // for some reasons phpunit refuses to do this for us only for this test
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $result = $ocs->createShare($this->filename, Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
@@ -145,7 +149,7 @@ public function testCreateShareUserFile(): void {
public function testCreateShareUserFolder(): void {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $result = $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
@@ -162,7 +166,7 @@ public function testCreateShareUserFolder(): void {
public function testCreateShareGroupFile(): void {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
+ $result = $ocs->createShare($this->filename, Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
$data = $result->getData();
@@ -178,7 +182,7 @@ public function testCreateShareGroupFile(): void {
public function testCreateShareGroupFolder(): void {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
+ $result = $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
$data = $result->getData();
@@ -197,11 +201,11 @@ public function testCreateShareGroupFolder(): void {
*/
public function testCreateShareLink(): void {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
+ $result = $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_LINK);
$ocs->cleanup();
$data = $result->getData();
- $this->assertEquals(\OCP\Constants::PERMISSION_ALL,
+ $this->assertEquals(Constants::PERMISSION_ALL,
$data['permissions']);
$this->assertEmpty($data['expiration']);
$this->assertTrue(is_string($data['token']));
@@ -222,16 +226,16 @@ public function testCreateShareLink(): void {
*/
public function testCreateShareLinkPublicUpload(): void {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true');
+ $result = $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true');
$ocs->cleanup();
$data = $result->getData();
$this->assertEquals(
- \OCP\Constants::PERMISSION_READ |
- \OCP\Constants::PERMISSION_CREATE |
- \OCP\Constants::PERMISSION_UPDATE |
- \OCP\Constants::PERMISSION_DELETE |
- \OCP\Constants::PERMISSION_SHARE,
+ Constants::PERMISSION_READ |
+ Constants::PERMISSION_CREATE |
+ Constants::PERMISSION_UPDATE |
+ Constants::PERMISSION_DELETE |
+ Constants::PERMISSION_SHARE,
$data['permissions']
);
$this->assertEmpty($data['expiration']);
@@ -255,7 +259,7 @@ public function testEnforceLinkPassword(): void {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
+ $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_LINK);
$this->fail();
} catch (OCSForbiddenException $e) {
}
@@ -263,7 +267,7 @@ public function testEnforceLinkPassword(): void {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '');
+ $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '');
$this->fail();
} catch (OCSForbiddenException $e) {
}
@@ -271,7 +275,7 @@ public function testEnforceLinkPassword(): void {
// share with password should succeed
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', $password);
+ $result = $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', $password);
$ocs->cleanup();
$data = $result->getData();
@@ -308,7 +312,7 @@ public function testSharePermissions(): void {
\OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no');
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $result = $ocs->createShare($this->filename, Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
@@ -324,7 +328,7 @@ public function testSharePermissions(): void {
\OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', 'admin,group1,group2');
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $result = $ocs->createShare($this->filename, Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
@@ -339,7 +343,7 @@ public function testSharePermissions(): void {
\OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', 'admin,group');
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $ocs->createShare($this->filename, Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
// cleanup
@@ -416,7 +420,7 @@ public function testGetAllSharesWithMe(): void {
*/
public function testPublicLinkUrl(): void {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
+ $result = $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_LINK);
$ocs->cleanup();
$data = $result->getData();
@@ -1008,11 +1012,11 @@ public function testUpdateShareUpload(): void {
$share1 = $this->shareManager->getShareById($share1->getFullId());
$this->assertEquals(
- \OCP\Constants::PERMISSION_READ |
- \OCP\Constants::PERMISSION_CREATE |
- \OCP\Constants::PERMISSION_UPDATE |
- \OCP\Constants::PERMISSION_DELETE |
- \OCP\Constants::PERMISSION_SHARE,
+ Constants::PERMISSION_READ |
+ Constants::PERMISSION_CREATE |
+ Constants::PERMISSION_UPDATE |
+ Constants::PERMISSION_DELETE |
+ Constants::PERMISSION_SHARE,
$share1->getPermissions()
);
@@ -1172,7 +1176,7 @@ public function testShareFolderWithAMountPoint(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
@@ -1180,7 +1184,7 @@ public function testShareFolderWithAMountPoint(): void {
// user2 shares a file from the folder as link
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $view = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$view->mkdir('localDir');
// move mount point to the folder "localDir"
@@ -1190,7 +1194,7 @@ public function testShareFolderWithAMountPoint(): void {
// try to share "localDir"
$fileInfo2 = $view->getFileInfo('localDir');
- $this->assertTrue($fileInfo2 instanceof \OC\Files\FileInfo);
+ $this->assertTrue($fileInfo2 instanceof FileInfo);
$pass = true;
try {
@@ -1199,7 +1203,7 @@ public function testShareFolderWithAMountPoint(): void {
'localDir',
self::TEST_FILES_SHARING_API_USER2,
self::TEST_FILES_SHARING_API_USER3,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
} catch (\Exception $e) {
$pass = false;
@@ -1223,7 +1227,7 @@ public function testShareFolderWithAMountPoint(): void {
*/
public static function initTestMountPointsHook($data) {
if ($data['user'] === self::TEST_FILES_SHARING_API_USER1) {
- \OC\Files\Filesystem::mount(self::$tempStorage, [], '/' . self::TEST_FILES_SHARING_API_USER1 . '/files' . self::TEST_FOLDER_NAME);
+ Filesystem::mount(self::$tempStorage, [], '/' . self::TEST_FILES_SHARING_API_USER1 . '/files' . self::TEST_FOLDER_NAME);
}
}
@@ -1231,7 +1235,7 @@ public static function initTestMountPointsHook($data) {
* Tests mounting a folder that is an external storage mount point.
*/
public function testShareStorageMountPoint(): void {
- $tempStorage = new \OC\Files\Storage\Temporary([]);
+ $tempStorage = new Temporary([]);
$tempStorage->file_put_contents('test.txt', 'abcdef');
$tempStorage->getScanner()->scan('');
@@ -1246,7 +1250,7 @@ public function testShareStorageMountPoint(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
@@ -1254,7 +1258,7 @@ public function testShareStorageMountPoint(): void {
// user2: check that mount point name appears correctly
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $view = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$this->assertTrue($view->file_exists($this->folder));
$this->assertTrue($view->file_exists($this->folder . '/test.txt'));
@@ -1290,7 +1294,7 @@ public function testPublicLinkExpireDate($date, $valid): void {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try {
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date);
+ $result = $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date);
$this->assertTrue($valid);
} catch (OCSNotFoundException $e) {
$this->assertFalse($valid);
@@ -1329,7 +1333,7 @@ public function testCreatePublicLinkExpireDateValid(): void {
$date->add(new \DateInterval('P5D'));
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
+ $result = $ocs->createShare($this->filename, Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
$ocs->cleanup();
$data = $result->getData();
@@ -1363,7 +1367,7 @@ public function testCreatePublicLinkExpireDateInvalidFuture(): void {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
+ $ocs->createShare($this->filename, Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
$this->fail();
} catch (OCSException $e) {
$this->assertEquals(404, $e->getCode());
@@ -1384,7 +1388,7 @@ public function XtestCreatePublicLinkExpireDateInvalidPast() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
+ $ocs->createShare($this->filename, Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
$this->fail();
} catch (OCSException $e) {
$this->assertEquals(404, $e->getCode());
@@ -1403,7 +1407,7 @@ public function XtestCreatePublicLinkExpireDateInvalidPast() {
public function testInvisibleSharesUser(): void {
// simulate a post request
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $result = $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
@@ -1414,7 +1418,7 @@ public function testInvisibleSharesUser(): void {
$ocs->cleanup();
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2);
- $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
+ $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_LINK);
$ocs->cleanup();
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
@@ -1435,7 +1439,7 @@ public function testInvisibleSharesUser(): void {
public function testInvisibleSharesGroup(): void {
// simulate a post request
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
+ $result = $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
$data = $result->getData();
@@ -1448,7 +1452,7 @@ public function testInvisibleSharesGroup(): void {
\OC_Util::tearDownFS();
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2);
- $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
+ $ocs->createShare($this->folder, Constants::PERMISSION_ALL, IShare::TYPE_LINK);
$ocs->cleanup();
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php
index ebcfc43edadae..1d622e6a14a9e 100644
--- a/apps/files_sharing/tests/CacheTest.php
+++ b/apps/files_sharing/tests/CacheTest.php
@@ -6,9 +6,12 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OC\Files\Filesystem;
use OC\Files\Storage\Temporary;
use OC\Files\Storage\Wrapper\Jail;
+use OC\Files\View;
use OCA\Files_Sharing\SharedStorage;
+use OCP\Constants;
use OCP\Share\IShare;
/**
@@ -50,7 +53,7 @@ protected function setUp(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $this->user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $this->user2View = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
// prepare user1's dir structure
$this->view->mkdir('container');
@@ -80,7 +83,7 @@ protected function setUp(): void {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
@@ -91,7 +94,7 @@ protected function setUp(): void {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE));
+ ->setPermissions(Constants::PERMISSION_ALL & ~(Constants::PERMISSION_CREATE | Constants::PERMISSION_DELETE));
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
@@ -100,7 +103,7 @@ protected function setUp(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// retrieve the shared storage
- $secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
+ $secondView = new View('/' . self::TEST_FILES_SHARING_API_USER2);
[$this->sharedStorage,] = $secondView->resolvePath('files/shareddir');
$this->sharedCache = $this->sharedStorage->getCache();
}
@@ -297,7 +300,7 @@ public function testShareRenameOriginalFileInRecentResults(): void {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_READ);
+ ->setPermissions(Constants::PERMISSION_READ);
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
@@ -326,14 +329,14 @@ public function testGetFolderContentsWhenSubSubdirShared(): void {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
- $thirdView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
+ $thirdView = new View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
$results = $thirdView->getDirectoryContent('/subdir');
$this->verifyFiles(
@@ -402,8 +405,8 @@ private function verifyKeys($example, $result) {
public function testGetPathByIdDirectShare(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OC\Files\Filesystem::file_put_contents('test.txt', 'foo');
- $info = \OC\Files\Filesystem::getFileInfo('test.txt');
+ Filesystem::file_put_contents('test.txt', 'foo');
+ $info = Filesystem::getFileInfo('test.txt');
$rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
$node = $rootFolder->get('test.txt');
@@ -412,7 +415,7 @@ public function testGetPathByIdDirectShare(): void {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
+ ->setPermissions(Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE);
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
@@ -420,23 +423,22 @@ public function testGetPathByIdDirectShare(): void {
\OC_Util::tearDownFS();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists('/test.txt'));
- [$sharedStorage] = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/test.txt');
+ $this->assertTrue(Filesystem::file_exists('/test.txt'));
+ [$sharedStorage] = Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/test.txt');
/**
- * @var \OCA\Files_Sharing\SharedStorage $sharedStorage
+ * @var SharedStorage $sharedStorage
*/
-
$sharedCache = $sharedStorage->getCache();
$this->assertEquals('', $sharedCache->getPathById($info->getId()));
}
public function testGetPathByIdShareSubFolder(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OC\Files\Filesystem::mkdir('foo');
- \OC\Files\Filesystem::mkdir('foo/bar');
- \OC\Files\Filesystem::touch('foo/bar/test.txt');
- $folderInfo = \OC\Files\Filesystem::getFileInfo('foo');
- $fileInfo = \OC\Files\Filesystem::getFileInfo('foo/bar/test.txt');
+ Filesystem::mkdir('foo');
+ Filesystem::mkdir('foo/bar');
+ Filesystem::touch('foo/bar/test.txt');
+ $folderInfo = Filesystem::getFileInfo('foo');
+ $fileInfo = Filesystem::getFileInfo('foo/bar/test.txt');
$rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
$node = $rootFolder->get('foo');
@@ -445,19 +447,18 @@ public function testGetPathByIdShareSubFolder(): void {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
\OC_Util::tearDownFS();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists('/foo'));
- [$sharedStorage] = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/foo');
+ $this->assertTrue(Filesystem::file_exists('/foo'));
+ [$sharedStorage] = Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/foo');
/**
- * @var \OCA\Files_Sharing\SharedStorage $sharedStorage
+ * @var SharedStorage $sharedStorage
*/
-
$sharedCache = $sharedStorage->getCache();
$this->assertEquals('', $sharedCache->getPathById($folderInfo->getId()));
$this->assertEquals('bar/test.txt', $sharedCache->getPathById($fileInfo->getId()));
@@ -465,7 +466,7 @@ public function testGetPathByIdShareSubFolder(): void {
public function testNumericStorageId(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OC\Files\Filesystem::mkdir('foo');
+ Filesystem::mkdir('foo');
$rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
$node = $rootFolder->get('foo');
@@ -474,18 +475,18 @@ public function testNumericStorageId(): void {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
\OC_Util::tearDownFS();
- [$sourceStorage] = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER1 . '/files/foo');
+ [$sourceStorage] = Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER1 . '/files/foo');
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists('/foo'));
+ $this->assertTrue(Filesystem::file_exists('/foo'));
/** @var SharedStorage $sharedStorage */
- [$sharedStorage] = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/foo');
+ [$sharedStorage] = Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/foo');
$this->assertEquals($sourceStorage->getCache()->getNumericStorageId(), $sharedStorage->getCache()->getNumericStorageId());
}
@@ -511,18 +512,18 @@ public function testShareJailedStorage(): void {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
\OC_Util::tearDownFS();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertEquals('foo', \OC\Files\Filesystem::file_get_contents('/sub/foo.txt'));
+ $this->assertEquals('foo', Filesystem::file_get_contents('/sub/foo.txt'));
- \OC\Files\Filesystem::file_put_contents('/sub/bar.txt', 'bar');
+ Filesystem::file_put_contents('/sub/bar.txt', 'bar');
/** @var SharedStorage $sharedStorage */
- [$sharedStorage] = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/sub');
+ [$sharedStorage] = Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/sub');
$this->assertTrue($sharedStorage->getCache()->inCache('bar.txt'));
@@ -550,7 +551,7 @@ public function testSearchShareJailedStorage(): void {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
@@ -559,7 +560,7 @@ public function testSearchShareJailedStorage(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
/** @var SharedStorage $sharedStorage */
- [$sharedStorage] = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/sub');
+ [$sharedStorage] = Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/sub');
$results = $sharedStorage->getCache()->search('foo.txt');
$this->assertCount(1, $results);
diff --git a/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php b/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
index eac37a3f3a5a3..7940fc1cd8efb 100644
--- a/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
@@ -25,7 +25,7 @@
class ExternalShareControllerTest extends \Test\TestCase {
/** @var IRequest */
private $request;
- /** @var \OCA\Files_Sharing\External\Manager */
+ /** @var Manager */
private $externalManager;
/** @var IConfig|MockObject */
private $config;
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index b45e17eefdc51..677c980d67ad7 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -6,11 +6,15 @@
*/
namespace OCA\Files_Sharing\Tests\Controller;
+use OC\Share20\Manager;
use OCA\Files_Sharing\Controller\ShareAPIController;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSException;
+use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCS\OCSNotFoundException;
+use OCP\Constants;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
@@ -27,9 +31,11 @@
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
use OCP\Mail\IMailer;
use OCP\Share\Exceptions\GenericShareException;
+use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IAttributes as IShareAttributes;
use OCP\Share\IManager;
use OCP\Share\IProviderFactory;
@@ -48,7 +54,7 @@
class ShareAPIControllerTest extends TestCase {
private string $appName = 'files_sharing';
- private \OC\Share20\Manager|\PHPUnit\Framework\MockObject\MockObject $shareManager;
+ private Manager|\PHPUnit\Framework\MockObject\MockObject $shareManager;
private IGroupManager|\PHPUnit\Framework\MockObject\MockObject $groupManager;
private IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager;
private IRequest|\PHPUnit\Framework\MockObject\MockObject $request;
@@ -175,7 +181,7 @@ private function mockShareAttributes() {
}
public function testDeleteShareShareNotFound(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Wrong share ID, share does not exist');
$this->shareManager
@@ -183,7 +189,7 @@ public function testDeleteShareShareNotFound(): void {
->method('getShareById')
->willReturnCallback(function ($id): void {
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42' || $id === 'deck:42' || $id === 'sciencemesh:42') {
- throw new \OCP\Share\Exceptions\ShareNotFound();
+ throw new ShareNotFound();
} else {
throw new \Exception();
}
@@ -212,7 +218,7 @@ public function testDeleteShare(): void {
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$expected = new DataResponse();
$result = $this->ocs->deleteShare(42);
@@ -223,7 +229,7 @@ public function testDeleteShare(): void {
public function testDeleteShareLocked(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Could not delete share');
$node = $this->getMockBuilder(File::class)->getMock();
@@ -244,7 +250,7 @@ public function testDeleteShareLocked(): void {
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED)
+ ->with(ILockingProvider::LOCK_SHARED)
->will($this->throwException(new LockedException('mypath')));
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share]));
@@ -277,7 +283,7 @@ public function testDeleteShareWithMe(): void {
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share]));
$this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShare', [$share]));
@@ -308,7 +314,7 @@ public function testDeleteShareOwner(): void {
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share]));
$this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShare', [$share]));
@@ -341,7 +347,7 @@ public function testDeleteShareFileOwner(): void {
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share]));
$this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShare', [$share]));
@@ -385,7 +391,7 @@ public function testDeleteSharedWithMyGroup(): void {
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
$this->rootFolder->method('getUserFolder')
@@ -414,7 +420,7 @@ public function testDeleteSharedWithMyGroup(): void {
* in the group the share is shared with
*/
public function testDeleteSharedWithGroupIDontBelongTo(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Wrong share ID, share does not exist');
$node = $this->getMockBuilder(File::class)->getMock();
@@ -448,7 +454,7 @@ public function testDeleteSharedWithGroupIDontBelongTo(): void {
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
$this->rootFolder->method('getUserFolder')
@@ -743,7 +749,7 @@ public function dataGetShare() {
/**
* @dataProvider dataGetShare
*/
- public function testGetShare(\OCP\Share\IShare $share, array $result): void {
+ public function testGetShare(IShare $share, array $result): void {
/** @var ShareAPIController|\PHPUnit\Framework\MockObject\MockObject $ocs */
$ocs = $this->getMockBuilder(ShareAPIController::class)
->setConstructorArgs([
@@ -833,7 +839,7 @@ public function testGetShare(\OCP\Share\IShare $share, array $result): void {
public function testGetShareInvalidNode(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Wrong share ID, share does not exist');
$share = \OC::$server->getShareManager()->newShare();
@@ -872,7 +878,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(4);
@@ -886,7 +892,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('currentUser')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(8);
@@ -900,7 +906,7 @@ public function dataGetShares() {
->setSharedWith('currentUser')
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(15);
@@ -914,7 +920,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(16);
@@ -928,7 +934,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(23);
@@ -942,7 +948,7 @@ public function dataGetShares() {
->setSharedWith('currentUserGroup')
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(42);
@@ -956,7 +962,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(108);
@@ -965,7 +971,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(415);
@@ -979,7 +985,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(416);
@@ -993,7 +999,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(423);
@@ -1007,7 +1013,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1)
->setId(442);
@@ -1021,7 +1027,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setExpirationDate(new \DateTime('2000-01-01T01:02:03'))
->setNode($file1)
->setId(815);
@@ -1036,7 +1042,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setExpirationDate(new \DateTime('2000-01-02T01:02:03'))
->setNode($file1)
->setId(816);
@@ -1051,7 +1057,7 @@ public function dataGetShares() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file2)
->setId(823);
@@ -1378,7 +1384,7 @@ public function dataGetShares() {
* @dataProvider dataGetShares
*/
public function testGetShares(array $getSharesParameters, array $shares, array $extraShareTypes, array $expected): void {
- /** @var \OCA\Files_Sharing\Controller\ShareAPIController $ocs */
+ /** @var ShareAPIController $ocs */
$ocs = $this->getMockBuilder(ShareAPIController::class)
->setConstructorArgs([
$this->appName,
@@ -1484,7 +1490,7 @@ public function testCanAccessShare(): void {
->willReturn($file);
$file->method('getPermissions')
- ->will($this->onConsecutiveCalls(\OCP\Constants::PERMISSION_SHARE, \OCP\Constants::PERMISSION_READ));
+ ->will($this->onConsecutiveCalls(Constants::PERMISSION_SHARE, Constants::PERMISSION_READ));
// getPermissions -> share
$share = $this->getMockBuilder(IShare::class)->getMock();
@@ -1569,7 +1575,7 @@ public function dataCanAccessRoomShare() {
* @param bool helperAvailable
* @param bool canAccessShareByHelper
*/
- public function testCanAccessRoomShare(bool $expected, \OCP\Share\IShare $share, bool $helperAvailable, bool $canAccessShareByHelper): void {
+ public function testCanAccessRoomShare(bool $expected, IShare $share, bool $helperAvailable, bool $canAccessShareByHelper): void {
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
$this->rootFolder->method('getUserFolder')
->with($this->currentUser)
@@ -1605,7 +1611,7 @@ public function testCanAccessRoomShare(bool $expected, \OCP\Share\IShare $share,
public function testCreateShareNoPath(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Please specify a file or folder path');
$this->ocs->createShare();
@@ -1613,7 +1619,7 @@ public function testCreateShareNoPath(): void {
public function testCreateShareInvalidPath(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Wrong path, file/folder does not exist');
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
@@ -1625,14 +1631,14 @@ public function testCreateShareInvalidPath(): void {
$userFolder->expects($this->once())
->method('get')
->with('invalid-path')
- ->will($this->throwException(new \OCP\Files\NotFoundException()));
+ ->will($this->throwException(new NotFoundException()));
$this->ocs->createShare('invalid-path');
}
public function testCreateShareInvalidPermissions(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Invalid permissions');
$share = $this->newShare();
@@ -1654,14 +1660,14 @@ public function testCreateShareInvalidPermissions(): void {
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->ocs->createShare('valid-path', 32);
}
public function testCreateShareUserNoShareWith(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Please specify a valid account to share with');
$share = $this->newShare();
@@ -1682,14 +1688,14 @@ public function testCreateShareUserNoShareWith(): void {
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER);
+ $this->ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_USER);
}
public function testCreateShareUserNoValidShareWith(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Please specify a valid account to share with');
$share = $this->newShare();
@@ -1709,19 +1715,19 @@ public function testCreateShareUserNoValidShareWith(): void {
->willReturn([]);
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->userManager->method('userExists')
->with('invalidUser')
->willReturn(false);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'invalidUser');
+ $this->ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_USER, 'invalidUser');
}
public function testCreateShareUser(): void {
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
- /** @var \OCA\Files_Sharing\Controller\ShareAPIController $ocs */
+ /** @var ShareAPIController $ocs */
$ocs = $this->getMockBuilder(ShareAPIController::class)
->setConstructorArgs([
$this->appName,
@@ -1762,15 +1768,15 @@ public function testCreateShareUser(): void {
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('createShare')
- ->with($this->callback(function (\OCP\Share\IShare $share) use ($path) {
+ ->with($this->callback(function (IShare $share) use ($path) {
return $share->getNode() === $path &&
$share->getPermissions() === (
- \OCP\Constants::PERMISSION_ALL &
- ~\OCP\Constants::PERMISSION_DELETE &
- ~\OCP\Constants::PERMISSION_CREATE
+ Constants::PERMISSION_ALL &
+ ~Constants::PERMISSION_DELETE &
+ ~Constants::PERMISSION_CREATE
) &&
$share->getShareType() === IShare::TYPE_USER &&
$share->getSharedWith() === 'validUser' &&
@@ -1779,7 +1785,7 @@ public function testCreateShareUser(): void {
->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'validUser');
+ $result = $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_USER, 'validUser');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1787,7 +1793,7 @@ public function testCreateShareUser(): void {
public function testCreateShareGroupNoValidShareWith(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Please specify a valid group');
$share = $this->newShare();
@@ -1810,9 +1816,9 @@ public function testCreateShareGroupNoValidShareWith(): void {
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'invalidGroup');
+ $this->ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'invalidGroup');
}
public function testCreateShareGroup(): void {
@@ -1847,7 +1853,7 @@ public function testCreateShareGroup(): void {
->method('getParam')
->willReturnMap([
['path', null, 'valid-path'],
- ['permissions', null, \OCP\Constants::PERMISSION_ALL],
+ ['permissions', null, Constants::PERMISSION_ALL],
['shareType', '-1', IShare::TYPE_GROUP],
['shareWith', null, 'validGroup'],
]);
@@ -1873,12 +1879,12 @@ public function testCreateShareGroup(): void {
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('createShare')
- ->with($this->callback(function (\OCP\Share\IShare $share) use ($path) {
+ ->with($this->callback(function (IShare $share) use ($path) {
return $share->getNode() === $path &&
- $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $share->getPermissions() === Constants::PERMISSION_ALL &&
$share->getShareType() === IShare::TYPE_GROUP &&
$share->getSharedWith() === 'validGroup' &&
$share->getSharedBy() === 'currentUser';
@@ -1886,7 +1892,7 @@ public function testCreateShareGroup(): void {
->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'validGroup');
+ $result = $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'validGroup');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1894,7 +1900,7 @@ public function testCreateShareGroup(): void {
public function testCreateShareGroupNotAllowed(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Group sharing is disabled by the administrator');
$share = $this->newShare();
@@ -1919,12 +1925,12 @@ public function testCreateShareGroupNotAllowed(): void {
->method('allowGroupSharing')
->willReturn(false);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'invalidGroup');
+ $this->ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'invalidGroup');
}
public function testCreateShareLinkNoLinksAllowed(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Public link sharing is disabled by the administrator');
$this->request
@@ -1950,12 +1956,12 @@ public function testCreateShareLinkNoLinksAllowed(): void {
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
+ $this->ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_LINK);
}
public function testCreateShareLinkNoPublicUpload(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectException(OCSForbiddenException::class);
$this->expectExceptionMessage('Public upload disabled by the administrator');
$path = $this->getMockBuilder(Folder::class)->getMock();
@@ -1975,12 +1981,12 @@ public function testCreateShareLinkNoPublicUpload(): void {
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true');
+ $this->ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true');
}
public function testCreateShareLinkPublicUploadFile(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Public upload is only possible for publicly shared folders');
$path = $this->getMockBuilder(File::class)->getMock();
@@ -2001,7 +2007,7 @@ public function testCreateShareLinkPublicUploadFile(): void {
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true');
+ $this->ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true');
}
public function testCreateShareLinkPublicUploadFolder(): void {
@@ -2026,10 +2032,10 @@ public function testCreateShareLinkPublicUploadFolder(): void {
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
$this->shareManager->expects($this->once())->method('createShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($path) {
+ $this->callback(function (IShare $share) use ($path) {
return $share->getNode() === $path &&
$share->getShareType() === IShare::TYPE_LINK &&
- $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
+ $share->getPermissions() === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE) &&
$share->getSharedBy() === 'currentUser' &&
$share->getPassword() === null &&
$share->getExpirationDate() === null;
@@ -2037,7 +2043,7 @@ public function testCreateShareLinkPublicUploadFolder(): void {
)->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true', '', null, '');
+ $result = $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true', '', null, '');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -2065,10 +2071,10 @@ public function testCreateShareLinkPassword(): void {
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
$this->shareManager->expects($this->once())->method('createShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($path) {
+ $this->callback(function (IShare $share) use ($path) {
return $share->getNode() === $path &&
$share->getShareType() === IShare::TYPE_LINK &&
- $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $share->getPermissions() === Constants::PERMISSION_ALL &&
$share->getSharedBy() === 'currentUser' &&
$share->getPassword() === 'password' &&
$share->getExpirationDate() === null;
@@ -2076,7 +2082,7 @@ public function testCreateShareLinkPassword(): void {
)->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', null, '');
+ $result = $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', null, '');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -2106,10 +2112,10 @@ public function testCreateShareLinkSendPasswordByTalk(): void {
$this->appManager->method('isEnabledForUser')->with('spreed')->willReturn(true);
$this->shareManager->expects($this->once())->method('createShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($path) {
+ $this->callback(function (IShare $share) use ($path) {
return $share->getNode() === $path &&
$share->getShareType() === IShare::TYPE_LINK &&
- $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $share->getPermissions() === Constants::PERMISSION_ALL &&
$share->getSharedBy() === 'currentUser' &&
$share->getPassword() === 'password' &&
$share->getSendPasswordByTalk() === true &&
@@ -2118,7 +2124,7 @@ public function testCreateShareLinkSendPasswordByTalk(): void {
)->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', '');
+ $result = $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', '');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -2126,7 +2132,7 @@ public function testCreateShareLinkSendPasswordByTalk(): void {
public function testCreateShareLinkSendPasswordByTalkWithTalkDisabled(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectException(OCSForbiddenException::class);
$this->expectExceptionMessage('Sharing valid-path sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled');
$ocs = $this->mockFormatShare();
@@ -2154,7 +2160,7 @@ public function testCreateShareLinkSendPasswordByTalkWithTalkDisabled(): void {
$this->shareManager->expects($this->never())->method('createShare');
- $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', '');
+ $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', '');
}
public function testCreateShareValidExpireDate(): void {
@@ -2189,13 +2195,13 @@ public function testCreateShareValidExpireDate(): void {
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
$this->shareManager->expects($this->once())->method('createShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($path) {
+ $this->callback(function (IShare $share) use ($path) {
$date = new \DateTime('2000-01-01');
$date->setTime(0, 0, 0);
return $share->getNode() === $path &&
$share->getShareType() === IShare::TYPE_LINK &&
- $share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE &&
+ $share->getPermissions() === Constants::PERMISSION_READ | Constants::PERMISSION_SHARE &&
$share->getSharedBy() === 'currentUser' &&
$share->getPassword() === null &&
$share->getExpirationDate() == $date;
@@ -2211,7 +2217,7 @@ public function testCreateShareValidExpireDate(): void {
public function testCreateShareInvalidExpireDate(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Invalid date, date format must be YYYY-MM-DD');
$ocs = $this->mockFormatShare();
@@ -2234,14 +2240,14 @@ public function testCreateShareInvalidExpireDate(): void {
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
- $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, 'a1b2d3');
+ $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, 'a1b2d3');
}
public function testCreateShareRemote(): void {
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
- /** @var \OCA\Files_Sharing\Controller\ShareAPIController $ocs */
+ /** @var ShareAPIController $ocs */
$ocs = $this->getMockBuilder(ShareAPIController::class)
->setConstructorArgs([
$this->appName,
@@ -2282,15 +2288,15 @@ public function testCreateShareRemote(): void {
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('createShare')
- ->with($this->callback(function (\OCP\Share\IShare $share) use ($path) {
+ ->with($this->callback(function (IShare $share) use ($path) {
return $share->getNode() === $path &&
$share->getPermissions() === (
- \OCP\Constants::PERMISSION_ALL &
- ~\OCP\Constants::PERMISSION_DELETE &
- ~\OCP\Constants::PERMISSION_CREATE
+ Constants::PERMISSION_ALL &
+ ~Constants::PERMISSION_DELETE &
+ ~Constants::PERMISSION_CREATE
) &&
$share->getShareType() === IShare::TYPE_REMOTE &&
$share->getSharedWith() === 'user@example.org' &&
@@ -2301,7 +2307,7 @@ public function testCreateShareRemote(): void {
$this->shareManager->method('outgoingServer2ServerSharesAllowed')->willReturn(true);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_REMOTE, 'user@example.org');
+ $result = $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_REMOTE, 'user@example.org');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -2311,7 +2317,7 @@ public function testCreateShareRemoteGroup(): void {
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
- /** @var \OCA\Files_Sharing\Controller\ShareAPIController $ocs */
+ /** @var ShareAPIController $ocs */
$ocs = $this->getMockBuilder(ShareAPIController::class)
->setConstructorArgs([
$this->appName,
@@ -2352,15 +2358,15 @@ public function testCreateShareRemoteGroup(): void {
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('createShare')
- ->with($this->callback(function (\OCP\Share\IShare $share) use ($path) {
+ ->with($this->callback(function (IShare $share) use ($path) {
return $share->getNode() === $path &&
$share->getPermissions() === (
- \OCP\Constants::PERMISSION_ALL &
- ~\OCP\Constants::PERMISSION_DELETE &
- ~\OCP\Constants::PERMISSION_CREATE
+ Constants::PERMISSION_ALL &
+ ~Constants::PERMISSION_DELETE &
+ ~Constants::PERMISSION_CREATE
) &&
$share->getShareType() === IShare::TYPE_REMOTE_GROUP &&
$share->getSharedWith() === 'group@example.org' &&
@@ -2371,7 +2377,7 @@ public function testCreateShareRemoteGroup(): void {
$this->shareManager->method('outgoingServer2ServerGroupSharesAllowed')->willReturn(true);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_REMOTE_GROUP, 'group@example.org');
+ $result = $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_REMOTE_GROUP, 'group@example.org');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -2398,7 +2404,7 @@ public function testCreateShareRoom(): void {
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->appManager->method('isEnabledForUser')
->with('spreed')
@@ -2411,17 +2417,17 @@ public function testCreateShareRoom(): void {
->with(
$share,
'recipientRoom',
- \OCP\Constants::PERMISSION_ALL &
- ~\OCP\Constants::PERMISSION_DELETE &
- ~\OCP\Constants::PERMISSION_CREATE,
+ Constants::PERMISSION_ALL &
+ ~Constants::PERMISSION_DELETE &
+ ~Constants::PERMISSION_CREATE,
''
)->willReturnCallback(
function ($share): void {
$share->setSharedWith('recipientRoom');
$share->setPermissions(
- \OCP\Constants::PERMISSION_ALL &
- ~\OCP\Constants::PERMISSION_DELETE &
- ~\OCP\Constants::PERMISSION_CREATE
+ Constants::PERMISSION_ALL &
+ ~Constants::PERMISSION_DELETE &
+ ~Constants::PERMISSION_CREATE
);
}
);
@@ -2431,12 +2437,12 @@ function ($share): void {
->willReturn($helper);
$this->shareManager->method('createShare')
- ->with($this->callback(function (\OCP\Share\IShare $share) use ($path) {
+ ->with($this->callback(function (IShare $share) use ($path) {
return $share->getNode() === $path &&
$share->getPermissions() === (
- \OCP\Constants::PERMISSION_ALL &
- ~\OCP\Constants::PERMISSION_DELETE &
- ~\OCP\Constants::PERMISSION_CREATE
+ Constants::PERMISSION_ALL &
+ ~Constants::PERMISSION_DELETE &
+ ~Constants::PERMISSION_CREATE
) &&
$share->getShareType() === IShare::TYPE_ROOM &&
$share->getSharedWith() === 'recipientRoom' &&
@@ -2445,7 +2451,7 @@ function ($share): void {
->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom');
+ $result = $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -2453,7 +2459,7 @@ function ($share): void {
public function testCreateShareRoomHelperNotAvailable(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectException(OCSForbiddenException::class);
$this->expectExceptionMessage('Sharing valid-path failed because the back end does not support room shares');
$ocs = $this->mockFormatShare();
@@ -2477,7 +2483,7 @@ public function testCreateShareRoomHelperNotAvailable(): void {
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->appManager->method('isEnabledForUser')
->with('spreed')
@@ -2485,12 +2491,12 @@ public function testCreateShareRoomHelperNotAvailable(): void {
$this->shareManager->expects($this->never())->method('createShare');
- $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom');
+ $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom');
}
public function testCreateShareRoomHelperThrowException(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Exception thrown by the helper');
$ocs = $this->mockFormatShare();
@@ -2514,7 +2520,7 @@ public function testCreateShareRoomHelperThrowException(): void {
$path->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->appManager->method('isEnabledForUser')
->with('spreed')
@@ -2527,9 +2533,9 @@ public function testCreateShareRoomHelperThrowException(): void {
->with(
$share,
'recipientRoom',
- \OCP\Constants::PERMISSION_ALL &
- ~\OCP\Constants::PERMISSION_DELETE &
- ~\OCP\Constants::PERMISSION_CREATE,
+ Constants::PERMISSION_ALL &
+ ~Constants::PERMISSION_DELETE &
+ ~Constants::PERMISSION_CREATE,
''
)->willReturnCallback(
function ($share): void {
@@ -2543,7 +2549,7 @@ function ($share): void {
$this->shareManager->expects($this->never())->method('createShare');
- $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom');
+ $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom');
}
/**
@@ -2596,7 +2602,7 @@ public function testCreateReshareOfFederatedMountNoDeletePermissions(): void {
$userFolder->method('getStorage')->willReturn($storage);
$path->method('getStorage')->willReturn($storage);
- $path->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
+ $path->method('getPermissions')->willReturn(Constants::PERMISSION_READ);
$userFolder->expects($this->once())
->method('get')
->with('valid-path')
@@ -2609,17 +2615,17 @@ public function testCreateReshareOfFederatedMountNoDeletePermissions(): void {
$this->shareManager
->expects($this->once())
->method('createShare')
- ->with($this->callback(function (\OCP\Share\IShare $share) {
- return $share->getPermissions() === \OCP\Constants::PERMISSION_READ;
+ ->with($this->callback(function (IShare $share) {
+ return $share->getPermissions() === Constants::PERMISSION_READ;
}))
->willReturnArgument(0);
- $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'validUser');
+ $ocs->createShare('valid-path', Constants::PERMISSION_ALL, IShare::TYPE_USER, 'validUser');
}
public function testUpdateShareCantAccess(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectException(OCSNotFoundException::class);
$this->expectExceptionMessage('Wrong share ID, share does not exist');
[$userFolder, $node] = $this->getNonSharedUserFolder();
@@ -2628,7 +2634,7 @@ public function testUpdateShareCantAccess(): void {
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
@@ -2645,19 +2651,19 @@ public function testUpdateShareCantAccess(): void {
public function testUpdateNoParametersLink(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectException(OCSBadRequestException::class);
$this->expectExceptionMessage('Wrong or no update parameter given');
$node = $this->getMockBuilder(Folder::class)->getMock();
$share = $this->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setNode($node);
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
@@ -2666,19 +2672,19 @@ public function testUpdateNoParametersLink(): void {
public function testUpdateNoParametersOther(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectException(OCSBadRequestException::class);
$this->expectExceptionMessage('Wrong or no update parameter given');
$node = $this->getMockBuilder(Folder::class)->getMock();
$share = $this->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_GROUP)
->setNode($node);
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
@@ -2692,7 +2698,7 @@ public function testUpdateLinkShareClear(): void {
$node->method('getId')
->willReturn(42);
$share = $this->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -2700,18 +2706,18 @@ public function testUpdateLinkShareClear(): void {
->setNote('note')
->setLabel('label')
->setHideDownload(true)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setPermissions(Constants::PERMISSION_ALL)
->setNode($node);
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) {
- return $share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
+ $this->callback(function (IShare $share) {
+ return $share->getPermissions() === Constants::PERMISSION_READ &&
$share->getPassword() === null &&
$share->getExpirationDate() === null &&
// Once set a note or a label are never back to null, only to an
@@ -2754,7 +2760,7 @@ public function testUpdateLinkShareSet(): void {
->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setNode($folder);
@@ -2763,11 +2769,11 @@ public function testUpdateLinkShareSet(): void {
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) {
+ $this->callback(function (IShare $share) {
$date = new \DateTime('2000-01-01');
$date->setTime(0, 0, 0);
- return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
+ return $share->getPermissions() === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE) &&
$share->getPassword() === 'password' &&
$share->getExpirationDate() == $date &&
$share->getNote() === 'note' &&
@@ -2811,7 +2817,7 @@ public function testUpdateLinkShareEnablePublicUpload($permissions, $publicUploa
->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -2822,8 +2828,8 @@ public function testUpdateLinkShareEnablePublicUpload($permissions, $publicUploa
$this->shareManager->method('getSharedWith')->willReturn([]);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) {
- return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
+ $this->callback(function (IShare $share) {
+ return $share->getPermissions() === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE) &&
$share->getPassword() === 'password' &&
$share->getExpirationDate() === null;
})
@@ -2853,11 +2859,11 @@ public function testUpdateLinkShareEnablePublicUpload($permissions, $publicUploa
public function publicLinkValidPermissionsProvider() {
return [
- [\OCP\Constants::PERMISSION_CREATE],
- [\OCP\Constants::PERMISSION_READ],
- [\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE],
- [\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE],
- [\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE],
+ [Constants::PERMISSION_CREATE],
+ [Constants::PERMISSION_READ],
+ [Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE],
+ [Constants::PERMISSION_READ | Constants::PERMISSION_DELETE],
+ [Constants::PERMISSION_READ | Constants::PERMISSION_CREATE],
];
}
@@ -2872,7 +2878,7 @@ public function testUpdateLinkShareSetCRUDPermissions($permissions): void {
->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -2910,9 +2916,9 @@ public function testUpdateLinkShareSetCRUDPermissions($permissions): void {
public function publicLinkInvalidPermissionsProvider1() {
return [
- [\OCP\Constants::PERMISSION_DELETE],
- [\OCP\Constants::PERMISSION_UPDATE],
- [\OCP\Constants::PERMISSION_SHARE],
+ [Constants::PERMISSION_DELETE],
+ [Constants::PERMISSION_UPDATE],
+ [Constants::PERMISSION_SHARE],
];
}
@@ -2920,7 +2926,7 @@ public function publicLinkInvalidPermissionsProvider1() {
* @dataProvider publicLinkInvalidPermissionsProvider1
*/
public function testUpdateLinkShareSetInvalidCRUDPermissions1($permissions): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectException(OCSBadRequestException::class);
$this->expectExceptionMessage('Share must at least have READ or CREATE permissions');
$this->testUpdateLinkShareSetCRUDPermissions($permissions);
@@ -2928,8 +2934,8 @@ public function testUpdateLinkShareSetInvalidCRUDPermissions1($permissions): voi
public function publicLinkInvalidPermissionsProvider2() {
return [
- [\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE],
- [\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE],
+ [Constants::PERMISSION_CREATE | Constants::PERMISSION_DELETE],
+ [Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE],
];
}
@@ -2937,14 +2943,14 @@ public function publicLinkInvalidPermissionsProvider2() {
* @dataProvider publicLinkInvalidPermissionsProvider2
*/
public function testUpdateLinkShareSetInvalidCRUDPermissions2($permissions): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectException(OCSBadRequestException::class);
$this->expectExceptionMessage('Share must have READ permission if UPDATE or DELETE permission is set');
$this->testUpdateLinkShareSetCRUDPermissions($permissions);
}
public function testUpdateLinkShareInvalidDate(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectException(OCSBadRequestException::class);
$this->expectExceptionMessage('Invalid date. Format must be YYYY-MM-DD');
$ocs = $this->mockFormatShare();
@@ -2960,7 +2966,7 @@ public function testUpdateLinkShareInvalidDate(): void {
->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setNode($folder);
@@ -2976,12 +2982,12 @@ public function publicUploadParamsProvider() {
[null, 'true', null, 'password'],
// legacy had no delete
[
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE,
+ Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE,
'true', null, 'password'
],
// correct
[
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE,
+ Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE,
null, null, 'password'
],
];
@@ -2991,7 +2997,7 @@ public function publicUploadParamsProvider() {
* @dataProvider publicUploadParamsProvider
*/
public function testUpdateLinkSharePublicUploadNotAllowed($permissions, $publicUpload, $expireDate, $password): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectException(OCSForbiddenException::class);
$this->expectExceptionMessage('Public upload disabled by the administrator');
$ocs = $this->mockFormatShare();
@@ -3006,7 +3012,7 @@ public function testUpdateLinkSharePublicUploadNotAllowed($permissions, $publicU
$folder->method('getId')->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setNode($folder);
@@ -3019,7 +3025,7 @@ public function testUpdateLinkSharePublicUploadNotAllowed($permissions, $publicU
public function testUpdateLinkSharePublicUploadOnFile(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectException(OCSBadRequestException::class);
$this->expectExceptionMessage('Public upload is only possible for publicly shared folders');
$ocs = $this->mockFormatShare();
@@ -3036,7 +3042,7 @@ public function testUpdateLinkSharePublicUploadOnFile(): void {
->willReturn($userFolder);
$share = \OC::$server->getShareManager()->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setNode($file);
@@ -3062,7 +3068,7 @@ public function testUpdateLinkSharePasswordDoesNotChangeOther(): void {
->with($this->currentUser)
->willReturn($userFolder);
$share = $this->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -3071,18 +3077,18 @@ public function testUpdateLinkSharePasswordDoesNotChangeOther(): void {
->setNote('note')
->setLabel('label')
->setHideDownload(true)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setPermissions(Constants::PERMISSION_ALL)
->setNode($node);
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($date) {
- return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $this->callback(function (IShare $share) use ($date) {
+ return $share->getPermissions() === Constants::PERMISSION_ALL &&
$share->getPassword() === 'newpassword' &&
$share->getSendPasswordByTalk() === true &&
$share->getExpirationDate() === $date &&
@@ -3114,7 +3120,7 @@ public function testUpdateLinkShareSendPasswordByTalkDoesNotChangeOther(): void
->willReturn($userFolder);
$node->method('getId')->willReturn(42);
$share = $this->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -3123,20 +3129,20 @@ public function testUpdateLinkShareSendPasswordByTalkDoesNotChangeOther(): void
->setNote('note')
->setLabel('label')
->setHideDownload(true)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setPermissions(Constants::PERMISSION_ALL)
->setNode($node);
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->appManager->method('isEnabledForUser')->with('spreed')->willReturn(true);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($date) {
- return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $this->callback(function (IShare $share) use ($date) {
+ return $share->getPermissions() === Constants::PERMISSION_ALL &&
$share->getPassword() === 'password' &&
$share->getSendPasswordByTalk() === true &&
$share->getExpirationDate() === $date &&
@@ -3155,7 +3161,7 @@ public function testUpdateLinkShareSendPasswordByTalkDoesNotChangeOther(): void
public function testUpdateLinkShareSendPasswordByTalkWithTalkDisabledDoesNotChangeOther(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectException(OCSForbiddenException::class);
$this->expectExceptionMessage('"Sending the password by Nextcloud Talk" for sharing a file or folder failed because Nextcloud Talk is not enabled.');
$ocs = $this->mockFormatShare();
@@ -3172,7 +3178,7 @@ public function testUpdateLinkShareSendPasswordByTalkWithTalkDisabledDoesNotChan
->willReturn($userFolder);
$node->method('getId')->willReturn(42);
$share = $this->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -3181,12 +3187,12 @@ public function testUpdateLinkShareSendPasswordByTalkWithTalkDisabledDoesNotChan
->setNote('note')
->setLabel('label')
->setHideDownload(true)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setPermissions(Constants::PERMISSION_ALL)
->setNode($node);
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
@@ -3212,7 +3218,7 @@ public function testUpdateLinkShareDoNotSendPasswordByTalkDoesNotChangeOther():
->willReturn($userFolder);
$node->method('getId')->willReturn(42);
$share = $this->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -3221,20 +3227,20 @@ public function testUpdateLinkShareDoNotSendPasswordByTalkDoesNotChangeOther():
->setNote('note')
->setLabel('label')
->setHideDownload(true)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setPermissions(Constants::PERMISSION_ALL)
->setNode($node);
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->appManager->method('isEnabledForUser')->with('spreed')->willReturn(true);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($date) {
- return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $this->callback(function (IShare $share) use ($date) {
+ return $share->getPermissions() === Constants::PERMISSION_ALL &&
$share->getPassword() === 'password' &&
$share->getSendPasswordByTalk() === false &&
$share->getExpirationDate() === $date &&
@@ -3262,7 +3268,7 @@ public function testUpdateLinkShareDoNotSendPasswordByTalkWithTalkDisabledDoesNo
->willReturn(42);
$share = $this->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -3271,20 +3277,20 @@ public function testUpdateLinkShareDoNotSendPasswordByTalkWithTalkDisabledDoesNo
->setNote('note')
->setLabel('label')
->setHideDownload(true)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setPermissions(Constants::PERMISSION_ALL)
->setNode($node);
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->appManager->method('isEnabledForUser')->with('spreed')->willReturn(false);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($date) {
- return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $this->callback(function (IShare $share) use ($date) {
+ return $share->getPermissions() === Constants::PERMISSION_ALL &&
$share->getPassword() === 'password' &&
$share->getSendPasswordByTalk() === false &&
$share->getExpirationDate() === $date &&
@@ -3329,7 +3335,7 @@ public function testUpdateLinkShareExpireDateDoesNotChangeOther(): void {
->willReturn(42);
$share = $this->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -3338,21 +3344,21 @@ public function testUpdateLinkShareExpireDateDoesNotChangeOther(): void {
->setNote('note')
->setLabel('label')
->setHideDownload(true)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setPermissions(Constants::PERMISSION_ALL)
->setNode($node);
$node->expects($this->once())
->method('lock')
- ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ ->with(ILockingProvider::LOCK_SHARED);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) {
+ $this->callback(function (IShare $share) {
$date = new \DateTime('2010-12-23');
$date->setTime(0, 0, 0);
- return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ return $share->getPermissions() === Constants::PERMISSION_ALL &&
$share->getPassword() === 'password' &&
$share->getSendPasswordByTalk() === true &&
$share->getExpirationDate() == $date &&
@@ -3393,7 +3399,7 @@ public function testUpdateLinkSharePublicUploadDoesNotChangeOther(): void {
->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -3402,15 +3408,15 @@ public function testUpdateLinkSharePublicUploadDoesNotChangeOther(): void {
->setNote('note')
->setLabel('label')
->setHideDownload(true)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setPermissions(Constants::PERMISSION_ALL)
->setNode($folder);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($date) {
- return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
+ $this->callback(function (IShare $share) use ($date) {
+ return $share->getPermissions() === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE) &&
$share->getPassword() === 'password' &&
$share->getSendPasswordByTalk() === true &&
$share->getExpirationDate() === $date &&
@@ -3454,7 +3460,7 @@ public function testUpdateLinkSharePermissions(): void {
->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -3463,15 +3469,15 @@ public function testUpdateLinkSharePermissions(): void {
->setNote('note')
->setLabel('label')
->setHideDownload(true)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setPermissions(Constants::PERMISSION_ALL)
->setNode($folder);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($date): bool {
- return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
+ $this->callback(function (IShare $share) use ($date): bool {
+ return $share->getPermissions() === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE) &&
$share->getPassword() === 'password' &&
$share->getSendPasswordByTalk() === true &&
$share->getExpirationDate() === $date &&
@@ -3514,7 +3520,7 @@ public function testUpdateLinkSharePermissionsShare(): void {
->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_LINK)
->setPassword('password')
@@ -3523,15 +3529,15 @@ public function testUpdateLinkSharePermissionsShare(): void {
->setNote('note')
->setLabel('label')
->setHideDownload(true)
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($date) {
- return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
+ $this->callback(function (IShare $share) use ($date) {
+ return $share->getPermissions() === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE) &&
$share->getPassword() === 'password' &&
$share->getSendPasswordByTalk() === true &&
$share->getExpirationDate() === $date &&
@@ -3572,7 +3578,7 @@ public function testUpdateOtherPermissions(): void {
->willReturn(42);
$share = \OC::$server->getShareManager()->newShare();
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ $share->setPermissions(Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(IShare::TYPE_USER)
->setNode($file);
@@ -3581,8 +3587,8 @@ public function testUpdateOtherPermissions(): void {
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
$this->shareManager->expects($this->once())->method('updateShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) {
- return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL;
+ $this->callback(function (IShare $share) {
+ return $share->getPermissions() === Constants::PERMISSION_ALL;
})
)->willReturnArgument(0);
@@ -3624,7 +3630,7 @@ public function testUpdateShareCannotIncreasePermissions(): void {
->setShareOwner('anotheruser')
->setShareType(IShare::TYPE_GROUP)
->setSharedWith('group1')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder);
// note: updateShare will modify the received instance but getSharedWith will reread from the database,
@@ -3636,7 +3642,7 @@ public function testUpdateShareCannotIncreasePermissions(): void {
->setShareOwner('anotheruser')
->setShareType(IShare::TYPE_GROUP)
->setSharedWith('group1')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder);
$this->request
@@ -3696,7 +3702,7 @@ public function testUpdateShareCanIncreasePermissionsIfOwner(): void {
->setShareOwner($this->currentUser)
->setShareType(IShare::TYPE_GROUP)
->setSharedWith('group1')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder);
// note: updateShare will modify the received instance but getSharedWith will reread from the database,
@@ -3708,7 +3714,7 @@ public function testUpdateShareCanIncreasePermissionsIfOwner(): void {
->setShareOwner($this->currentUser)
->setShareType(IShare::TYPE_GROUP)
->setSharedWith('group1')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
@@ -3811,7 +3817,7 @@ public function dataFormatShare() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setAttributes($shareAttributes)
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
@@ -3913,7 +3919,7 @@ public function dataFormatShare() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -3967,7 +3973,7 @@ public function dataFormatShare() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4023,7 +4029,7 @@ public function dataFormatShare() {
->setSharedWith('recipientGroup')
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4077,7 +4083,7 @@ public function dataFormatShare() {
->setSharedWith('recipientGroup2')
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4127,7 +4133,7 @@ public function dataFormatShare() {
$share->setShareType(IShare::TYPE_LINK)
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4186,7 +4192,7 @@ public function dataFormatShare() {
$share->setShareType(IShare::TYPE_LINK)
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4246,7 +4252,7 @@ public function dataFormatShare() {
->setSharedBy('initiator')
->setSharedWith('user@server.com')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setExpirationDate(new \DateTime('2001-02-03T04:05:06'))
@@ -4299,7 +4305,7 @@ public function dataFormatShare() {
->setSharedBy('initiator')
->setSharedWith('user@server.com')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setExpirationDate(new \DateTime('2001-02-03T04:05:06'))
@@ -4355,7 +4361,7 @@ public function dataFormatShare() {
->setSharedWithDisplayName('The display name')
->setSharedWithAvatar('path/to/the/avatar')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4409,7 +4415,7 @@ public function dataFormatShare() {
->setSharedBy('initiator')
->setSharedWith('Circle (Public circle, circleOwner) [4815162342]')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4462,7 +4468,7 @@ public function dataFormatShare() {
->setSharedBy('initiator')
->setSharedWith('Circle (Public circle, circleOwner)')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4514,7 +4520,7 @@ public function dataFormatShare() {
->setSharedBy('initiator')
->setSharedWith('recipient')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
->setNote('personal note')
@@ -4529,7 +4535,7 @@ public function dataFormatShare() {
->setSharedBy('initiator')
->setSharedWith('user@server.com')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4584,7 +4590,7 @@ public function dataFormatShare() {
->setSharedBy('initiator')
->setSharedWith('user@server.com')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4641,7 +4647,7 @@ public function dataFormatShare() {
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($fileWithPreview)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4700,7 +4706,7 @@ public function dataFormatShare() {
* @param array $users
* @param $exception
*/
- public function testFormatShare(array $expects, \OCP\Share\IShare $share, array $users, $exception): void {
+ public function testFormatShare(array $expects, IShare $share, array $users, $exception): void {
$this->userManager->method('get')->willReturnMap($users);
$recipientGroup = $this->createMock(IGroup::class);
@@ -4807,7 +4813,7 @@ public function dataFormatRoomShare() {
->setSharedWith('recipientRoom')
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4859,7 +4865,7 @@ public function dataFormatRoomShare() {
->setSharedWith('recipientRoom')
->setSharedBy('initiator')
->setShareOwner('owner')
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
@@ -4919,7 +4925,7 @@ public function dataFormatRoomShare() {
* @param bool $helperAvailable
* @param array $formatShareByHelper
*/
- public function testFormatRoomShare(array $expects, \OCP\Share\IShare $share, bool $helperAvailable, array $formatShareByHelper): void {
+ public function testFormatRoomShare(array $expects, IShare $share, bool $helperAvailable, array $formatShareByHelper): void {
$this->rootFolder->method('getUserFolder')
->with($this->currentUser)
->willReturnSelf();
diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php
index 45c0d54c9186f..5d962dff4c008 100644
--- a/apps/files_sharing/tests/Controller/ShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php
@@ -17,6 +17,7 @@
use OCP\Accounts\IAccountManager;
use OCP\Accounts\IAccountProperty;
use OCP\Activity\IManager;
+use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\Template\ExternalShareMenuAction;
use OCP\AppFramework\Http\Template\LinkMenuAction;
@@ -39,6 +40,7 @@
use OCP\IUser;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
+use OCP\Server;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IPublicShareTemplateFactory;
use OCP\Share\IShare;
@@ -115,7 +117,7 @@ protected function setUp(): void {
)
);
- $this->shareController = new \OCA\Files_Sharing\Controller\ShareController(
+ $this->shareController = new ShareController(
$this->appName,
$this->createMock(IRequest::class),
$this->config,
@@ -236,7 +238,7 @@ public function testShowShare(): void {
->willReturn($account);
/** @var Manager */
- $manager = \OCP\Server::get(Manager::class);
+ $manager = Server::get(Manager::class);
$share = $manager->newShare();
$share->setId(42)
->setPermissions(Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE)
@@ -333,7 +335,7 @@ public function testShowShare(): void {
$this->assertEquals($expectedInitialState, $initialState);
- $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
+ $csp = new ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
$expectedResponse = new PublicTemplateResponse('files', 'index');
$expectedResponse->setContentSecurityPolicy($csp);
@@ -382,7 +384,7 @@ public function testShowFileDropShare(): void {
->willReturn($account);
/** @var Manager */
- $manager = \OCP\Server::get(Manager::class);
+ $manager = Server::get(Manager::class);
$share = $manager->newShare();
$share->setId(42)
->setPermissions(Constants::PERMISSION_CREATE)
@@ -472,7 +474,7 @@ public function testShowFileDropShare(): void {
$this->assertEquals($expectedInitialState, $initialState);
- $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
+ $csp = new ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
$expectedResponse = new PublicTemplateResponse('files', 'index');
$expectedResponse->setContentSecurityPolicy($csp);
@@ -522,7 +524,7 @@ public function testShowShareWithPrivateName(): void {
->willReturn($account);
/** @var IShare */
- $share = \OCP\Server::get(Manager::class)->newShare();
+ $share = Server::get(Manager::class)->newShare();
$share->setId(42);
$share->setPassword('password')
->setShareOwner('ownerUID')
@@ -530,7 +532,7 @@ public function testShowShareWithPrivateName(): void {
->setNode($file)
->setNote($note)
->setToken('token')
- ->setPermissions(\OCP\Constants::PERMISSION_ALL & ~\OCP\Constants::PERMISSION_SHARE)
+ ->setPermissions(Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE)
->setTarget("/$filename");
$this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
@@ -599,7 +601,7 @@ public function testShowShareWithPrivateName(): void {
$response = $this->shareController->showShare();
- $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
+ $csp = new ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
$expectedResponse = new PublicTemplateResponse('files', 'index');
$expectedResponse->setContentSecurityPolicy($csp);
@@ -616,7 +618,7 @@ public function testShowShareWithPrivateName(): void {
public function testShowShareInvalid(): void {
- $this->expectException(\OCP\Files\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$filename = 'file1.txt';
$this->shareController->setToken('token');
@@ -671,7 +673,7 @@ public function testDownloadShareWithCreateOnlyShare(): void {
$share
->expects($this->once())
->method('getPermissions')
- ->willReturn(\OCP\Constants::PERMISSION_CREATE);
+ ->willReturn(Constants::PERMISSION_CREATE);
$this->shareManager
->expects($this->once())
diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
index bf02e8114df89..b3b395da8c059 100644
--- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
@@ -8,7 +8,6 @@
use OCA\Files_Sharing\Controller\ShareesAPIController;
use OCA\Files_Sharing\Tests\TestCase;
-use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\Collaboration\Collaborators\ISearch;
@@ -298,7 +297,7 @@ public function testSearch(
}
});
- $this->assertInstanceOf(Http\DataResponse::class, $sharees->search($search, $itemType, $page, $perPage, $shareType));
+ $this->assertInstanceOf(DataResponse::class, $sharees->search($search, $itemType, $page, $perPage, $shareType));
}
public function dataSearchInvalid(): array {
@@ -413,7 +412,7 @@ public function testSearchSharingDisabled(): void {
}
public function testSearchNoItemType(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectException(OCSBadRequestException::class);
$this->expectExceptionMessage('Missing itemType');
$this->sharees->search('', null, 1, 10, [], false);
diff --git a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php
index e0d2d67d45f1a..a35642b0793ae 100644
--- a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php
+++ b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php
@@ -6,7 +6,10 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OC\Files\Filesystem;
use OCA\Files_Sharing\DeleteOrphanedSharesJob;
+use OCP\Constants;
+use OCP\Server;
use OCP\Share\IShare;
/**
@@ -48,7 +51,7 @@ public static function setUpBeforeClass(): void {
$appManager->disableApp('files_trashbin');
// just in case...
- \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
+ Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
}
public static function tearDownAfterClass(): void {
@@ -73,7 +76,7 @@ protected function setUp(): void {
\OC::registerShareHooks(\OC::$server->getSystemConfig());
- $this->job = \OCP\Server::get(DeleteOrphanedSharesJob::class);
+ $this->job = Server::get(DeleteOrphanedSharesJob::class);
}
protected function tearDown(): void {
@@ -119,7 +122,7 @@ public function testClearShares(): void {
$share->setNode($testSubFolder)
->setShareType(IShare::TYPE_USER)
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setSharedWith($this->user2)
->setSharedBy($this->user1);
diff --git a/apps/files_sharing/tests/EtagPropagationTest.php b/apps/files_sharing/tests/EtagPropagationTest.php
index 5a65b1b5389ab..2b6d45561ba89 100644
--- a/apps/files_sharing/tests/EtagPropagationTest.php
+++ b/apps/files_sharing/tests/EtagPropagationTest.php
@@ -8,6 +8,7 @@
use OC\Files\Filesystem;
use OC\Files\View;
+use OCP\Constants;
use OCP\Share\IShare;
/**
@@ -56,7 +57,7 @@ protected function setUpShares() {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
+ ->setPermissions(Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE);
$share = $shareManager->createShare($share);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER2);
$node = $rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER1)
@@ -67,7 +68,7 @@ protected function setUpShares() {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $shareManager->createShare($share);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER2);
@@ -76,7 +77,7 @@ protected function setUpShares() {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $shareManager->createShare($share);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER3);
@@ -90,7 +91,7 @@ protected function setUpShares() {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $shareManager->createShare($share);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER2);
@@ -117,7 +118,7 @@ protected function setUpShares() {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER4)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $shareManager->createShare($share);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER4);
@@ -131,7 +132,7 @@ protected function setUpShares() {
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER4)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = $shareManager->createShare($share);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER4);
@@ -437,13 +438,13 @@ public function testEtagChangeOnPermissionsChange(): void {
$shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node);
/** @var \OCP\Share\IShare[] $shares */
- $shares = array_filter($shares, function (\OCP\Share\IShare $share) {
+ $shares = array_filter($shares, function (IShare $share) {
return $share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2;
});
$this->assertCount(1, $shares);
$share = $shares[0];
- $share->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE);
+ $share->setPermissions(Constants::PERMISSION_READ | Constants::PERMISSION_SHARE);
$this->shareManager->updateShare($share);
$this->assertEtagsForFoldersChanged([self::TEST_FILES_SHARING_API_USER2]);
diff --git a/apps/files_sharing/tests/ExpireSharesJobTest.php b/apps/files_sharing/tests/ExpireSharesJobTest.php
index cf7be7b20a0ba..c3b81591ebc5d 100644
--- a/apps/files_sharing/tests/ExpireSharesJobTest.php
+++ b/apps/files_sharing/tests/ExpireSharesJobTest.php
@@ -8,6 +8,7 @@
use OCA\Files_Sharing\ExpireSharesJob;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Constants;
use OCP\Share\IManager;
use OCP\Share\IShare;
@@ -118,7 +119,7 @@ public function testExpireLinkShare($addExpiration, $interval, $addInterval, $sh
$share->setNode($testFolder)
->setShareType(IShare::TYPE_LINK)
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setSharedBy($this->user1);
$shareManager->createShare($share);
@@ -175,7 +176,7 @@ public function testDoNotExpireOtherShares(): void {
$share->setNode($testFolder)
->setShareType(IShare::TYPE_USER)
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setSharedBy($this->user1)
->setSharedWith($this->user2);
diff --git a/apps/files_sharing/tests/External/CacheTest.php b/apps/files_sharing/tests/External/CacheTest.php
index 139227134c684..0f5c204f79e71 100644
--- a/apps/files_sharing/tests/External/CacheTest.php
+++ b/apps/files_sharing/tests/External/CacheTest.php
@@ -7,6 +7,7 @@
namespace OCA\Files_Sharing\Tests\External;
use OC\Federation\CloudIdManager;
+use OCA\Files_Sharing\External\Cache;
use OCA\Files_Sharing\Tests\TestCase;
use OCP\Contacts\IManager;
use OCP\EventDispatcher\IEventDispatcher;
@@ -33,7 +34,7 @@ class CacheTest extends TestCase {
private $storage;
/**
- * @var \OCA\Files_Sharing\External\Cache
+ * @var Cache
*/
private $cache;
@@ -71,7 +72,7 @@ protected function setUp(): void {
->method('search')
->willReturn([]);
- $this->cache = new \OCA\Files_Sharing\External\Cache(
+ $this->cache = new Cache(
$this->storage,
$this->cloudIdManager->getCloudId($this->remoteUser, 'http://example.com/owncloud')
);
diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php
index 7302fd307f211..282467c4e28c0 100644
--- a/apps/files_sharing/tests/External/ManagerTest.php
+++ b/apps/files_sharing/tests/External/ManagerTest.php
@@ -28,6 +28,7 @@
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\OCS\IDiscoveryService;
use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
use Test\Traits\UserTrait;
@@ -156,7 +157,7 @@ private function createManagerForUser($userId) {
new StorageFactory(),
$this->clientService,
\OC::$server->getNotificationManager(),
- \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
+ \OC::$server->query(IDiscoveryService::class),
$this->cloudFederationProviderManager,
$this->cloudFederationFactory,
$this->groupManager,
diff --git a/apps/files_sharing/tests/External/ScannerTest.php b/apps/files_sharing/tests/External/ScannerTest.php
index 7daa5f229d2e0..3966fe9f71f17 100644
--- a/apps/files_sharing/tests/External/ScannerTest.php
+++ b/apps/files_sharing/tests/External/ScannerTest.php
@@ -7,6 +7,7 @@
namespace OCA\Files_Sharing\Tests\External;
use OCA\Files_Sharing\External\Scanner;
+use OCA\Files_Sharing\External\Storage;
use Test\TestCase;
/**
@@ -14,7 +15,7 @@
*/
class ScannerTest extends TestCase {
protected Scanner $scanner;
- /** @var \OCA\Files_Sharing\External\Storage|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Storage|\PHPUnit\Framework\MockObject\MockObject */
protected $storage;
/** @var \OC\Files\Cache\Cache|\PHPUnit\Framework\MockObject\MockObject */
protected $cache;
diff --git a/apps/files_sharing/tests/ExternalStorageTest.php b/apps/files_sharing/tests/ExternalStorageTest.php
index 56a1f3200308c..84271bcbb4fa7 100644
--- a/apps/files_sharing/tests/ExternalStorageTest.php
+++ b/apps/files_sharing/tests/ExternalStorageTest.php
@@ -8,6 +8,7 @@
use OC\Federation\CloudId;
use OCA\Files_Sharing\External\Manager as ExternalShareManager;
+use OCA\Files_Sharing\External\Storage;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
@@ -103,7 +104,7 @@ public function testIfTestReturnsTheValue(): void {
/**
* Dummy subclass to make it possible to access private members
*/
-class TestSharingExternalStorage extends \OCA\Files_Sharing\External\Storage {
+class TestSharingExternalStorage extends Storage {
public function getBaseUri() {
return $this->createBaseUri();
}
diff --git a/apps/files_sharing/tests/GroupEtagPropagationTest.php b/apps/files_sharing/tests/GroupEtagPropagationTest.php
index 9b2b63b018154..f2c747896976a 100644
--- a/apps/files_sharing/tests/GroupEtagPropagationTest.php
+++ b/apps/files_sharing/tests/GroupEtagPropagationTest.php
@@ -8,6 +8,7 @@
use OC\Files\Filesystem;
use OC\Files\View;
+use OCP\Constants;
use OCP\Share\IShare;
/**
@@ -38,7 +39,7 @@ protected function setUpShares() {
'/test',
self::TEST_FILES_SHARING_API_USER1,
'group1',
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER2);
$this->fileIds[self::TEST_FILES_SHARING_API_USER1][''] = $view1->getFileInfo('')->getId();
@@ -53,7 +54,7 @@ protected function setUpShares() {
'/test',
self::TEST_FILES_SHARING_API_USER2,
'group2',
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER3);
$share = $this->share(
@@ -61,7 +62,7 @@ protected function setUpShares() {
'/test/sub',
self::TEST_FILES_SHARING_API_USER2,
'group3',
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER4);
diff --git a/apps/files_sharing/tests/HelperTest.php b/apps/files_sharing/tests/HelperTest.php
index d72afc4d4aa03..fcbfc41b603e5 100644
--- a/apps/files_sharing/tests/HelperTest.php
+++ b/apps/files_sharing/tests/HelperTest.php
@@ -6,6 +6,9 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OC\Files\Filesystem;
+use OCA\Files_Sharing\Helper;
+
/**
* Class HelperTest
*
@@ -17,13 +20,13 @@ class HelperTest extends TestCase {
* test set and get share folder
*/
public function testSetGetShareFolder(): void {
- $this->assertSame('/', \OCA\Files_Sharing\Helper::getShareFolder());
+ $this->assertSame('/', Helper::getShareFolder());
- \OCA\Files_Sharing\Helper::setShareFolder('/Shared/Folder');
+ Helper::setShareFolder('/Shared/Folder');
- $sharedFolder = \OCA\Files_Sharing\Helper::getShareFolder();
- $this->assertSame('/Shared/Folder', \OCA\Files_Sharing\Helper::getShareFolder());
- $this->assertTrue(\OC\Files\Filesystem::is_dir($sharedFolder));
+ $sharedFolder = Helper::getShareFolder();
+ $this->assertSame('/Shared/Folder', Helper::getShareFolder());
+ $this->assertTrue(Filesystem::is_dir($sharedFolder));
// cleanup
\OC::$server->getConfig()->deleteSystemValue('share_folder');
diff --git a/apps/files_sharing/tests/LockingTest.php b/apps/files_sharing/tests/LockingTest.php
index c69cf99f185b6..1e822d6339ea8 100644
--- a/apps/files_sharing/tests/LockingTest.php
+++ b/apps/files_sharing/tests/LockingTest.php
@@ -8,7 +8,9 @@
use OC\Files\Filesystem;
use OC\Files\View;
+use OCP\Constants;
use OCP\Lock\ILockingProvider;
+use OCP\Lock\LockedException;
use OCP\Share\IShare;
/**
@@ -48,7 +50,7 @@ protected function setUp(): void {
'/foo/bar.txt',
$this->ownerUid,
$this->recipientUid,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE
);
$this->loginAsUser($this->recipientUid);
@@ -62,7 +64,7 @@ protected function tearDown(): void {
public function testLockAsRecipient(): void {
- $this->expectException(\OCP\Lock\LockedException::class);
+ $this->expectException(LockedException::class);
$this->loginAsUser($this->ownerUid);
diff --git a/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php b/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
index 88fa56a9bcb1f..44ef3bebdc896 100644
--- a/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
@@ -11,6 +11,7 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\AppFramework\Http\Response;
use OCP\Share\IManager as ShareManager;
use Test\TestCase;
@@ -86,7 +87,7 @@ public function testAfterExceptionS2S(): void {
}
public function testAfterControllerNoShareInfo(): void {
- $response = $this->createMock(Http\Response::class);
+ $response = $this->createMock(Response::class);
$this->assertEquals(
$response,
@@ -95,7 +96,7 @@ public function testAfterControllerNoShareInfo(): void {
}
public function testAfterControllerNoJSON(): void {
- $response = $this->createMock(Http\Response::class);
+ $response = $this->createMock(Response::class);
$this->assertEquals(
$response,
diff --git a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
index 99fcb4eaea07c..5b4f4de33d7dd 100644
--- a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
@@ -178,7 +178,7 @@ public function testBeforeControllerWithShareControllerWithSharingEnabled(): voi
public function testBeforeControllerWithSharingDisabled(): void {
- $this->expectException(\OCP\Files\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$this->expectExceptionMessage('Sharing is disabled.');
$this->appManager
diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php
index 2dc5365ae2b01..1f67bdd01fab3 100644
--- a/apps/files_sharing/tests/MountProviderTest.php
+++ b/apps/files_sharing/tests/MountProviderTest.php
@@ -7,6 +7,7 @@
namespace OCA\Files_Sharing\Tests;
use OC\Memcache\NullCache;
+use OC\Share20\Share;
use OCA\Files_Sharing\MountProvider;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
@@ -165,7 +166,7 @@ public function testExcludeShares(): void {
$this->shareManager->expects($this->any())
->method('newShare')
->willReturnCallback(function () use ($rootFolder, $userManager) {
- return new \OC\Share20\Share($rootFolder, $userManager);
+ return new Share($rootFolder, $userManager);
});
$mounts = $this->provider->getMountsForUser($this->user, $this->loader);
$this->assertCount(4, $mounts);
@@ -386,7 +387,7 @@ public function testMergeShares($userShares, $groupShares, $expectedShares, $mov
$this->shareManager->expects($this->any())
->method('newShare')
->willReturnCallback(function () use ($rootFolder, $userManager) {
- return new \OC\Share20\Share($rootFolder, $userManager);
+ return new Share($rootFolder, $userManager);
});
if ($moveFails) {
diff --git a/apps/files_sharing/tests/PropagationTestCase.php b/apps/files_sharing/tests/PropagationTestCase.php
index dee056f0658fd..78ff394bb80c3 100644
--- a/apps/files_sharing/tests/PropagationTestCase.php
+++ b/apps/files_sharing/tests/PropagationTestCase.php
@@ -6,6 +6,8 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OCA\Files_Sharing\Helper;
+
abstract class PropagationTestCase extends TestCase {
/**
* @var \OC\Files\View
@@ -16,7 +18,7 @@ abstract class PropagationTestCase extends TestCase {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
- \OCA\Files_Sharing\Helper::registerHooks();
+ Helper::registerHooks();
}
protected function setUp(): void {
diff --git a/apps/files_sharing/tests/ShareTest.php b/apps/files_sharing/tests/ShareTest.php
index 6956093a0c16c..2a3800dec196a 100644
--- a/apps/files_sharing/tests/ShareTest.php
+++ b/apps/files_sharing/tests/ShareTest.php
@@ -6,6 +6,9 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OC\Files\Filesystem;
+use OCA\Files_Sharing\Helper;
+use OCP\Constants;
use OCP\Share\IShare;
/**
@@ -63,7 +66,7 @@ public function testUnshareFromSelf(): void {
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE
);
$share2 = $this->share(
@@ -71,26 +74,26 @@ public function testUnshareFromSelf(): void {
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
'testGroup',
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE
);
$this->shareManager->acceptShare($share2, self::TEST_FILES_SHARING_API_USER2);
$this->shareManager->acceptShare($share2, self::TEST_FILES_SHARING_API_USER3);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertTrue(Filesystem::file_exists($this->filename));
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertTrue(Filesystem::file_exists($this->filename));
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- \OC\Files\Filesystem::unlink($this->filename);
+ Filesystem::unlink($this->filename);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// both group share and user share should be gone
- $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertFalse(Filesystem::file_exists($this->filename));
// for user3 nothing should change
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertTrue(Filesystem::file_exists($this->filename));
$this->shareManager->deleteShare($share1);
$this->shareManager->deleteShare($share2);
@@ -117,23 +120,23 @@ public function testShareWithDifferentShareFolder(): void {
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE
);
- \OCA\Files_Sharing\Helper::setShareFolder('/Shared/subfolder');
+ Helper::setShareFolder('/Shared/subfolder');
$share = $this->share(
IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
- $this->assertTrue(\OC\Files\Filesystem::file_exists('/Shared/subfolder/' . $this->folder));
+ $this->assertTrue(Filesystem::file_exists($this->filename));
+ $this->assertTrue(Filesystem::file_exists('/Shared/subfolder/' . $this->folder));
//cleanup
\OC::$server->getConfig()->deleteSystemValue('share_folder');
@@ -143,14 +146,14 @@ public function testShareWithGroupUniqueName(): void {
$this->markTestSkipped('TODO: Disable because fails on drone');
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OC\Files\Filesystem::file_put_contents('test.txt', 'test');
+ Filesystem::file_put_contents('test.txt', 'test');
$share = $this->share(
IShare::TYPE_GROUP,
'test.txt',
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_GROUP1,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE
);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -160,14 +163,14 @@ public function testShareWithGroupUniqueName(): void {
$this->assertSame('/test.txt', $share->getTarget());
$this->assertSame(19, $share->getPermissions());
- \OC\Files\Filesystem::rename('test.txt', 'new test.txt');
+ Filesystem::rename('test.txt', 'new test.txt');
$shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP);
$share = $shares[0];
$this->assertSame('/new test.txt', $share->getTarget());
$this->assertSame(19, $share->getPermissions());
- $share->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE);
+ $share->setPermissions(Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE);
$this->shareManager->updateShare($share);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -200,11 +203,11 @@ public function testFileSharePermissions($permission, $expectedvalid): void {
}
public function dataProviderTestFileSharePermissions() {
- $permission1 = \OCP\Constants::PERMISSION_ALL;
- $permission3 = \OCP\Constants::PERMISSION_READ;
- $permission4 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE;
- $permission5 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE;
- $permission6 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE;
+ $permission1 = Constants::PERMISSION_ALL;
+ $permission3 = Constants::PERMISSION_READ;
+ $permission4 = Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE;
+ $permission5 = Constants::PERMISSION_READ | Constants::PERMISSION_DELETE;
+ $permission6 = Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE;
return [
[$permission1, false],
@@ -221,12 +224,12 @@ public function testFileOwner(): void {
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ
+ Constants::PERMISSION_READ
);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $info = \OC\Files\Filesystem::getFileInfo($this->filename);
+ $info = Filesystem::getFileInfo($this->filename);
$this->assertSame(self::TEST_FILES_SHARING_API_USER1, $info->getOwner()->getUID());
}
diff --git a/apps/files_sharing/tests/SharedMountTest.php b/apps/files_sharing/tests/SharedMountTest.php
index 82c0770440d00..241b708f07e0f 100644
--- a/apps/files_sharing/tests/SharedMountTest.php
+++ b/apps/files_sharing/tests/SharedMountTest.php
@@ -6,11 +6,16 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OC\Files\Filesystem;
+use OC\Files\View;
use OC\Memcache\ArrayCache;
use OCA\Files_Sharing\MountProvider;
+use OCA\Files_Sharing\SharedMount;
+use OCP\Constants;
use OCP\ICacheFactory;
use OCP\IGroupManager;
use OCP\IUserManager;
+use OCP\Server;
use OCP\Share\IShare;
/**
@@ -73,7 +78,7 @@ public function testShareMountLoseParentFolder(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL);
+ Constants::PERMISSION_ALL);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER2);
$share->setTarget('/foo/bar' . $this->folder);
@@ -104,11 +109,11 @@ public function testDeleteParentOfMountPoint(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $user2View = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$this->assertTrue($user2View->file_exists($this->folder));
// create a local folder
@@ -143,25 +148,25 @@ public function testMoveSharedFile(): void {
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- \OC\Files\Filesystem::rename($this->filename, $this->filename . '_renamed');
+ Filesystem::rename($this->filename, $this->filename . '_renamed');
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename . '_renamed'));
- $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertTrue(Filesystem::file_exists($this->filename . '_renamed'));
+ $this->assertFalse(Filesystem::file_exists($this->filename));
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
- $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename . '_renamed'));
+ $this->assertTrue(Filesystem::file_exists($this->filename));
+ $this->assertFalse(Filesystem::file_exists($this->filename . '_renamed'));
// rename back to original name
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- \OC\Files\Filesystem::rename($this->filename . '_renamed', $this->filename);
- $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename . '_renamed'));
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
+ Filesystem::rename($this->filename . '_renamed', $this->filename);
+ $this->assertFalse(Filesystem::file_exists($this->filename . '_renamed'));
+ $this->assertTrue(Filesystem::file_exists($this->filename));
//cleanup
$this->shareManager->deleteShare($share);
@@ -186,7 +191,7 @@ public function testMoveGroupShare(): void {
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
'testGroup',
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE
);
$this->shareManager->acceptShare($share, $user1->getUID());
$this->shareManager->acceptShare($share, $user2->getUID());
@@ -194,20 +199,20 @@ public function testMoveGroupShare(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertTrue(Filesystem::file_exists($this->filename));
- \OC\Files\Filesystem::rename($this->filename, 'newFileName');
+ Filesystem::rename($this->filename, 'newFileName');
- $this->assertTrue(\OC\Files\Filesystem::file_exists('newFileName'));
- $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
+ $this->assertTrue(Filesystem::file_exists('newFileName'));
+ $this->assertFalse(Filesystem::file_exists($this->filename));
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
- $this->assertFalse(\OC\Files\Filesystem::file_exists('newFileName'));
+ $this->assertTrue(Filesystem::file_exists($this->filename));
+ $this->assertFalse(Filesystem::file_exists('newFileName'));
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
- $this->assertFalse(\OC\Files\Filesystem::file_exists('newFileName'));
+ $this->assertTrue(Filesystem::file_exists($this->filename));
+ $this->assertFalse(Filesystem::file_exists('newFileName'));
//cleanup
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
@@ -270,7 +275,7 @@ public function testPermissionUpgradeOnUserDeletedGroupShare(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
'testGroup',
- \OCP\Constants::PERMISSION_READ
+ Constants::PERMISSION_READ
);
$this->shareManager->acceptShare($share, $user1->getUID());
$this->shareManager->acceptShare($share, $user2->getUID());
@@ -278,14 +283,14 @@ public function testPermissionUpgradeOnUserDeletedGroupShare(): void {
// Login as user 2 and verify the item exists
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
+ $this->assertTrue(Filesystem::file_exists($this->folder));
$result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
$this->assertNotEmpty($result);
- $this->assertEquals(\OCP\Constants::PERMISSION_READ, $result->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ, $result->getPermissions());
// Delete the share
- $this->assertTrue(\OC\Files\Filesystem::rmdir($this->folder));
- $this->assertFalse(\OC\Files\Filesystem::file_exists($this->folder));
+ $this->assertTrue(Filesystem::rmdir($this->folder));
+ $this->assertFalse(Filesystem::file_exists($this->folder));
// Verify we do not get a share
$result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
@@ -293,12 +298,12 @@ public function testPermissionUpgradeOnUserDeletedGroupShare(): void {
// Login as user 1 again and change permissions
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $share->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $share->setPermissions(Constants::PERMISSION_ALL);
$share = $this->shareManager->updateShare($share);
// Login as user 2 and verify
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertFalse(\OC\Files\Filesystem::file_exists($this->folder));
+ $this->assertFalse(Filesystem::file_exists($this->folder));
$result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
$this->assertEquals(0, $result->getPermissions());
@@ -326,7 +331,7 @@ public function testShareMountOverFolder(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL);
+ Constants::PERMISSION_ALL);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER2);
$share->setTarget('/bar');
@@ -369,7 +374,7 @@ public function testShareMountOverShare(): void {
});
// hack to overwrite the cache factory, we can't use the proper "overwriteService" since the mount provider is created before this test is called
- $mountProvider = \OCP\Server::get(MountProvider::class);
+ $mountProvider = Server::get(MountProvider::class);
$reflectionClass = new \ReflectionClass($mountProvider);
$reflectionCacheFactory = $reflectionClass->getProperty('cacheFactory');
$reflectionCacheFactory->setAccessible(true);
@@ -381,7 +386,7 @@ public function testShareMountOverShare(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL);
+ Constants::PERMISSION_ALL);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER2);
$share->setTarget('/foobar');
@@ -394,7 +399,7 @@ public function testShareMountOverShare(): void {
$this->folder2,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL);
+ Constants::PERMISSION_ALL);
$this->shareManager->acceptShare($share2, self::TEST_FILES_SHARING_API_USER2);
$share2->setTarget('/foobar');
@@ -418,7 +423,7 @@ public function testShareMountOverShare(): void {
}
}
-class DummyTestClassSharedMount extends \OCA\Files_Sharing\SharedMount {
+class DummyTestClassSharedMount extends SharedMount {
public function __construct($storage, $mountpoint, $arguments = null, $loader = null) {
// noop
}
diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php
index 49ff97c053a92..fd8a51a2b03ae 100644
--- a/apps/files_sharing/tests/SharedStorageTest.php
+++ b/apps/files_sharing/tests/SharedStorageTest.php
@@ -6,10 +6,15 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OC\Files\Cache\FailedCache;
+use OC\Files\Filesystem;
+use OC\Files\Storage\FailedStorage;
+use OC\Files\Storage\Temporary;
use OC\Files\View;
use OCA\Files_Sharing\SharedStorage;
use OCA\Files_Trashbin\AppInfo\Application;
use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\Constants;
use OCP\Files\NotFoundException;
use OCP\Share\IShare;
@@ -46,7 +51,7 @@ protected function tearDown(): void {
}
}
- \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
+ Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
parent::tearDown();
}
@@ -64,11 +69,11 @@ public function testParentOfMountPointIsGone(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $user2View = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$this->assertTrue($user2View->file_exists($this->folder));
// create a local folder
@@ -84,7 +89,7 @@ public function testParentOfMountPointIsGone(): void {
// delete the local folder
/** @var \OC\Files\Storage\Storage $storage */
- [$storage, $internalPath] = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/localfolder');
+ [$storage, $internalPath] = Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/localfolder');
$storage->rmdir($internalPath);
//enforce reload of the mount points
@@ -109,12 +114,12 @@ public function testRenamePartFile(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $user2View = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$this->assertTrue($user2View->file_exists($this->folder));
@@ -149,7 +154,7 @@ public function testFilesize(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$share2 = $this->share(
@@ -157,16 +162,16 @@ public function testFilesize(): void {
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// compare file size between user1 and user2, should always be the same
- $this->assertSame($folderSize, \OC\Files\Filesystem::filesize($this->folder));
- $this->assertSame($file1Size, \OC\Files\Filesystem::filesize($this->folder . $this->filename));
- $this->assertSame($file2Size, \OC\Files\Filesystem::filesize($this->filename));
+ $this->assertSame($folderSize, Filesystem::filesize($this->folder));
+ $this->assertSame($file1Size, Filesystem::filesize($this->folder . $this->filename));
+ $this->assertSame($file2Size, Filesystem::filesize($this->filename));
//cleanup
$this->shareManager->deleteShare($share1);
@@ -179,23 +184,23 @@ public function testGetPermissions(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ
+ Constants::PERMISSION_READ
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue(\OC\Files\Filesystem::is_dir($this->folder));
+ $this->assertTrue(Filesystem::is_dir($this->folder));
// for the share root we expect:
// the read permissions (1)
// the delete permission (8), to enable unshare
- $rootInfo = \OC\Files\Filesystem::getFileInfo($this->folder);
+ $rootInfo = Filesystem::getFileInfo($this->folder);
$this->assertSame(9, $rootInfo->getPermissions());
// for the file within the shared folder we expect:
// the read permissions (1)
- $subfileInfo = \OC\Files\Filesystem::getFileInfo($this->folder . $this->filename);
+ $subfileInfo = Filesystem::getFileInfo($this->folder . $this->filename);
$this->assertSame(1, $subfileInfo->getPermissions());
@@ -211,11 +216,11 @@ public function testFopenWithReadOnlyPermission(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ
+ Constants::PERMISSION_READ
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $user2View = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
// part file should be forbidden
$handle = $user2View->fopen($this->folder . '/test.txt.part', 'w');
@@ -244,11 +249,11 @@ public function testFopenWithCreateOnlyPermission(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE
+ Constants::PERMISSION_READ | Constants::PERMISSION_CREATE
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $user2View = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
// create part file allowed
$handle = $user2View->fopen($this->folder . '/test.txt.part', 'w');
@@ -290,11 +295,11 @@ public function testFopenWithUpdateOnlyPermission(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $user2View = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
// create part file allowed
$handle = $user2View->fopen($this->folder . '/test.txt.part', 'w');
@@ -336,11 +341,11 @@ public function testFopenWithDeleteOnlyPermission(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE
+ Constants::PERMISSION_READ | Constants::PERMISSION_DELETE
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $user2View = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
// part file should be forbidden
$handle = $user2View->fopen($this->folder . '/test.txt.part', 'w');
@@ -361,7 +366,7 @@ public function testFopenWithDeleteOnlyPermission(): void {
}
public function testMountSharesOtherUser(): void {
- $rootView = new \OC\Files\View('');
+ $rootView = new View('');
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
// share 2 different files with 2 different users
@@ -370,14 +375,14 @@ public function testMountSharesOtherUser(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$share2 = $this->share(
IShare::TYPE_USER,
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER3,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -385,7 +390,7 @@ public function testMountSharesOtherUser(): void {
$mountConfigManager = \OC::$server->getMountProviderCollection();
$mounts = $mountConfigManager->getMountsForUser(\OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER3));
- array_walk($mounts, [\OC\Files\Filesystem::getMountManager(), 'addMount']);
+ array_walk($mounts, [Filesystem::getMountManager(), 'addMount']);
$this->assertTrue($rootView->file_exists('/' . self::TEST_FILES_SHARING_API_USER3 . '/files/' . $this->filename));
@@ -409,17 +414,17 @@ public function testCopyFromStorage(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $view = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$this->assertTrue($view->file_exists($this->folder));
[$sharedStorage,] = $view->resolvePath($this->folder);
$this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage'));
- $sourceStorage = new \OC\Files\Storage\Temporary([]);
+ $sourceStorage = new Temporary([]);
$sourceStorage->file_put_contents('foo.txt', 'asd');
$sharedStorage->copyFromStorage($sourceStorage, 'foo.txt', 'bar.txt');
@@ -439,17 +444,17 @@ public function testMoveFromStorage(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $view = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$this->assertTrue($view->file_exists($this->folder));
[$sharedStorage,] = $view->resolvePath($this->folder);
$this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage'));
- $sourceStorage = new \OC\Files\Storage\Temporary([]);
+ $sourceStorage = new Temporary([]);
$sourceStorage->file_put_contents('foo.txt', 'asd');
$sharedStorage->moveFromStorage($sourceStorage, 'foo.txt', 'bar.txt');
@@ -463,11 +468,11 @@ public function testMoveFromStorage(): void {
public function testNameConflict(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $view1 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
+ $view1 = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
$view1->mkdir('foo');
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
- $view3 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
+ $view3 = new View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
$view3->mkdir('foo');
// share a folder with the same name from two different users to the same user
@@ -478,7 +483,7 @@ public function testNameConflict(): void {
'foo',
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_GROUP1,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$this->shareManager->acceptShare($share1, self::TEST_FILES_SHARING_API_USER2);
@@ -491,19 +496,19 @@ public function testNameConflict(): void {
'foo',
self::TEST_FILES_SHARING_API_USER3,
self::TEST_FILES_SHARING_API_GROUP1,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$this->shareManager->acceptShare($share2, self::TEST_FILES_SHARING_API_USER2);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $view2 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $view2 = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$this->assertTrue($view2->file_exists('/foo'));
$this->assertTrue($view2->file_exists('/foo (2)'));
$mount = $view2->getMount('/foo');
$this->assertInstanceOf('\OCA\Files_Sharing\SharedMount', $mount);
- /** @var \OCA\Files_Sharing\SharedStorage $storage */
+ /** @var SharedStorage $storage */
$storage = $mount->getStorage();
$this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $storage->getOwner(''));
@@ -520,11 +525,11 @@ public function testOwnerPermissions(): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_DELETE
+ Constants::PERMISSION_ALL - Constants::PERMISSION_DELETE
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $view = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$this->assertTrue($view->file_exists($this->folder));
$view->file_put_contents($this->folder . '/newfile.txt', 'asd');
@@ -532,7 +537,7 @@ public function testOwnerPermissions(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$this->assertTrue($this->view->file_exists($this->folder . '/newfile.txt'));
- $this->assertEquals(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE,
+ $this->assertEquals(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE,
$this->view->getFileInfo($this->folder . '/newfile.txt')->getPermissions());
$this->view->unlink($this->folder);
@@ -551,8 +556,8 @@ public function testInitWithNonExistingUser(): void {
]);
// trigger init
- $this->assertInstanceOf(\OC\Files\Storage\FailedStorage::class, $storage->getSourceStorage());
- $this->assertInstanceOf(\OC\Files\Cache\FailedCache::class, $storage->getCache());
+ $this->assertInstanceOf(FailedStorage::class, $storage->getSourceStorage());
+ $this->assertInstanceOf(FailedCache::class, $storage->getCache());
}
public function testInitWithNotFoundSource(): void {
@@ -569,7 +574,7 @@ public function testInitWithNotFoundSource(): void {
]);
// trigger init
- $this->assertInstanceOf(\OC\Files\Storage\FailedStorage::class, $storage->getSourceStorage());
- $this->assertInstanceOf(\OC\Files\Cache\FailedCache::class, $storage->getCache());
+ $this->assertInstanceOf(FailedStorage::class, $storage->getSourceStorage());
+ $this->assertInstanceOf(FailedCache::class, $storage->getCache());
}
}
diff --git a/apps/files_sharing/tests/SizePropagationTest.php b/apps/files_sharing/tests/SizePropagationTest.php
index de830c508cdd9..2c6eda0fb8e20 100644
--- a/apps/files_sharing/tests/SizePropagationTest.php
+++ b/apps/files_sharing/tests/SizePropagationTest.php
@@ -7,6 +7,7 @@
namespace OCA\Files_Sharing\Tests;
use OC\Files\View;
+use OCP\Constants;
use OCP\Share\IShare;
use Test\Traits\UserTrait;
@@ -40,7 +41,7 @@ public function testSizePropagationWhenOwnerChangesFile(): void {
'/sharedfolder',
self::TEST_FILES_SHARING_API_USER2,
self::TEST_FILES_SHARING_API_USER1,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$ownerRootInfo = $ownerView->getFileInfo('', false);
@@ -75,7 +76,7 @@ public function testSizePropagationWhenRecipientChangesFile(): void {
'/sharedfolder',
self::TEST_FILES_SHARING_API_USER2,
self::TEST_FILES_SHARING_API_USER1,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$ownerRootInfo = $ownerView->getFileInfo('', false);
diff --git a/apps/files_sharing/tests/TestCase.php b/apps/files_sharing/tests/TestCase.php
index 4545e67be3219..473b7cb722729 100644
--- a/apps/files_sharing/tests/TestCase.php
+++ b/apps/files_sharing/tests/TestCase.php
@@ -6,7 +6,10 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OC\Files\Cache\Storage;
use OC\Files\Filesystem;
+use OC\Files\View;
+use OC\Group\Database;
use OC\User\DisplayNameCache;
use OCA\Files_Sharing\AppInfo\Application;
use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider;
@@ -101,8 +104,8 @@ protected function setUp(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$this->data = 'foobar';
- $this->view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
- $this->view2 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $this->view = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
+ $this->view2 = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$this->shareManager = \OC::$server->getShareManager();
$this->rootFolder = \OC::$server->getRootFolder();
@@ -153,7 +156,7 @@ public static function tearDownAfterClass(): void {
\OC_User::clearBackends();
\OC_User::useBackend('database');
\OC::$server->getGroupManager()->clearBackends();
- \OC::$server->getGroupManager()->addBackend(new \OC\Group\Database());
+ \OC::$server->getGroupManager()->addBackend(new Database());
parent::tearDownAfterClass();
}
@@ -181,9 +184,9 @@ protected static function loginHelper($user, $create = false, $password = false)
}
\OC_Util::tearDownFS();
- \OC\Files\Cache\Storage::getGlobalCache()->clearCache();
+ Storage::getGlobalCache()->clearCache();
\OC::$server->getUserSession()->setUser(null);
- \OC\Files\Filesystem::tearDown();
+ Filesystem::tearDown();
\OC::$server->getUserSession()->login($user, $password);
\OC::$server->getUserFolder($user);
diff --git a/apps/files_sharing/tests/UnshareChildrenTest.php b/apps/files_sharing/tests/UnshareChildrenTest.php
index e95c1c68ecb2b..61c4aa94213c5 100644
--- a/apps/files_sharing/tests/UnshareChildrenTest.php
+++ b/apps/files_sharing/tests/UnshareChildrenTest.php
@@ -6,7 +6,10 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OC\Files\Filesystem;
+use OCP\Constants;
use OCP\Share\IShare;
+use OCP\Util;
/**
* Class UnshareChildrenTest
@@ -25,7 +28,7 @@ class UnshareChildrenTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
+ Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
$this->folder = self::TEST_FOLDER_NAME;
$this->subfolder = '/subfolder_share_api_test';
@@ -55,14 +58,14 @@ protected function tearDown(): void {
* @medium
*/
public function testUnshareChildren(): void {
- $fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder);
+ $fileInfo2 = Filesystem::getFileInfo($this->folder);
$this->share(
IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -72,11 +75,11 @@ public function testUnshareChildren(): void {
$this->assertCount(1, $shares);
// move shared folder to 'localDir'
- \OC\Files\Filesystem::mkdir('localDir');
- $result = \OC\Files\Filesystem::rename($this->folder, '/localDir/' . $this->folder);
+ Filesystem::mkdir('localDir');
+ $result = Filesystem::rename($this->folder, '/localDir/' . $this->folder);
$this->assertTrue($result);
- \OC\Files\Filesystem::unlink('localDir');
+ Filesystem::unlink('localDir');
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -87,6 +90,6 @@ public function testUnshareChildren(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
// the folder for the owner should still exists
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
+ $this->assertTrue(Filesystem::file_exists($this->folder));
}
}
diff --git a/apps/files_sharing/tests/UpdaterTest.php b/apps/files_sharing/tests/UpdaterTest.php
index 8aee8d7ddfc6a..62dd731559199 100644
--- a/apps/files_sharing/tests/UpdaterTest.php
+++ b/apps/files_sharing/tests/UpdaterTest.php
@@ -6,8 +6,13 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OC\Files\FileInfo;
+use OC\Files\Filesystem;
+use OC\Files\View;
+use OCA\Files_Sharing\Helper;
use OCA\Files_Trashbin\AppInfo\Application;
use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\Constants;
use OCP\Share\IShare;
/**
@@ -20,7 +25,7 @@ class UpdaterTest extends TestCase {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
- \OCA\Files_Sharing\Helper::registerHooks();
+ Helper::registerHooks();
}
protected function setUp(): void {
@@ -58,19 +63,19 @@ public function testDeleteParentFolder(): void {
$trashbinApp = new Application();
$trashbinApp->boot($this->createMock(IBootContext::class));
- $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
- $this->assertTrue($fileinfo instanceof \OC\Files\FileInfo);
+ $fileinfo = Filesystem::getFileInfo($this->folder);
+ $this->assertTrue($fileinfo instanceof FileInfo);
$this->share(
IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $view = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
// check if user2 can see the shared folder
$this->assertTrue($view->file_exists($this->folder));
@@ -96,7 +101,7 @@ public function testDeleteParentFolder(): void {
$this->assertCount(0, $foldersShared);
// trashbin should contain the local file but not the mount point
- $rootView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
+ $rootView = new View('/' . self::TEST_FILES_SHARING_API_USER2);
$trashContent = \OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_FILES_SHARING_API_USER2);
$this->assertSame(1, count($trashContent));
$firstElement = reset($trashContent);
@@ -111,7 +116,7 @@ public function testDeleteParentFolder(): void {
\OC::$server->getAppManager()->disableApp('files_trashbin');
}
- \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
+ Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
}
public function shareFolderProvider() {
@@ -135,12 +140,12 @@ public function testShareFile($shareFolder): void {
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $beforeShareRoot = \OC\Files\Filesystem::getFileInfo('');
+ $beforeShareRoot = Filesystem::getFileInfo('');
$etagBeforeShareRoot = $beforeShareRoot->getEtag();
- \OC\Files\Filesystem::mkdir($shareFolder);
+ Filesystem::mkdir($shareFolder);
- $beforeShareDir = \OC\Files\Filesystem::getFileInfo($shareFolder);
+ $beforeShareDir = Filesystem::getFileInfo($shareFolder);
$etagBeforeShareDir = $beforeShareDir->getEtag();
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
@@ -150,15 +155,15 @@ public function testShareFile($shareFolder): void {
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $afterShareRoot = \OC\Files\Filesystem::getFileInfo('');
+ $afterShareRoot = Filesystem::getFileInfo('');
$etagAfterShareRoot = $afterShareRoot->getEtag();
- $afterShareDir = \OC\Files\Filesystem::getFileInfo($shareFolder);
+ $afterShareDir = Filesystem::getFileInfo($shareFolder);
$etagAfterShareDir = $afterShareDir->getEtag();
$this->assertTrue(is_string($etagBeforeShareRoot));
@@ -179,36 +184,36 @@ public function testShareFile($shareFolder): void {
* if a folder gets renamed all children mount points should be renamed too
*/
public function testRename(): void {
- $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
+ $fileinfo = Filesystem::getFileInfo($this->folder);
$share = $this->share(
IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
// make sure that the shared folder exists
- $this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
+ $this->assertTrue(Filesystem::file_exists($this->folder));
- \OC\Files\Filesystem::mkdir('oldTarget');
- \OC\Files\Filesystem::mkdir('oldTarget/subfolder');
- \OC\Files\Filesystem::mkdir('newTarget');
+ Filesystem::mkdir('oldTarget');
+ Filesystem::mkdir('oldTarget/subfolder');
+ Filesystem::mkdir('newTarget');
- \OC\Files\Filesystem::rename($this->folder, 'oldTarget/subfolder/' . $this->folder);
+ Filesystem::rename($this->folder, 'oldTarget/subfolder/' . $this->folder);
// re-login to make sure that the new mount points are initialized
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- \OC\Files\Filesystem::rename('/oldTarget', '/newTarget/oldTarget');
+ Filesystem::rename('/oldTarget', '/newTarget/oldTarget');
// re-login to make sure that the new mount points are initialized
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists('/newTarget/oldTarget/subfolder/' . $this->folder));
+ $this->assertTrue(Filesystem::file_exists('/newTarget/oldTarget/subfolder/' . $this->folder));
// cleanup
$this->shareManager->deleteShare($share);
@@ -229,7 +234,7 @@ public function testMovedIntoShareChangeOwner(): void {
$this->markTestSkipped('Skipped because this is failing with S3 as primary as file id are change when moved.');
// user1 creates folder1
- $viewUser1 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
+ $viewUser1 = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
$folder1 = 'folder1';
$viewUser1->mkdir($folder1);
@@ -239,11 +244,11 @@ public function testMovedIntoShareChangeOwner(): void {
$folder1,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_SHARE
);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $viewUser2 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+ $viewUser2 = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
// Create user2 files
$folder2 = 'folder2';
$viewUser2->mkdir($folder2);
@@ -262,7 +267,7 @@ public function testMovedIntoShareChangeOwner(): void {
$folder2,
self::TEST_FILES_SHARING_API_USER2,
self::TEST_FILES_SHARING_API_USER3,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
// user2 shares folder2/file1 to user3
$file1Share = $this->share(
@@ -270,7 +275,7 @@ public function testMovedIntoShareChangeOwner(): void {
$file1,
self::TEST_FILES_SHARING_API_USER2,
self::TEST_FILES_SHARING_API_USER3,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_SHARE
);
// user2 shares subfolder1 to user3
$subfolder1Share = $this->share(
@@ -278,7 +283,7 @@ public function testMovedIntoShareChangeOwner(): void {
$subfolder1,
self::TEST_FILES_SHARING_API_USER2,
self::TEST_FILES_SHARING_API_USER3,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
// user2 shares subfolder2/file2.txt to user3
$file2Share = $this->share(
@@ -286,7 +291,7 @@ public function testMovedIntoShareChangeOwner(): void {
$file2,
self::TEST_FILES_SHARING_API_USER2,
self::TEST_FILES_SHARING_API_USER3,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_SHARE
);
// user2 moves folder2 into folder1
@@ -302,10 +307,10 @@ public function testMovedIntoShareChangeOwner(): void {
$this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $subfolder1Share->getShareOwner());
$this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $file2Share->getShareOwner());
// Expect permissions to be limited by the permissions of the destination share
- $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $folder2Share->getPermissions());
- $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $file1Share->getPermissions());
- $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $subfolder1Share->getPermissions());
- $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $file2Share->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ | Constants::PERMISSION_SHARE, $folder2Share->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ | Constants::PERMISSION_SHARE, $file1Share->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ | Constants::PERMISSION_SHARE, $subfolder1Share->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ | Constants::PERMISSION_SHARE, $file2Share->getPermissions());
// user2 moves folder2 out of folder1
$viewUser2->rename($folder1 . '/' . $folder2, $folder2);
@@ -320,10 +325,10 @@ public function testMovedIntoShareChangeOwner(): void {
$this->assertEquals(self::TEST_FILES_SHARING_API_USER2, $subfolder1Share->getShareOwner());
$this->assertEquals(self::TEST_FILES_SHARING_API_USER2, $file2Share->getShareOwner());
// Expect permissions to not change
- $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $folder2Share->getPermissions());
- $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $file1Share->getPermissions());
- $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $subfolder1Share->getPermissions());
- $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $file2Share->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ | Constants::PERMISSION_SHARE, $folder2Share->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ | Constants::PERMISSION_SHARE, $file1Share->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ | Constants::PERMISSION_SHARE, $subfolder1Share->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ | Constants::PERMISSION_SHARE, $file2Share->getPermissions());
// cleanup
$this->shareManager->deleteShare($folder1Share);
diff --git a/apps/files_sharing/tests/WatcherTest.php b/apps/files_sharing/tests/WatcherTest.php
index 012acdcd69128..cddba7db7359e 100644
--- a/apps/files_sharing/tests/WatcherTest.php
+++ b/apps/files_sharing/tests/WatcherTest.php
@@ -6,6 +6,8 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OC\Files\View;
+use OCP\Constants;
use OCP\Share\IShare;
/**
@@ -50,7 +52,7 @@ protected function setUp(): void {
'container/shareddir',
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
- \OCP\Constants::PERMISSION_ALL
+ Constants::PERMISSION_ALL
);
$this->_share->setStatus(IShare::STATUS_ACCEPTED);
@@ -60,7 +62,7 @@ protected function setUp(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// retrieve the shared storage
- $secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
+ $secondView = new View('/' . self::TEST_FILES_SHARING_API_USER2);
[$this->sharedStorage, $internalPath] = $secondView->resolvePath('files/shareddir');
$this->sharedCache = $this->sharedStorage->getCache();
}
diff --git a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
index 651f5035c1cb5..b5980b27c0af4 100644
--- a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
+++ b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_Trashbin\BackgroundJob;
+use OC\Files\View;
use OCA\Files_Trashbin\Expiration;
use OCA\Files_Trashbin\Helper;
use OCA\Files_Trashbin\Trashbin;
@@ -70,7 +71,7 @@ protected function setupFS(string $user): bool {
\OC_Util::setupFS($user);
// Check if this user has a trashbin directory
- $view = new \OC\Files\View('/' . $user);
+ $view = new View('/' . $user);
if (!$view->is_dir('/files_trashbin/files')) {
return false;
}
diff --git a/apps/files_trashbin/lib/Command/ExpireTrash.php b/apps/files_trashbin/lib/Command/ExpireTrash.php
index 33a5ac83dbf41..c27d74c0c26fa 100644
--- a/apps/files_trashbin/lib/Command/ExpireTrash.php
+++ b/apps/files_trashbin/lib/Command/ExpireTrash.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_Trashbin\Command;
+use OC\Files\View;
use OCA\Files_Trashbin\Expiration;
use OCA\Files_Trashbin\Helper;
use OCA\Files_Trashbin\Trashbin;
@@ -103,7 +104,7 @@ protected function setupFS($user) {
\OC_Util::setupFS($user);
// Check if this user has a trashbin directory
- $view = new \OC\Files\View('/' . $user);
+ $view = new View('/' . $user);
if (!$view->is_dir('/files_trashbin/files')) {
return false;
}
diff --git a/apps/files_trashbin/lib/Command/RestoreAllFiles.php b/apps/files_trashbin/lib/Command/RestoreAllFiles.php
index 969791379c153..81b59543a4e7c 100644
--- a/apps/files_trashbin/lib/Command/RestoreAllFiles.php
+++ b/apps/files_trashbin/lib/Command/RestoreAllFiles.php
@@ -7,6 +7,7 @@
use OC\Core\Command\Base;
use OCA\Files_Trashbin\Trash\ITrashManager;
+use OCA\Files_Trashbin\Trash\TrashItem;
use OCP\Files\IRootFolder;
use OCP\IDBConnection;
use OCP\IL10N;
@@ -246,7 +247,7 @@ protected function filterTrashItems(array $trashItems, int $scope, ?int $since,
$trashItemClass = get_class($trashItem);
// Check scope with exact class name for locally deleted files
- if ($scope === self::SCOPE_USER && $trashItemClass !== \OCA\Files_Trashbin\Trash\TrashItem::class) {
+ if ($scope === self::SCOPE_USER && $trashItemClass !== TrashItem::class) {
$output->writeln('Skipping ' . $trashItem->getName() . ' because it is not a user trash item', OutputInterface::VERBOSITY_VERBOSE);
continue;
}
diff --git a/apps/files_trashbin/lib/Controller/PreviewController.php b/apps/files_trashbin/lib/Controller/PreviewController.php
index b006ba5e5aca4..78d501b68d4c6 100644
--- a/apps/files_trashbin/lib/Controller/PreviewController.php
+++ b/apps/files_trashbin/lib/Controller/PreviewController.php
@@ -14,6 +14,7 @@
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\Folder;
use OCP\Files\IMimeTypeDetector;
@@ -111,7 +112,7 @@ public function getPreview(
}
$f = $this->previewManager->getPreview($file, $x, $y, !$a, IPreview::MODE_FILL, $mimeType);
- $response = new Http\FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]);
+ $response = new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]);
// Cache previews for 24H
$response->cacheFor(3600 * 24);
diff --git a/apps/files_trashbin/lib/Helper.php b/apps/files_trashbin/lib/Helper.php
index 2e7916d9c6d05..7aeb737a56c40 100644
--- a/apps/files_trashbin/lib/Helper.php
+++ b/apps/files_trashbin/lib/Helper.php
@@ -7,6 +7,7 @@
namespace OCA\Files_Trashbin;
use OC\Files\FileInfo;
+use OC\Files\View;
use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
@@ -25,7 +26,7 @@ public static function getTrashFiles($dir, $user, $sortAttribute = '', $sortDesc
$result = [];
$timestamp = null;
- $view = new \OC\Files\View('/' . $user . '/files_trashbin/files');
+ $view = new View('/' . $user . '/files_trashbin/files');
if (ltrim($dir, '/') !== '' && !$view->is_dir($dir)) {
throw new \Exception('Directory does not exists');
@@ -36,7 +37,7 @@ public static function getTrashFiles($dir, $user, $sortAttribute = '', $sortDesc
$absoluteDir = $view->getAbsolutePath($dir);
$internalPath = $mount->getInternalPath($absoluteDir);
- $extraData = \OCA\Files_Trashbin\Trashbin::getExtraData($user);
+ $extraData = Trashbin::getExtraData($user);
$dirContent = $storage->getCache()->getFolderContents($mount->getInternalPath($view->getAbsolutePath($dir)));
foreach ($dirContent as $entry) {
$entryName = $entry->getName();
@@ -98,7 +99,7 @@ public static function formatFileInfos($fileInfos) {
$entry = \OCA\Files\Helper::formatFileInfo($i);
$entry['id'] = $i->getId();
$entry['etag'] = $entry['mtime']; // add fake etag, it is only needed to identify the preview image
- $entry['permissions'] = \OCP\Constants::PERMISSION_READ;
+ $entry['permissions'] = Constants::PERMISSION_READ;
$files[] = $entry;
}
return $files;
diff --git a/apps/files_trashbin/lib/Sabre/TrashRoot.php b/apps/files_trashbin/lib/Sabre/TrashRoot.php
index 3421a56bd5acd..e2661ccdec72d 100644
--- a/apps/files_trashbin/lib/Sabre/TrashRoot.php
+++ b/apps/files_trashbin/lib/Sabre/TrashRoot.php
@@ -10,6 +10,7 @@
use OCA\Files_Trashbin\Trash\ITrashItem;
use OCA\Files_Trashbin\Trash\ITrashManager;
+use OCA\Files_Trashbin\Trashbin;
use OCP\Files\FileInfo;
use OCP\IUser;
use Sabre\DAV\Exception\Forbidden;
@@ -30,7 +31,7 @@ public function __construct(IUser $user, ITrashManager $trashManager) {
}
public function delete() {
- \OCA\Files_Trashbin\Trashbin::deleteAll();
+ Trashbin::deleteAll();
foreach ($this->trashManager->listTrashRoot($this->user) as $trashItem) {
$this->trashManager->removeItem($trashItem);
}
diff --git a/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php b/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php
index 862c746c23914..0fd370a6cf137 100644
--- a/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php
+++ b/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php
@@ -92,7 +92,7 @@ public function moveToTrash(IStorage $storage, string $internalPath): bool {
$this->deletedFiles[$normalized] = $normalized;
if ($filesPath = $view->getRelativePath($normalized)) {
$filesPath = trim($filesPath, '/');
- $result = \OCA\Files_Trashbin\Trashbin::move2trash($filesPath);
+ $result = Trashbin::move2trash($filesPath);
} else {
$result = false;
}
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index a30ba0ce0551c..f6e5a3830ad96 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -19,6 +19,8 @@
use OCA\Files_Trashbin\Command\Expire;
use OCA\Files_Trashbin\Events\BeforeNodeRestoredEvent;
use OCA\Files_Trashbin\Events\NodeRestoredEvent;
+use OCA\Files_Trashbin\Exceptions\CopyRecursiveException;
+use OCA\Files_Versions\Storage;
use OCP\App\IAppManager;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\Event;
@@ -39,6 +41,7 @@
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
use OCP\Server;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/** @template-implements IEventListener */
@@ -293,7 +296,7 @@ public static function move2trash($file_path, $ownerOnly = false) {
if ($sourceStorage->getCache()->inCache($sourceInternalPath)) {
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
}
- } catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
+ } catch (CopyRecursiveException $e) {
$moveSuccessful = false;
if ($trashStorage->file_exists($trashInternalPath)) {
$trashStorage->unlink($trashInternalPath);
@@ -329,7 +332,7 @@ public static function move2trash($file_path, $ownerOnly = false) {
if (!$result) {
\OC::$server->get(LoggerInterface::class)->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']);
}
- \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path),
+ Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path),
'trashPath' => Filesystem::normalizePath(static::getTrashFilename($filename, $timestamp))]);
self::retainVersions($filename, $owner, $ownerPath, $timestamp);
@@ -356,11 +359,11 @@ private static function getConfiguredTrashbinSize(string $user): int|float {
$config = \OC::$server->get(IConfig::class);
$userTrashbinSize = $config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
if (is_numeric($userTrashbinSize) && ($userTrashbinSize > -1)) {
- return \OCP\Util::numericToNumber($userTrashbinSize);
+ return Util::numericToNumber($userTrashbinSize);
}
$systemTrashbinSize = $config->getAppValue('files_trashbin', 'trashbin_size', '-1');
if (is_numeric($systemTrashbinSize)) {
- return \OCP\Util::numericToNumber($systemTrashbinSize);
+ return Util::numericToNumber($systemTrashbinSize);
}
return -1;
}
@@ -374,7 +377,7 @@ private static function getConfiguredTrashbinSize(string $user): int|float {
* @param int $timestamp when the file was deleted
*/
private static function retainVersions($filename, $owner, $ownerPath, $timestamp) {
- if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions') && !empty($ownerPath)) {
+ if (Server::get(IAppManager::class)->isEnabledForUser('files_versions') && !empty($ownerPath)) {
$user = OC_User::getUser();
$rootView = new View('/');
@@ -383,7 +386,7 @@ private static function retainVersions($filename, $owner, $ownerPath, $timestamp
self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . static::getTrashFilename(basename($ownerPath), $timestamp), $rootView);
}
self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . static::getTrashFilename($filename, $timestamp));
- } elseif ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) {
+ } elseif ($versions = Storage::getVersions($owner, $ownerPath)) {
foreach ($versions as $v) {
if ($owner !== $user) {
self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . static::getTrashFilename($v['name'] . '.v' . $v['version'], $timestamp));
@@ -505,7 +508,7 @@ public static function restore($file, $filename, $timestamp) {
$view->chroot('/' . $user . '/files');
$view->touch('/' . $location . '/' . $uniqueFilename, $mtime);
$view->chroot($fakeRoot);
- \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => $targetPath, 'trashPath' => $sourcePath]);
+ Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => $targetPath, 'trashPath' => $sourcePath]);
$sourceNode = self::getNodeForPath($sourcePath);
$targetNode = self::getNodeForPath($targetPath);
@@ -542,7 +545,7 @@ public static function restore($file, $filename, $timestamp) {
* @return false|null
*/
private static function restoreVersions(View $view, $file, $filename, $uniqueFilename, $location, $timestamp) {
- if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
+ if (Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
$user = OC_User::getUser();
$rootView = new View('/');
@@ -700,7 +703,7 @@ public static function delete($filename, $user, $timestamp = null) {
*/
private static function deleteVersions(View $view, $file, $filename, $timestamp, string $user): int|float {
$size = 0;
- if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
+ if (Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
if ($view->is_dir('files_trashbin/versions/' . $file)) {
$size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file));
$view->unlink('files_trashbin/versions/' . $file);
@@ -778,7 +781,7 @@ private static function calculateFreeSpace(int|float $trashbinSize, string $user
$quota = PHP_INT_MAX;
}
} else {
- $quota = \OCP\Util::computerFileSize($quota);
+ $quota = Util::computerFileSize($quota);
// invalid quota
if ($quota === false) {
$quota = PHP_INT_MAX;
@@ -802,7 +805,7 @@ private static function calculateFreeSpace(int|float $trashbinSize, string $user
$availableSpace = $quota;
}
- return \OCP\Util::numericToNumber($availableSpace);
+ return Util::numericToNumber($availableSpace);
}
/**
@@ -902,7 +905,7 @@ public static function deleteExpiredFiles($files, $user) {
try {
$size += self::delete($filename, $user, $timestamp);
$count++;
- } catch (\OCP\Files\NotPermittedException $e) {
+ } catch (NotPermittedException $e) {
\OC::$server->get(LoggerInterface::class)->warning('Removing "' . $filename . '" from trashbin failed.',
[
'exception' => $e,
@@ -944,7 +947,7 @@ private static function copy_recursive($source, $destination, View $view): int|f
$size += $view->filesize($pathDir);
$result = $view->copy($pathDir, $destination . '/' . $i['name']);
if (!$result) {
- throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
+ throw new CopyRecursiveException();
}
$view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir));
}
@@ -953,7 +956,7 @@ private static function copy_recursive($source, $destination, View $view): int|f
$size += $view->filesize($source);
$result = $view->copy($source, $destination);
if (!$result) {
- throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
+ throw new CopyRecursiveException();
}
$view->touch($destination, $view->filemtime($source));
}
@@ -1033,7 +1036,7 @@ private static function getVersionsFromTrash($filename, $timestamp, string $user
private static function getUniqueFilename($location, $filename, View $view) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$name = pathinfo($filename, PATHINFO_FILENAME);
- $l = \OCP\Util::getL10N('files_trashbin');
+ $l = Util::getL10N('files_trashbin');
$location = '/' . trim($location, '/');
diff --git a/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php b/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php
index 87c8647450fb4..b58efbb38a63a 100644
--- a/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php
+++ b/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php
@@ -10,6 +10,7 @@
namespace OCA\Files_Trashbin\UserMigration;
use OCA\Files_Trashbin\AppInfo\Application;
+use OCA\Files_Trashbin\Trashbin;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
@@ -81,7 +82,7 @@ public function export(IUser $user, IExportDestination $exportDestination, Outpu
$exportDestination->copyFolder($trashbinFolder, static::PATH_FILES_FOLDER);
$originalLocations = [];
// TODO Export all extra data and bump migrator to v2
- foreach (\OCA\Files_Trashbin\Trashbin::getExtraData($uid) as $filename => $extraData) {
+ foreach (Trashbin::getExtraData($uid) as $filename => $extraData) {
$locationData = [];
foreach ($extraData as $timestamp => ['location' => $location]) {
$locationData[$timestamp] = $location;
diff --git a/apps/files_trashbin/tests/Command/CleanUpTest.php b/apps/files_trashbin/tests/Command/CleanUpTest.php
index b071fa8ecdd1f..fef57f44f24e8 100644
--- a/apps/files_trashbin/tests/Command/CleanUpTest.php
+++ b/apps/files_trashbin/tests/Command/CleanUpTest.php
@@ -10,6 +10,7 @@
use OCA\Files_Trashbin\Command\CleanUp;
use OCP\Files\IRootFolder;
use OCP\IDBConnection;
+use OCP\UserInterface;
use Symfony\Component\Console\Exception\InvalidOptionException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\NullOutput;
@@ -175,7 +176,7 @@ public function testExecuteAllUsers(): void {
->setMethods(['removeDeletedFiles'])
->setConstructorArgs([$this->rootFolder, $this->userManager, $this->dbConnection])
->getMock();
- $backend = $this->createMock(\OCP\UserInterface::class);
+ $backend = $this->createMock(UserInterface::class);
$backend->method('getUsers')
->with('', 500, 0)
->willReturn($backendUsers);
diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php
index f0f3159b32aae..703cbf5f3df15 100644
--- a/apps/files_trashbin/tests/StorageTest.php
+++ b/apps/files_trashbin/tests/StorageTest.php
@@ -10,12 +10,14 @@
use OC\Files\Storage\Common;
use OC\Files\Storage\Local;
use OC\Files\Storage\Temporary;
+use OC\Files\View;
use OCA\Files_Trashbin\AppInfo\Application;
use OCA\Files_Trashbin\Events\MoveToTrashEvent;
use OCA\Files_Trashbin\Storage;
use OCA\Files_Trashbin\Trash\ITrashManager;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Cache\ICache;
use OCP\Files\Folder;
@@ -84,10 +86,10 @@ protected function setUp(): void {
// this will setup the FS
$this->loginAsUser($this->user);
- \OCA\Files_Trashbin\Storage::setupStorage();
+ Storage::setupStorage();
- $this->rootView = new \OC\Files\View('/');
- $this->userView = new \OC\Files\View('/' . $this->user . '/files/');
+ $this->rootView = new View('/');
+ $this->userView = new View('/' . $this->user . '/files/');
$this->userView->file_put_contents('test.txt', 'foo');
$this->userView->file_put_contents(static::LONG_FILENAME, 'foo');
$this->userView->file_put_contents(static::MAX_FILENAME, 'foo');
@@ -97,7 +99,7 @@ protected function setUp(): void {
}
protected function tearDown(): void {
- \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
+ Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
$this->logout();
$user = \OC::$server->getUserManager()->get($this->user);
if ($user !== null) {
@@ -192,7 +194,7 @@ public function testSingleStorageDeleteMaxLengthFilename(): void {
*/
public function testCrossStorageDeleteFile(): void {
$storage2 = new Temporary([]);
- \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage');
+ Filesystem::mount($storage2, [], $this->user . '/files/substorage');
$this->userView->file_put_contents('substorage/subfile.txt', 'foo');
$storage2->getScanner()->scan('');
@@ -218,7 +220,7 @@ public function testCrossStorageDeleteFile(): void {
*/
public function testCrossStorageDeleteFolder(): void {
$storage2 = new Temporary([]);
- \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage');
+ Filesystem::mount($storage2, [], $this->user . '/files/substorage');
$this->userView->mkdir('substorage/folder');
$this->userView->file_put_contents('substorage/folder/subfile.txt', 'bar');
@@ -323,14 +325,14 @@ public function testDeleteVersionsOfFileAsRecipient(): void {
->setShareType(IShare::TYPE_USER)
->setSharedBy($this->user)
->setSharedWith($recipientUser)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = \OC::$server->getShareManager()->createShare($share);
\OC::$server->getShareManager()->acceptShare($share, $recipientUser);
$this->loginAsUser($recipientUser);
// delete as recipient
- $recipientView = new \OC\Files\View('/' . $recipientUser . '/files');
+ $recipientView = new View('/' . $recipientUser . '/files');
$recipientView->unlink('share/test.txt');
// rescan trash storage for both users
@@ -375,14 +377,14 @@ public function testDeleteVersionsOfFolderAsRecipient(): void {
->setShareType(IShare::TYPE_USER)
->setSharedBy($this->user)
->setSharedWith($recipientUser)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = \OC::$server->getShareManager()->createShare($share);
\OC::$server->getShareManager()->acceptShare($share, $recipientUser);
$this->loginAsUser($recipientUser);
// delete as recipient
- $recipientView = new \OC\Files\View('/' . $recipientUser . '/files');
+ $recipientView = new View('/' . $recipientUser . '/files');
$recipientView->rmdir('share/folder');
// rescan trash storage
@@ -425,7 +427,7 @@ public function testDeleteVersionsOfFolderAsRecipient(): void {
*/
public function testKeepFileAndVersionsWhenMovingFileBetweenStorages(): void {
$storage2 = new Temporary([]);
- \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage');
+ Filesystem::mount($storage2, [], $this->user . '/files/substorage');
// trigger a version (multiple would not work because of the expire logic)
$this->userView->file_put_contents('test.txt', 'v1');
@@ -464,7 +466,7 @@ public function testKeepFileAndVersionsWhenMovingFileBetweenStorages(): void {
*/
public function testKeepFileAndVersionsWhenMovingFolderBetweenStorages(): void {
$storage2 = new Temporary([]);
- \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage');
+ Filesystem::mount($storage2, [], $this->user . '/files/substorage');
// trigger a version (multiple would not work because of the expire logic)
$this->userView->file_put_contents('folder/inside.txt', 'v1');
diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php
index 11501891c779a..72aa9b280e848 100644
--- a/apps/files_trashbin/tests/TrashbinTest.php
+++ b/apps/files_trashbin/tests/TrashbinTest.php
@@ -4,10 +4,21 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
+use OC\AllConfig;
use OC\AppFramework\Bootstrap\BootContext;
use OC\AppFramework\DependencyInjection\DIContainer;
+use OC\Files\Cache\Watcher;
+use OC\Files\Filesystem;
+use OC\Files\Storage\Local;
+use OC\Files\View;
use OCA\Files_Sharing\AppInfo\Application;
use OCA\Files_Trashbin\AppInfo\Application as TrashbinApplication;
+use OCA\Files_Trashbin\Expiration;
+use OCA\Files_Trashbin\Helper;
+use OCA\Files_Trashbin\Trashbin;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Constants;
+use OCP\IConfig;
use OCP\Share\IShare;
/**
@@ -56,9 +67,9 @@ public static function setUpBeforeClass(): void {
$config = \OC::$server->getConfig();
//configure trashbin
- self::$rememberRetentionObligation = $config->getSystemValue('trashbin_retention_obligation', \OCA\Files_Trashbin\Expiration::DEFAULT_RETENTION_OBLIGATION);
- /** @var \OCA\Files_Trashbin\Expiration $expiration */
- $expiration = \OC::$server->query(\OCA\Files_Trashbin\Expiration::class);
+ self::$rememberRetentionObligation = $config->getSystemValue('trashbin_retention_obligation', Expiration::DEFAULT_RETENTION_OBLIGATION);
+ /** @var Expiration $expiration */
+ $expiration = \OC::$server->query(Expiration::class);
$expiration->setRetentionObligation('auto, 2');
// register trashbin hooks
@@ -78,13 +89,13 @@ public static function tearDownAfterClass(): void {
$user->delete();
}
- /** @var \OCA\Files_Trashbin\Expiration $expiration */
- $expiration = \OC::$server->query(\OCA\Files_Trashbin\Expiration::class);
+ /** @var Expiration $expiration */
+ $expiration = \OC::$server->query(Expiration::class);
$expiration->setRetentionObligation(self::$rememberRetentionObligation);
\OC_Hook::clear();
- \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
+ Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
if (self::$trashBinStatus) {
\OC::$server->getAppManager()->enableApp('files_trashbin');
@@ -98,12 +109,12 @@ protected function setUp(): void {
\OC::$server->getAppManager()->enableApp('files_trashbin');
$config = \OC::$server->getConfig();
- $mockConfig = $this->createMock(\OCP\IConfig::class);
+ $mockConfig = $this->createMock(IConfig::class);
$mockConfig
->method('getSystemValue')
->willReturnCallback(static function ($key, $default) use ($config) {
if ($key === 'filesystem_check_changes') {
- return \OC\Files\Cache\Watcher::CHECK_ONCE;
+ return Watcher::CHECK_ONCE;
} else {
return $config->getSystemValue($key, $default);
}
@@ -118,16 +129,16 @@ protected function setUp(): void {
->willReturnCallback(static function ($appName, $key, $default = '') use ($config) {
return $config->getAppValue($appName, $key, $default);
});
- $this->overwriteService(\OC\AllConfig::class, $mockConfig);
+ $this->overwriteService(AllConfig::class, $mockConfig);
$this->trashRoot1 = '/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin';
$this->trashRoot2 = '/' . self::TEST_TRASHBIN_USER2 . '/files_trashbin';
- $this->rootView = new \OC\Files\View();
+ $this->rootView = new View();
self::loginHelper(self::TEST_TRASHBIN_USER1);
}
protected function tearDown(): void {
- $this->restoreService(\OC\AllConfig::class);
+ $this->restoreService(AllConfig::class);
// disable trashbin to be able to properly clean up
\OC::$server->getAppManager()->disableApp('files_trashbin');
@@ -149,23 +160,23 @@ protected function tearDown(): void {
public function testExpireOldFiles(): void {
/** @var \OCP\AppFramework\Utility\ITimeFactory $time */
- $time = \OC::$server->query(\OCP\AppFramework\Utility\ITimeFactory::class);
+ $time = \OC::$server->query(ITimeFactory::class);
$currentTime = $time->getTime();
$expireAt = $currentTime - 2 * 24 * 60 * 60;
$expiredDate = $currentTime - 3 * 24 * 60 * 60;
// create some files
- \OC\Files\Filesystem::file_put_contents('file1.txt', 'file1');
- \OC\Files\Filesystem::file_put_contents('file2.txt', 'file2');
- \OC\Files\Filesystem::file_put_contents('file3.txt', 'file3');
+ Filesystem::file_put_contents('file1.txt', 'file1');
+ Filesystem::file_put_contents('file2.txt', 'file2');
+ Filesystem::file_put_contents('file3.txt', 'file3');
// delete them so that they end up in the trash bin
- \OC\Files\Filesystem::unlink('file1.txt');
- \OC\Files\Filesystem::unlink('file2.txt');
- \OC\Files\Filesystem::unlink('file3.txt');
+ Filesystem::unlink('file1.txt');
+ Filesystem::unlink('file2.txt');
+ Filesystem::unlink('file3.txt');
//make sure that files are in the trash bin
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'name');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'name');
$this->assertSame(3, count($filesInTrash));
// every second file will get a date in the past so that it will get expired
@@ -185,7 +196,7 @@ public function testExpireOldFiles(): void {
#$this->assertSame('file2.txt', $remainingFile['name']);
// check that file1.txt and file3.txt was really deleted
- $newTrashContent = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1);
+ $newTrashContent = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1);
$this->assertSame(1, count($newTrashContent));
$element = reset($newTrashContent);
// TODO: failing test
@@ -204,11 +215,11 @@ public function testExpireOldFilesShared(): void {
$expiredDate = $currentTime - 3 * 24 * 60 * 60;
// create some files
- \OC\Files\Filesystem::mkdir($folder);
- \OC\Files\Filesystem::file_put_contents($folder . 'user1-1.txt', 'file1');
- \OC\Files\Filesystem::file_put_contents($folder . 'user1-2.txt', 'file2');
- \OC\Files\Filesystem::file_put_contents($folder . 'user1-3.txt', 'file3');
- \OC\Files\Filesystem::file_put_contents($folder . 'user1-4.txt', 'file4');
+ Filesystem::mkdir($folder);
+ Filesystem::file_put_contents($folder . 'user1-1.txt', 'file1');
+ Filesystem::file_put_contents($folder . 'user1-2.txt', 'file2');
+ Filesystem::file_put_contents($folder . 'user1-3.txt', 'file3');
+ Filesystem::file_put_contents($folder . 'user1-4.txt', 'file4');
//share user1-4.txt with user2
$node = \OC::$server->getUserFolder(self::TEST_TRASHBIN_USER1)->get($folder);
@@ -217,16 +228,16 @@ public function testExpireOldFilesShared(): void {
->setNode($node)
->setSharedBy(self::TEST_TRASHBIN_USER1)
->setSharedWith(self::TEST_TRASHBIN_USER2)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = \OC::$server->getShareManager()->createShare($share);
\OC::$server->getShareManager()->acceptShare($share, self::TEST_TRASHBIN_USER2);
// delete them so that they end up in the trash bin
- \OC\Files\Filesystem::unlink($folder . 'user1-1.txt');
- \OC\Files\Filesystem::unlink($folder . 'user1-2.txt');
- \OC\Files\Filesystem::unlink($folder . 'user1-3.txt');
+ Filesystem::unlink($folder . 'user1-1.txt');
+ Filesystem::unlink($folder . 'user1-2.txt');
+ Filesystem::unlink($folder . 'user1-3.txt');
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'name');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'name');
$this->assertSame(3, count($filesInTrash));
// every second file will get a date in the past so that it will get expired
@@ -235,27 +246,27 @@ public function testExpireOldFilesShared(): void {
// login as user2
self::loginHelper(self::TEST_TRASHBIN_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists($folder . 'user1-4.txt'));
+ $this->assertTrue(Filesystem::file_exists($folder . 'user1-4.txt'));
// create some files
- \OC\Files\Filesystem::file_put_contents('user2-1.txt', 'file1');
- \OC\Files\Filesystem::file_put_contents('user2-2.txt', 'file2');
+ Filesystem::file_put_contents('user2-1.txt', 'file1');
+ Filesystem::file_put_contents('user2-2.txt', 'file2');
// delete them so that they end up in the trash bin
- \OC\Files\Filesystem::unlink('user2-1.txt');
- \OC\Files\Filesystem::unlink('user2-2.txt');
+ Filesystem::unlink('user2-1.txt');
+ Filesystem::unlink('user2-2.txt');
- $filesInTrashUser2 = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER2, 'name');
+ $filesInTrashUser2 = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER2, 'name');
$this->assertSame(2, count($filesInTrashUser2));
// every second file will get a date in the past so that it will get expired
$this->manipulateDeleteTime($filesInTrashUser2, $this->trashRoot2, $expiredDate);
- \OC\Files\Filesystem::unlink($folder . 'user1-4.txt');
+ Filesystem::unlink($folder . 'user1-4.txt');
$this->runCommands();
- $filesInTrashUser2AfterDelete = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER2);
+ $filesInTrashUser2AfterDelete = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER2);
// user2-1.txt should have been expired
$this->verifyArray($filesInTrashUser2AfterDelete, ['user2-2.txt', 'user1-4.txt']);
@@ -263,7 +274,7 @@ public function testExpireOldFilesShared(): void {
self::loginHelper(self::TEST_TRASHBIN_USER1);
// user1-1.txt and user1-3.txt should have been expired
- $filesInTrashUser1AfterDelete = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1);
+ $filesInTrashUser1AfterDelete = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1);
$this->verifyArray($filesInTrashUser1AfterDelete, ['user1-2.txt', 'user1-4.txt']);
}
@@ -303,7 +314,7 @@ private function manipulateDeleteTime($files, $trashRoot, $expireDate) {
$counter = ($counter + 1) % 2;
if ($counter === 1) {
$source = $trashRoot . '/files/' . $file['name'] . '.d' . $file['mtime'];
- $target = \OC\Files\Filesystem::normalizePath($trashRoot . '/files/' . $file['name'] . '.d' . $expireDate);
+ $target = Filesystem::normalizePath($trashRoot . '/files/' . $file['name'] . '.d' . $expireDate);
$this->rootView->rename($source, $target);
$file['mtime'] = $expireDate;
}
@@ -319,19 +330,19 @@ private function manipulateDeleteTime($files, $trashRoot, $expireDate) {
public function testExpireOldFilesUtilLimitsAreMet(): void {
// create some files
- \OC\Files\Filesystem::file_put_contents('file1.txt', 'file1');
- \OC\Files\Filesystem::file_put_contents('file2.txt', 'file2');
- \OC\Files\Filesystem::file_put_contents('file3.txt', 'file3');
+ Filesystem::file_put_contents('file1.txt', 'file1');
+ Filesystem::file_put_contents('file2.txt', 'file2');
+ Filesystem::file_put_contents('file3.txt', 'file3');
// delete them so that they end up in the trash bin
- \OC\Files\Filesystem::unlink('file3.txt');
+ Filesystem::unlink('file3.txt');
sleep(1); // make sure that every file has a unique mtime
- \OC\Files\Filesystem::unlink('file2.txt');
+ Filesystem::unlink('file2.txt');
sleep(1); // make sure that every file has a unique mtime
- \OC\Files\Filesystem::unlink('file1.txt');
+ Filesystem::unlink('file1.txt');
//make sure that files are in the trash bin
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
$this->assertSame(3, count($filesInTrash));
$testClass = new TrashbinForTesting();
@@ -340,7 +351,7 @@ public function testExpireOldFilesUtilLimitsAreMet(): void {
// the two oldest files (file3.txt and file2.txt) should be deleted
$this->assertSame(10, $sizeOfDeletedFiles);
- $newTrashContent = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1);
+ $newTrashContent = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1);
$this->assertSame(1, count($newTrashContent));
$element = reset($newTrashContent);
$this->assertSame('file1.txt', $element['name']);
@@ -360,14 +371,14 @@ public function testRestoreFileInRoot(): void {
$this->assertFalse($userFolder->nodeExists('file1.txt'));
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
$this->assertCount(1, $filesInTrash);
/** @var \OCP\Files\FileInfo */
$trashedFile = $filesInTrash[0];
$this->assertTrue(
- OCA\Files_Trashbin\Trashbin::restore(
+ Trashbin::restore(
'file1.txt.d' . $trashedFile->getMtime(),
$trashedFile->getName(),
$trashedFile->getMtime()
@@ -393,14 +404,14 @@ public function testRestoreFileInSubfolder(): void {
$this->assertFalse($userFolder->nodeExists('folder/file1.txt'));
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
$this->assertCount(1, $filesInTrash);
/** @var \OCP\Files\FileInfo */
$trashedFile = $filesInTrash[0];
$this->assertTrue(
- OCA\Files_Trashbin\Trashbin::restore(
+ Trashbin::restore(
'file1.txt.d' . $trashedFile->getMtime(),
$trashedFile->getName(),
$trashedFile->getMtime()
@@ -426,14 +437,14 @@ public function testRestoreFolder(): void {
$this->assertFalse($userFolder->nodeExists('folder'));
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
$this->assertCount(1, $filesInTrash);
/** @var \OCP\Files\FileInfo */
$trashedFolder = $filesInTrash[0];
$this->assertTrue(
- OCA\Files_Trashbin\Trashbin::restore(
+ Trashbin::restore(
'folder.d' . $trashedFolder->getMtime(),
$trashedFolder->getName(),
$trashedFolder->getMtime()
@@ -459,14 +470,14 @@ public function testRestoreFileFromTrashedSubfolder(): void {
$this->assertFalse($userFolder->nodeExists('folder'));
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
$this->assertCount(1, $filesInTrash);
/** @var \OCP\Files\FileInfo */
$trashedFile = $filesInTrash[0];
$this->assertTrue(
- OCA\Files_Trashbin\Trashbin::restore(
+ Trashbin::restore(
'folder.d' . $trashedFile->getMtime() . '/file1.txt',
'file1.txt',
$trashedFile->getMtime()
@@ -493,7 +504,7 @@ public function testRestoreFileWithMissingSourceFolder(): void {
$this->assertFalse($userFolder->nodeExists('folder/file1.txt'));
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
$this->assertCount(1, $filesInTrash);
/** @var \OCP\Files\FileInfo */
@@ -503,7 +514,7 @@ public function testRestoreFileWithMissingSourceFolder(): void {
$folder->delete();
$this->assertTrue(
- OCA\Files_Trashbin\Trashbin::restore(
+ Trashbin::restore(
'file1.txt.d' . $trashedFile->getMtime(),
$trashedFile->getName(),
$trashedFile->getMtime()
@@ -529,7 +540,7 @@ public function testRestoreFileDoesNotOverwriteExistingInRoot(): void {
$this->assertFalse($userFolder->nodeExists('file1.txt'));
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
$this->assertCount(1, $filesInTrash);
/** @var \OCP\Files\FileInfo */
@@ -540,7 +551,7 @@ public function testRestoreFileDoesNotOverwriteExistingInRoot(): void {
$file->putContent('bar');
$this->assertTrue(
- OCA\Files_Trashbin\Trashbin::restore(
+ Trashbin::restore(
'file1.txt.d' . $trashedFile->getMtime(),
$trashedFile->getName(),
$trashedFile->getMtime()
@@ -570,7 +581,7 @@ public function testRestoreFileDoesNotOverwriteExistingInSubfolder(): void {
$this->assertFalse($userFolder->nodeExists('folder/file1.txt'));
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
$this->assertCount(1, $filesInTrash);
/** @var \OCP\Files\FileInfo */
@@ -581,7 +592,7 @@ public function testRestoreFileDoesNotOverwriteExistingInSubfolder(): void {
$file->putContent('bar');
$this->assertTrue(
- OCA\Files_Trashbin\Trashbin::restore(
+ Trashbin::restore(
'file1.txt.d' . $trashedFile->getMtime(),
$trashedFile->getName(),
$trashedFile->getMtime()
@@ -600,7 +611,7 @@ public function testRestoreFileDoesNotOverwriteExistingInSubfolder(): void {
*/
public function testRestoreUnexistingFile(): void {
$this->assertFalse(
- OCA\Files_Trashbin\Trashbin::restore(
+ Trashbin::restore(
'unexist.txt.d123456',
'unexist.txt',
'123456'
@@ -624,7 +635,7 @@ public function testRestoreFileIntoReadOnlySourceFolder(): void {
$this->assertFalse($userFolder->nodeExists('folder/file1.txt'));
- $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
+ $filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'mtime');
$this->assertCount(1, $filesInTrash);
/** @var \OCP\Files\FileInfo */
@@ -632,13 +643,13 @@ public function testRestoreFileIntoReadOnlySourceFolder(): void {
// delete source folder
[$storage, $internalPath] = $this->rootView->resolvePath('/' . self::TEST_TRASHBIN_USER1 . '/files/folder');
- if ($storage instanceof \OC\Files\Storage\Local) {
+ if ($storage instanceof Local) {
$folderAbsPath = $storage->getSourcePath($internalPath);
// make folder read-only
chmod($folderAbsPath, 0555);
$this->assertTrue(
- OCA\Files_Trashbin\Trashbin::restore(
+ Trashbin::restore(
'file1.txt.d' . $trashedFile->getMtime(),
$trashedFile->getName(),
$trashedFile->getMtime()
@@ -666,7 +677,7 @@ public static function loginHelper($user, $create = false) {
\OC_Util::tearDownFS();
\OC_User::setUserId('');
- \OC\Files\Filesystem::tearDown();
+ Filesystem::tearDown();
\OC_User::setUserId($user);
\OC_Util::setupFS($user);
\OC::$server->getUserFolder($user);
@@ -675,7 +686,7 @@ public static function loginHelper($user, $create = false) {
// just a dummy class to make protected methods available for testing
-class TrashbinForTesting extends \OCA\Files_Trashbin\Trashbin {
+class TrashbinForTesting extends Trashbin {
/**
* @param OCP\Files\FileInfo[] $files
diff --git a/apps/files_versions/lib/BackgroundJob/ExpireVersions.php b/apps/files_versions/lib/BackgroundJob/ExpireVersions.php
index 098e101fbc2f6..0df87d7d83b47 100644
--- a/apps/files_versions/lib/BackgroundJob/ExpireVersions.php
+++ b/apps/files_versions/lib/BackgroundJob/ExpireVersions.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_Versions\BackgroundJob;
+use OC\Files\View;
use OCA\Files_Versions\Expiration;
use OCA\Files_Versions\Storage;
use OCP\AppFramework\Utility\ITimeFactory;
@@ -59,7 +60,7 @@ protected function setupFS(string $user): bool {
\OC_Util::setupFS($user);
// Check if this user has a versions directory
- $view = new \OC\Files\View('/' . $user);
+ $view = new View('/' . $user);
if (!$view->is_dir('/files_versions')) {
return false;
}
diff --git a/apps/files_versions/lib/Command/ExpireVersions.php b/apps/files_versions/lib/Command/ExpireVersions.php
index d37a6a40b7033..fd0118549c6ce 100644
--- a/apps/files_versions/lib/Command/ExpireVersions.php
+++ b/apps/files_versions/lib/Command/ExpireVersions.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_Versions\Command;
+use OC\Files\View;
use OCA\Files_Versions\Expiration;
use OCA\Files_Versions\Storage;
use OCP\IUser;
@@ -84,7 +85,7 @@ protected function setupFS(string $user): bool {
\OC_Util::setupFS($user);
// Check if this user has a version directory
- $view = new \OC\Files\View('/' . $user);
+ $view = new View('/' . $user);
if (!$view->is_dir('/files_versions')) {
return false;
}
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php
index af14f8e4b9f2a..e5849bf936db2 100644
--- a/apps/files_versions/lib/Storage.php
+++ b/apps/files_versions/lib/Storage.php
@@ -12,6 +12,7 @@
use OC\Files\Search\SearchComparison;
use OC\Files\Search\SearchQuery;
use OC\Files\View;
+use OC\User\NoUserException;
use OC_User;
use OCA\Files_Sharing\SharedMount;
use OCA\Files_Versions\AppInfo\Application;
@@ -37,6 +38,8 @@
use OCP\IUser;
use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
+use OCP\Server;
+use OCP\Util;
use Psr\Log\LoggerInterface;
class Storage {
@@ -68,7 +71,7 @@ class Storage {
6 => ['intervalEndsAfter' => -1, 'step' => 604800],
];
- /** @var \OCA\Files_Versions\AppInfo\Application */
+ /** @var Application */
private static $application;
/**
@@ -598,7 +601,7 @@ public static function expireOlderThanMaxForUser($uid) {
$version->delete();
\OC_Hook::emit('\OCP\Versions', 'delete', ['path' => $internalPath, 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT]);
} catch (NotPermittedException $e) {
- \OCP\Server::get(LoggerInterface::class)->error("Missing permissions to delete version: {$internalPath}", ['app' => 'files_versions', 'exception' => $e]);
+ Server::get(LoggerInterface::class)->error("Missing permissions to delete version: {$internalPath}", ['app' => 'files_versions', 'exception' => $e]);
}
}
}
@@ -814,7 +817,7 @@ public static function expire($filename, $uid) {
$user = \OC::$server->get(IUserManager::class)->get($uid);
if (is_null($user)) {
$logger->error('Backends provided no user object for ' . $uid, ['app' => 'files_versions']);
- throw new \OC\User\NoUserException('Backends provided no user object for ' . $uid);
+ throw new NoUserException('Backends provided no user object for ' . $uid);
}
\OC_Util::setupFS($uid);
@@ -841,7 +844,7 @@ public static function expire($filename, $uid) {
$quota = Filesystem::free_space('/');
$softQuota = false;
} else {
- $quota = \OCP\Util::computerFileSize($quota);
+ $quota = Util::computerFileSize($quota);
}
// make sure that we have the current size of the version history
diff --git a/apps/files_versions/lib/Versions/LegacyVersionsBackend.php b/apps/files_versions/lib/Versions/LegacyVersionsBackend.php
index bc46da857525a..92b326b6cd383 100644
--- a/apps/files_versions/lib/Versions/LegacyVersionsBackend.php
+++ b/apps/files_versions/lib/Versions/LegacyVersionsBackend.php
@@ -15,6 +15,7 @@
use OCA\Files_Versions\Db\VersionEntity;
use OCA\Files_Versions\Db\VersionsMapper;
use OCA\Files_Versions\Storage;
+use OCP\Constants;
use OCP\Files\File;
use OCP\Files\FileInfo;
use OCP\Files\Folder;
@@ -162,7 +163,7 @@ public function createVersion(IUser $user, FileInfo $file) {
}
public function rollback(IVersion $version) {
- if (!$this->currentUserHasPermissions($version->getSourceFile(), \OCP\Constants::PERMISSION_UPDATE)) {
+ if (!$this->currentUserHasPermissions($version->getSourceFile(), Constants::PERMISSION_UPDATE)) {
throw new Forbidden('You cannot restore this version because you do not have update permissions on the source file.');
}
@@ -212,7 +213,7 @@ public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): Fi
}
public function deleteVersion(IVersion $version): void {
- if (!$this->currentUserHasPermissions($version->getSourceFile(), \OCP\Constants::PERMISSION_DELETE)) {
+ if (!$this->currentUserHasPermissions($version->getSourceFile(), Constants::PERMISSION_DELETE)) {
throw new Forbidden('You cannot delete this version because you do not have delete permissions on the source file.');
}
@@ -303,7 +304,7 @@ private function currentUserHasPermissions(FileInfo $sourceFile, int $permission
}
public function setMetadataValue(Node $node, int $revision, string $key, string $value): void {
- if (!$this->currentUserHasPermissions($node, \OCP\Constants::PERMISSION_UPDATE)) {
+ if (!$this->currentUserHasPermissions($node, Constants::PERMISSION_UPDATE)) {
throw new Forbidden('You cannot update the version\'s metadata because you do not have update permissions on the source file.');
}
diff --git a/apps/files_versions/tests/Command/CleanupTest.php b/apps/files_versions/tests/Command/CleanupTest.php
index 8103c69487913..62d9576e9c505 100644
--- a/apps/files_versions/tests/Command/CleanupTest.php
+++ b/apps/files_versions/tests/Command/CleanupTest.php
@@ -12,6 +12,7 @@
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Storage\IStorage;
+use OCP\UserInterface;
use Test\TestCase;
/**
@@ -142,7 +143,7 @@ public function testExecuteAllUsers(): void {
->setConstructorArgs([$this->rootFolder, $this->userManager, $this->versionMapper])
->getMock();
- $backend = $this->getMockBuilder(\OCP\UserInterface::class)
+ $backend = $this->getMockBuilder(UserInterface::class)
->disableOriginalConstructor()->getMock();
$backend->expects($this->once())->method('getUsers')
->with('', 500, 0)
diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php
index 5b3a29571da17..e20fbc623dc72 100644
--- a/apps/files_versions/tests/VersioningTest.php
+++ b/apps/files_versions/tests/VersioningTest.php
@@ -6,14 +6,24 @@
*/
namespace OCA\Files_Versions\Tests;
+use OC\AllConfig;
+use OC\Files\Cache\Watcher;
+use OC\Files\Filesystem;
use OC\Files\Storage\Temporary;
+use OC\Files\View;
+use OC\User\NoUserException;
+use OCA\Files_Sharing\AppInfo\Application;
use OCA\Files_Versions\Db\VersionEntity;
use OCA\Files_Versions\Db\VersionsMapper;
+use OCA\Files_Versions\Storage;
use OCA\Files_Versions\Versions\IVersionManager;
+use OCP\Constants;
use OCP\Files\IMimeTypeLoader;
use OCP\IConfig;
use OCP\IUser;
+use OCP\Server;
use OCP\Share\IShare;
+use OCP\Util;
/**
* Class Test_Files_versions
@@ -44,7 +54,7 @@ class VersioningTest extends \Test\TestCase {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
- $application = new \OCA\Files_Sharing\AppInfo\Application();
+ $application = new Application();
// create test user
self::loginHelper(self::TEST_VERSIONS_USER2, true);
@@ -74,12 +84,12 @@ protected function setUp(): void {
->method('getSystemValue')
->willReturnCallback(function ($key, $default) use ($config) {
if ($key === 'filesystem_check_changes') {
- return \OC\Files\Cache\Watcher::CHECK_ONCE;
+ return Watcher::CHECK_ONCE;
} else {
return $config->getSystemValue($key, $default);
}
});
- $this->overwriteService(\OC\AllConfig::class, $mockConfig);
+ $this->overwriteService(AllConfig::class, $mockConfig);
// clear hooks
\OC_Hook::clear();
@@ -87,13 +97,13 @@ protected function setUp(): void {
\OC::$server->boot();
self::loginHelper(self::TEST_VERSIONS_USER);
- $this->rootView = new \OC\Files\View();
+ $this->rootView = new View();
if (!$this->rootView->file_exists(self::USERS_VERSIONS_ROOT)) {
$this->rootView->mkdir(self::USERS_VERSIONS_ROOT);
}
- $this->versionsMapper = \OCP\Server::get(VersionsMapper::class);
- $this->mimeTypeLoader = \OCP\Server::get(IMimeTypeLoader::class);
+ $this->versionsMapper = Server::get(VersionsMapper::class);
+ $this->mimeTypeLoader = Server::get(IMimeTypeLoader::class);
$this->user1 = $this->createMock(IUser::class);
$this->user1->method('getUID')
@@ -104,7 +114,7 @@ protected function setUp(): void {
}
protected function tearDown(): void {
- $this->restoreService(\OC\AllConfig::class);
+ $this->restoreService(AllConfig::class);
if ($this->rootView) {
$this->rootView->deleteAll(self::TEST_VERSIONS_USER . '/files/');
@@ -270,7 +280,7 @@ public function versionsProvider() {
}
public function testRename(): void {
- \OC\Files\Filesystem::file_put_contents('test.txt', 'test file');
+ Filesystem::file_put_contents('test.txt', 'test file');
$t1 = time();
// second version is two weeks older, this way we make sure that no
@@ -287,7 +297,7 @@ public function testRename(): void {
$this->rootView->file_put_contents($v2, 'version2');
// execute rename hook of versions app
- \OC\Files\Filesystem::rename('test.txt', 'test2.txt');
+ Filesystem::rename('test.txt', 'test2.txt');
$this->runCommands();
@@ -299,9 +309,9 @@ public function testRename(): void {
}
public function testRenameInSharedFolder(): void {
- \OC\Files\Filesystem::mkdir('folder1');
- \OC\Files\Filesystem::mkdir('folder1/folder2');
- \OC\Files\Filesystem::file_put_contents('folder1/test.txt', 'test file');
+ Filesystem::mkdir('folder1');
+ Filesystem::mkdir('folder1/folder2');
+ Filesystem::file_put_contents('folder1/test.txt', 'test file');
$t1 = time();
// second version is two weeks older, this way we make sure that no
@@ -324,16 +334,16 @@ public function testRenameInSharedFolder(): void {
->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = \OC::$server->getShareManager()->createShare($share);
\OC::$server->getShareManager()->acceptShare($share, self::TEST_VERSIONS_USER2);
self::loginHelper(self::TEST_VERSIONS_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists('folder1/test.txt'));
+ $this->assertTrue(Filesystem::file_exists('folder1/test.txt'));
// execute rename hook of versions app
- \OC\Files\Filesystem::rename('/folder1/test.txt', '/folder1/folder2/test.txt');
+ Filesystem::rename('/folder1/test.txt', '/folder1/folder2/test.txt');
$this->runCommands();
@@ -349,9 +359,9 @@ public function testRenameInSharedFolder(): void {
}
public function testMoveFolder(): void {
- \OC\Files\Filesystem::mkdir('folder1');
- \OC\Files\Filesystem::mkdir('folder2');
- \OC\Files\Filesystem::file_put_contents('folder1/test.txt', 'test file');
+ Filesystem::mkdir('folder1');
+ Filesystem::mkdir('folder2');
+ Filesystem::file_put_contents('folder1/test.txt', 'test file');
$t1 = time();
// second version is two weeks older, this way we make sure that no
@@ -369,7 +379,7 @@ public function testMoveFolder(): void {
$this->rootView->file_put_contents($v2, 'version2');
// execute rename hook of versions app
- \OC\Files\Filesystem::rename('folder1', 'folder2/folder1');
+ Filesystem::rename('folder1', 'folder2/folder1');
$this->runCommands();
@@ -382,8 +392,8 @@ public function testMoveFolder(): void {
public function testMoveFileIntoSharedFolderAsRecipient(): void {
- \OC\Files\Filesystem::mkdir('folder1');
- $fileInfo = \OC\Files\Filesystem::getFileInfo('folder1');
+ Filesystem::mkdir('folder1');
+ $fileInfo = Filesystem::getFileInfo('folder1');
$node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1');
$share = \OC::$server->getShareManager()->newShare();
@@ -391,13 +401,13 @@ public function testMoveFileIntoSharedFolderAsRecipient(): void {
->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = \OC::$server->getShareManager()->createShare($share);
\OC::$server->getShareManager()->acceptShare($share, self::TEST_VERSIONS_USER2);
self::loginHelper(self::TEST_VERSIONS_USER2);
$versionsFolder2 = '/' . self::TEST_VERSIONS_USER2 . '/files_versions';
- \OC\Files\Filesystem::file_put_contents('test.txt', 'test file');
+ Filesystem::file_put_contents('test.txt', 'test file');
$t1 = time();
// second version is two weeks older, this way we make sure that no
@@ -413,7 +423,7 @@ public function testMoveFileIntoSharedFolderAsRecipient(): void {
$this->rootView->file_put_contents($v2, 'version2');
// move file into the shared folder as recipient
- \OC\Files\Filesystem::rename('/test.txt', '/folder1/test.txt');
+ Filesystem::rename('/test.txt', '/folder1/test.txt');
$this->assertFalse($this->rootView->file_exists($v1));
$this->assertFalse($this->rootView->file_exists($v2));
@@ -432,7 +442,7 @@ public function testMoveFileIntoSharedFolderAsRecipient(): void {
}
public function testMoveFolderIntoSharedFolderAsRecipient(): void {
- \OC\Files\Filesystem::mkdir('folder1');
+ Filesystem::mkdir('folder1');
$node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1');
$share = \OC::$server->getShareManager()->newShare();
@@ -440,14 +450,14 @@ public function testMoveFolderIntoSharedFolderAsRecipient(): void {
->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = \OC::$server->getShareManager()->createShare($share);
\OC::$server->getShareManager()->acceptShare($share, self::TEST_VERSIONS_USER2);
self::loginHelper(self::TEST_VERSIONS_USER2);
$versionsFolder2 = '/' . self::TEST_VERSIONS_USER2 . '/files_versions';
- \OC\Files\Filesystem::mkdir('folder2');
- \OC\Files\Filesystem::file_put_contents('folder2/test.txt', 'test file');
+ Filesystem::mkdir('folder2');
+ Filesystem::file_put_contents('folder2/test.txt', 'test file');
$t1 = time();
// second version is two weeks older, this way we make sure that no
@@ -464,7 +474,7 @@ public function testMoveFolderIntoSharedFolderAsRecipient(): void {
$this->rootView->file_put_contents($v2, 'version2');
// move file into the shared folder as recipient
- \OC\Files\Filesystem::rename('/folder2', '/folder1/folder2');
+ Filesystem::rename('/folder2', '/folder1/folder2');
$this->assertFalse($this->rootView->file_exists($v1));
$this->assertFalse($this->rootView->file_exists($v2));
@@ -483,7 +493,7 @@ public function testMoveFolderIntoSharedFolderAsRecipient(): void {
}
public function testRenameSharedFile(): void {
- \OC\Files\Filesystem::file_put_contents('test.txt', 'test file');
+ Filesystem::file_put_contents('test.txt', 'test file');
$t1 = time();
// second version is two weeks older, this way we make sure that no
@@ -507,16 +517,16 @@ public function testRenameSharedFile(): void {
->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
- ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
+ ->setPermissions(Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE);
$share = \OC::$server->getShareManager()->createShare($share);
\OC::$server->getShareManager()->acceptShare($share, self::TEST_VERSIONS_USER2);
self::loginHelper(self::TEST_VERSIONS_USER2);
- $this->assertTrue(\OC\Files\Filesystem::file_exists('test.txt'));
+ $this->assertTrue(Filesystem::file_exists('test.txt'));
// execute rename hook of versions app
- \OC\Files\Filesystem::rename('test.txt', 'test2.txt');
+ Filesystem::rename('test.txt', 'test2.txt');
self::loginHelper(self::TEST_VERSIONS_USER);
@@ -532,7 +542,7 @@ public function testRenameSharedFile(): void {
}
public function testCopy(): void {
- \OC\Files\Filesystem::file_put_contents('test.txt', 'test file');
+ Filesystem::file_put_contents('test.txt', 'test file');
$t1 = time();
// second version is two weeks older, this way we make sure that no
@@ -549,7 +559,7 @@ public function testCopy(): void {
$this->rootView->file_put_contents($v2, 'version2');
// execute copy hook of versions app
- \OC\Files\Filesystem::copy('test.txt', 'test2.txt');
+ Filesystem::copy('test.txt', 'test2.txt');
$this->runCommands();
@@ -580,7 +590,7 @@ public function testGetVersions(): void {
$this->rootView->file_put_contents($v2, 'version2');
// execute copy hook of versions app
- $versions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, '/subfolder/test.txt');
+ $versions = Storage::getVersions(self::TEST_VERSIONS_USER, '/subfolder/test.txt');
$this->assertCount(2, $versions);
@@ -599,10 +609,10 @@ public function testGetVersions(): void {
*/
public function testGetVersionsEmptyFile(): void {
// execute copy hook of versions app
- $versions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, '');
+ $versions = Storage::getVersions(self::TEST_VERSIONS_USER, '');
$this->assertCount(0, $versions);
- $versions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, null);
+ $versions = Storage::getVersions(self::TEST_VERSIONS_USER, null);
$this->assertCount(0, $versions);
}
@@ -611,29 +621,29 @@ public function testExpireNonexistingFile(): void {
// needed to have a FS setup (the background job does this)
\OC_Util::setupFS(self::TEST_VERSIONS_USER);
- $this->assertFalse(\OCA\Files_Versions\Storage::expire('/void/unexist.txt', self::TEST_VERSIONS_USER));
+ $this->assertFalse(Storage::expire('/void/unexist.txt', self::TEST_VERSIONS_USER));
}
public function testExpireNonexistingUser(): void {
- $this->expectException(\OC\User\NoUserException::class);
+ $this->expectException(NoUserException::class);
$this->logout();
// needed to have a FS setup (the background job does this)
\OC_Util::setupFS(self::TEST_VERSIONS_USER);
- \OC\Files\Filesystem::file_put_contents('test.txt', 'test file');
+ Filesystem::file_put_contents('test.txt', 'test file');
- $this->assertFalse(\OCA\Files_Versions\Storage::expire('test.txt', 'unexist'));
+ $this->assertFalse(Storage::expire('test.txt', 'unexist'));
}
public function testRestoreSameStorage(): void {
- \OC\Files\Filesystem::mkdir('sub');
+ Filesystem::mkdir('sub');
$this->doTestRestore();
}
public function testRestoreCrossStorage(): void {
$storage2 = new Temporary([]);
- \OC\Files\Filesystem::mount($storage2, [], self::TEST_VERSIONS_USER . '/files/sub');
+ Filesystem::mount($storage2, [], self::TEST_VERSIONS_USER . '/files/sub');
$this->doTestRestore();
}
@@ -650,12 +660,12 @@ public function testRestoreNoPermission(): void {
->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
- ->setPermissions(\OCP\Constants::PERMISSION_READ);
+ ->setPermissions(Constants::PERMISSION_READ);
$share = \OC::$server->getShareManager()->createShare($share);
\OC::$server->getShareManager()->acceptShare($share, self::TEST_VERSIONS_USER2);
$versions = $this->createAndCheckVersions(
- \OC\Files\Filesystem::getView(),
+ Filesystem::getView(),
'folder/test.txt'
);
@@ -665,7 +675,7 @@ public function testRestoreNoPermission(): void {
$firstVersion = current($versions);
- $this->assertFalse(\OCA\Files_Versions\Storage::rollback('folder/test.txt', $firstVersion['version'], $this->user2), 'Revert did not happen');
+ $this->assertFalse(Storage::rollback('folder/test.txt', $firstVersion['version'], $this->user2), 'Revert did not happen');
$this->loginAsUser(self::TEST_VERSIONS_USER);
@@ -689,7 +699,7 @@ public function testRestoreMovedShare(): void {
->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = \OC::$server->getShareManager()->createShare($share);
$shareManager = \OC::$server->getShareManager();
$shareManager->acceptShare($share, self::TEST_VERSIONS_USER2);
@@ -698,7 +708,7 @@ public function testRestoreMovedShare(): void {
$shareManager->moveShare($share, self::TEST_VERSIONS_USER2);
$versions = $this->createAndCheckVersions(
- \OC\Files\Filesystem::getView(),
+ Filesystem::getView(),
'folder/test.txt'
);
@@ -708,7 +718,7 @@ public function testRestoreMovedShare(): void {
$firstVersion = current($versions);
- $this->assertTrue(\OCA\Files_Versions\Storage::rollback('folder/test.txt', $firstVersion['version'], $this->user1));
+ $this->assertTrue(Storage::rollback('folder/test.txt', $firstVersion['version'], $this->user1));
$this->loginAsUser(self::TEST_VERSIONS_USER);
@@ -737,7 +747,7 @@ function ($p) use (&$params): void {
}
);
- \OCP\Util::connectHook(
+ Util::connectHook(
'\OCP\Versions',
$hookName,
$eventHandler,
@@ -783,7 +793,7 @@ private function doTestRestore() {
$versionEntity->setMetadata([]);
$this->versionsMapper->insert($versionEntity);
- $oldVersions = \OCA\Files_Versions\Storage::getVersions(
+ $oldVersions = Storage::getVersions(
self::TEST_VERSIONS_USER, '/sub/test.txt'
);
@@ -795,7 +805,7 @@ private function doTestRestore() {
$params = [];
$this->connectMockHooks('rollback', $params);
- $versionManager = \OCP\Server::get(IVersionManager::class);
+ $versionManager = Server::get(IVersionManager::class);
$versions = $versionManager->getVersionsForFile($this->user1, $info1);
$version = array_filter($versions, function ($version) use ($t2) {
return $version->getRevisionId() === $t2;
@@ -828,7 +838,7 @@ private function doTestRestore() {
'Restored file has mtime from version'
);
- $newVersions = \OCA\Files_Versions\Storage::getVersions(
+ $newVersions = Storage::getVersions(
self::TEST_VERSIONS_USER, '/sub/test.txt'
);
@@ -868,7 +878,7 @@ public function testStoreVersionAsOwner(): void {
$this->loginAsUser(self::TEST_VERSIONS_USER);
$this->createAndCheckVersions(
- \OC\Files\Filesystem::getView(),
+ Filesystem::getView(),
'test.txt'
);
}
@@ -879,8 +889,8 @@ public function testStoreVersionAsOwner(): void {
public function testStoreVersionAsRecipient(): void {
$this->loginAsUser(self::TEST_VERSIONS_USER);
- \OC\Files\Filesystem::mkdir('folder');
- \OC\Files\Filesystem::file_put_contents('folder/test.txt', 'test file');
+ Filesystem::mkdir('folder');
+ Filesystem::file_put_contents('folder/test.txt', 'test file');
$node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder');
$share = \OC::$server->getShareManager()->newShare();
@@ -888,14 +898,14 @@ public function testStoreVersionAsRecipient(): void {
->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
- ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ ->setPermissions(Constants::PERMISSION_ALL);
$share = \OC::$server->getShareManager()->createShare($share);
\OC::$server->getShareManager()->acceptShare($share, self::TEST_VERSIONS_USER2);
$this->loginAsUser(self::TEST_VERSIONS_USER2);
$this->createAndCheckVersions(
- \OC\Files\Filesystem::getView(),
+ Filesystem::getView(),
'folder/test.txt'
);
@@ -916,7 +926,7 @@ public function testStoreVersionAsAnonymous(): void {
// needed to make the hooks fire
\OC_Util::setupFS(self::TEST_VERSIONS_USER);
- $userView = new \OC\Files\View('/' . self::TEST_VERSIONS_USER . '/files');
+ $userView = new View('/' . self::TEST_VERSIONS_USER . '/files');
$this->createAndCheckVersions(
$userView,
'test.txt'
@@ -927,7 +937,7 @@ public function testStoreVersionAsAnonymous(): void {
* @param \OC\Files\View $view
* @param string $path
*/
- private function createAndCheckVersions(\OC\Files\View $view, $path) {
+ private function createAndCheckVersions(View $view, $path) {
$view->file_put_contents($path, 'test file');
$view->file_put_contents($path, 'version 1');
$view->file_put_contents($path, 'version 2');
@@ -938,7 +948,7 @@ private function createAndCheckVersions(\OC\Files\View $view, $path) {
[$rootStorage,] = $this->rootView->resolvePath(self::TEST_VERSIONS_USER . '/files_versions');
$rootStorage->getScanner()->scan('files_versions');
- $versions = \OCA\Files_Versions\Storage::getVersions(
+ $versions = Storage::getVersions(
self::TEST_VERSIONS_USER, '/' . $path
);
@@ -962,7 +972,7 @@ public static function loginHelper($user, $create = false) {
\OC_Util::tearDownFS();
\OC_User::setUserId('');
- \OC\Files\Filesystem::tearDown();
+ Filesystem::tearDown();
\OC_User::setUserId($user);
\OC_Util::setupFS($user);
\OC::$server->getUserFolder($user);
@@ -970,7 +980,7 @@ public static function loginHelper($user, $create = false) {
}
// extend the original class to make it possible to test protected methods
-class VersionStorageToTest extends \OCA\Files_Versions\Storage {
+class VersionStorageToTest extends Storage {
/**
* @param integer $time
diff --git a/apps/oauth2/tests/Db/AccessTokenMapperTest.php b/apps/oauth2/tests/Db/AccessTokenMapperTest.php
index 5bb069248f3d6..d1d595ef00317 100644
--- a/apps/oauth2/tests/Db/AccessTokenMapperTest.php
+++ b/apps/oauth2/tests/Db/AccessTokenMapperTest.php
@@ -7,6 +7,7 @@
use OCA\OAuth2\Db\AccessToken;
use OCA\OAuth2\Db\AccessTokenMapper;
+use OCA\OAuth2\Exceptions\AccessTokenNotFoundException;
use OCP\AppFramework\Utility\ITimeFactory;
use Test\TestCase;
@@ -39,7 +40,7 @@ public function testGetByCode(): void {
public function testDeleteByClientId(): void {
- $this->expectException(\OCA\OAuth2\Exceptions\AccessTokenNotFoundException::class);
+ $this->expectException(AccessTokenNotFoundException::class);
$this->accessTokenMapper->deleteByClientId(1234);
$token = new AccessToken();
diff --git a/apps/oauth2/tests/Db/ClientMapperTest.php b/apps/oauth2/tests/Db/ClientMapperTest.php
index 8c00c2e0a21a6..7c11470d09668 100644
--- a/apps/oauth2/tests/Db/ClientMapperTest.php
+++ b/apps/oauth2/tests/Db/ClientMapperTest.php
@@ -7,6 +7,7 @@
use OCA\OAuth2\Db\Client;
use OCA\OAuth2\Db\ClientMapper;
+use OCA\OAuth2\Exceptions\ClientNotFoundException;
use Test\TestCase;
/**
@@ -40,7 +41,7 @@ public function testGetByIdentifier(): void {
}
public function testGetByIdentifierNotExisting(): void {
- $this->expectException(\OCA\OAuth2\Exceptions\ClientNotFoundException::class);
+ $this->expectException(ClientNotFoundException::class);
$this->clientMapper->getByIdentifier('MyTotallyNotExistingClient');
}
@@ -57,7 +58,7 @@ public function testGetByUid(): void {
}
public function testGetByUidNotExisting(): void {
- $this->expectException(\OCA\OAuth2\Exceptions\ClientNotFoundException::class);
+ $this->expectException(ClientNotFoundException::class);
$this->clientMapper->getByUid(1234);
}
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 9b90f95d84206..e2dd32a9b7df8 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -46,6 +46,7 @@
use OCP\Security\Events\GenerateSecurePasswordEvent;
use OCP\Security\ISecureRandom;
use OCP\User\Backend\ISetDisplayNameBackend;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
@@ -1029,7 +1030,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
if (is_numeric($quota)) {
$quota = (float)$quota;
} else {
- $quota = \OCP\Util::computerFileSize($quota);
+ $quota = Util::computerFileSize($quota);
}
if ($quota === false) {
throw new OCSException($this->l10n->t('Invalid quota value: %1$s', [$value]), 102);
@@ -1041,7 +1042,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
if ($maxQuota !== -1 && $quota > $maxQuota) {
throw new OCSException($this->l10n->t('Invalid quota value. %1$s is exceeding the maximum quota', [$value]), 102);
}
- $quota = \OCP\Util::humanFileSize($quota);
+ $quota = Util::humanFileSize($quota);
}
}
// no else block because quota can be set to 'none' in previous if
diff --git a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
index f878b6b73d0b8..41739b6283fe6 100644
--- a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
@@ -17,6 +17,7 @@
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
+use OCP\Server;
use OCP\Settings\IManager;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -45,7 +46,7 @@ protected function setUp(): void {
$this->l10n = $this->createMock(IL10N::class);
$this->settingManager = $this->createMock(IManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
- $this->appManager = \OCP\Server::get(IAppManager::class);
+ $this->appManager = Server::get(IAppManager::class);
}
/**
diff --git a/apps/provisioning_api/tests/Controller/AppsControllerTest.php b/apps/provisioning_api/tests/Controller/AppsControllerTest.php
index 9c815a5217818..51980ce7ed201 100644
--- a/apps/provisioning_api/tests/Controller/AppsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/AppsControllerTest.php
@@ -8,7 +8,9 @@
namespace OCA\Provisioning_API\Tests\Controller;
use OCA\Provisioning_API\Controller\AppsController;
+use OCA\Provisioning_API\Tests\TestCase;
use OCP\App\IAppManager;
+use OCP\AppFramework\OCS\OCSException;
use OCP\IRequest;
use OCP\IUserSession;
@@ -19,7 +21,7 @@
*
* @package OCA\Provisioning_API\Tests
*/
-class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase {
+class AppsControllerTest extends TestCase {
/** @var IAppManager */
private $appManager;
/** @var AppsController */
@@ -57,7 +59,7 @@ public function testGetAppInfo(): void {
public function testGetAppInfoOnBadAppID(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(998);
$this->api->getAppInfo('not_provisioning_api');
@@ -94,7 +96,7 @@ public function testGetAppsDisabled(): void {
public function testGetAppsInvalidFilter(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(101);
$this->api->getApps('foo');
diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
index f9c0848fb7249..44f82c6e1d7c0 100644
--- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
@@ -12,6 +12,7 @@
use OC\User\NoUserException;
use OCA\Provisioning_API\Controller\GroupsController;
use OCP\Accounts\IAccountManager;
+use OCP\AppFramework\OCS\OCSException;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUser;
@@ -255,7 +256,7 @@ public function testGetGroupAsSubadmin(): void {
public function testGetGroupAsIrrelevantSubadmin(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(403);
$group = $this->createGroup('group');
@@ -300,7 +301,7 @@ public function testGetGroupAsAdmin(): void {
public function testGetGroupNonExisting(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('The requested group could not be found');
$this->expectExceptionCode(404);
@@ -311,7 +312,7 @@ public function testGetGroupNonExisting(): void {
public function testGetSubAdminsOfGroupsNotExists(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Group does not exist');
$this->expectExceptionCode(101);
@@ -358,7 +359,7 @@ public function testGetSubAdminsOfGroupEmptyList(): void {
public function testAddGroupEmptyGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Invalid group name');
$this->expectExceptionCode(101);
@@ -367,7 +368,7 @@ public function testAddGroupEmptyGroup(): void {
public function testAddGroupExistingGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(102);
$this->groupManager
@@ -412,7 +413,7 @@ public function testAddGroupWithSpecialChar(): void {
public function testDeleteGroupNonExisting(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(101);
$this->api->deleteGroup('NonExistingGroup');
@@ -420,7 +421,7 @@ public function testDeleteGroupNonExisting(): void {
public function testDeleteAdminGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(102);
$this->groupManager
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index 3fcac1290db80..74e0007e2fdd4 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -216,7 +216,7 @@ public function testGetUsersAsSubAdmin(): void {
public function testAddUserAlreadyExisting(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(102);
$this->userManager
@@ -250,7 +250,7 @@ public function testAddUserAlreadyExisting(): void {
public function testAddUserNonExistingGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Group NonExistingGroup does not exist');
$this->expectExceptionCode(104);
@@ -286,7 +286,7 @@ public function testAddUserNonExistingGroup(): void {
public function testAddUserExistingGroupNonExistingGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Group NonExistingGroup does not exist');
$this->expectExceptionCode(104);
@@ -527,7 +527,7 @@ public function testAddUserSuccessfulGeneratePassword(): void {
public function testAddUserFailedToGenerateUserID(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Could not create non-existing user ID');
$this->expectExceptionCode(111);
@@ -570,7 +570,7 @@ public function testAddUserFailedToGenerateUserID(): void {
public function testAddUserEmailRequired(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Required email address was not provided');
$this->expectExceptionCode(110);
@@ -677,7 +677,7 @@ public function testAddUserExistingGroup(): void {
public function testAddUserUnsuccessful(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Bad request');
$this->expectExceptionCode(101);
@@ -724,7 +724,7 @@ public function testAddUserUnsuccessful(): void {
public function testAddUserAsSubAdminNoGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('No group specified (required for sub-admins)');
$this->expectExceptionCode(106);
@@ -757,7 +757,7 @@ public function testAddUserAsSubAdminNoGroup(): void {
public function testAddUserAsSubAdminValidGroupNotSubAdmin(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Insufficient privileges for group ExistingGroup');
$this->expectExceptionCode(105);
@@ -900,7 +900,7 @@ public function testAddUserAsSubAdminExistingGroups(): void {
public function testGetUserTargetDoesNotExist(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('User does not exist');
$this->expectExceptionCode(404);
@@ -1220,7 +1220,7 @@ public function testGetUserDataAsSubAdminAndUserIsAccessible(): void {
public function testGetUserDataAsSubAdminAndUserIsNotAccessible(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(998);
$loggedInUser = $this->getMockBuilder(IUser::class)
@@ -1687,7 +1687,7 @@ public function testEditUserRegularUserSelfEditAddAdditionalEmailDuplicate(): vo
}
public function testEditUserRegularUserSelfEditChangeEmailInvalid(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(102);
$loggedInUser = $this->getMockBuilder(IUser::class)
@@ -1921,7 +1921,7 @@ public function testEditUserRegularUserSelfEditChangePassword(): void {
public function testEditUserRegularUserSelfEditChangeQuota(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(103);
$loggedInUser = $this->getMockBuilder(IUser::class)
@@ -2007,7 +2007,7 @@ public function testEditUserAdminUserSelfEditChangeValidQuota(): void {
public function testEditUserAdminUserSelfEditChangeInvalidQuota(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Invalid quota value: ABC');
$this->expectExceptionCode(102);
@@ -2158,7 +2158,7 @@ public function dataEditUserSelfEditChangeLanguageButForced() {
* @dataProvider dataEditUserSelfEditChangeLanguageButForced
*/
public function testEditUserSelfEditChangeLanguageButForced($forced): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->config->expects($this->any())
->method('getSystemValue')
@@ -2254,7 +2254,7 @@ public function testEditUserAdminEditChangeLanguage(): void {
* @dataProvider dataEditUserSelfEditChangeLanguageButForced
*/
public function testEditUserAdminEditChangeLanguageInvalidLanguage(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->l10nFactory->expects($this->once())
@@ -2358,7 +2358,7 @@ public function testEditUserSubadminUserAccessible(): void {
public function testEditUserSubadminUserInaccessible(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(998);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -2398,7 +2398,7 @@ public function testEditUserSubadminUserInaccessible(): void {
public function testDeleteUserNotExistingUser(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(998);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -2421,7 +2421,7 @@ public function testDeleteUserNotExistingUser(): void {
public function testDeleteUserSelf(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(101);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -2482,7 +2482,7 @@ public function testDeleteSuccessfulUserAsAdmin(): void {
public function testDeleteUnsuccessfulUserAsAdmin(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(101);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -2563,7 +2563,7 @@ public function testDeleteSuccessfulUserAsSubadmin(): void {
public function testDeleteUnsuccessfulUserAsSubadmin(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(101);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -2611,7 +2611,7 @@ public function testDeleteUnsuccessfulUserAsSubadmin(): void {
public function testDeleteUserAsSubAdminAndUserIsNotAccessible(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(998);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -2655,7 +2655,7 @@ public function testDeleteUserAsSubAdminAndUserIsNotAccessible(): void {
public function testGetUsersGroupsTargetUserNotExisting(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(998);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -2792,7 +2792,7 @@ public function testGetUsersGroupsForSubAdminUserAndUserIsAccessible(): void {
public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(998);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -2841,7 +2841,7 @@ public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible(): void {
public function testAddToGroupWithTargetGroupNotExisting(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(102);
$this->groupManager->expects($this->once())
@@ -2854,7 +2854,7 @@ public function testAddToGroupWithTargetGroupNotExisting(): void {
public function testAddToGroupWithNoGroupSpecified(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(101);
$this->api->addToGroup('TargetUser');
@@ -2862,7 +2862,7 @@ public function testAddToGroupWithNoGroupSpecified(): void {
public function testAddToGroupWithTargetUserNotExisting(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(103);
$targetGroup = $this->createMock(IGroup::class);
@@ -2876,7 +2876,7 @@ public function testAddToGroupWithTargetUserNotExisting(): void {
public function testAddToGroupNoSubadmin(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(104);
$targetUser = $this->createMock(IUser::class);
@@ -3010,7 +3010,7 @@ public function testAddToGroupSuccessAsAdmin(): void {
public function testRemoveFromGroupWithNoTargetGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(101);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -3024,7 +3024,7 @@ public function testRemoveFromGroupWithNoTargetGroup(): void {
public function testRemoveFromGroupWithEmptyTargetGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(101);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -3038,7 +3038,7 @@ public function testRemoveFromGroupWithEmptyTargetGroup(): void {
public function testRemoveFromGroupWithNotExistingTargetGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(102);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -3057,7 +3057,7 @@ public function testRemoveFromGroupWithNotExistingTargetGroup(): void {
public function testRemoveFromGroupWithNotExistingTargetUser(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(103);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -3082,7 +3082,7 @@ public function testRemoveFromGroupWithNotExistingTargetUser(): void {
public function testRemoveFromGroupWithoutPermission(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(104);
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -3123,7 +3123,7 @@ public function testRemoveFromGroupWithoutPermission(): void {
public function testRemoveFromGroupAsAdminFromAdmin(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Cannot remove yourself from the admin group');
$this->expectExceptionCode(105);
@@ -3173,7 +3173,7 @@ public function testRemoveFromGroupAsAdminFromAdmin(): void {
public function testRemoveFromGroupAsSubAdminFromSubAdmin(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Cannot remove yourself from this group as you are a sub-admin');
$this->expectExceptionCode(105);
@@ -3228,7 +3228,7 @@ public function testRemoveFromGroupAsSubAdminFromSubAdmin(): void {
public function testRemoveFromGroupAsSubAdminFromLastSubAdminGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Not viable to remove user from the last group you are sub-admin of');
$this->expectExceptionCode(105);
@@ -3331,7 +3331,7 @@ public function testRemoveFromGroupSuccessful(): void {
public function testAddSubAdminWithNotExistingTargetUser(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('User does not exist');
$this->expectExceptionCode(101);
@@ -3346,7 +3346,7 @@ public function testAddSubAdminWithNotExistingTargetUser(): void {
public function testAddSubAdminWithNotExistingTargetGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Group does not exist');
$this->expectExceptionCode(102);
@@ -3368,7 +3368,7 @@ public function testAddSubAdminWithNotExistingTargetGroup(): void {
public function testAddSubAdminToAdminGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Cannot create sub-admins for admin group');
$this->expectExceptionCode(103);
@@ -3454,7 +3454,7 @@ public function testAddSubAdminSuccessful(): void {
public function testRemoveSubAdminNotExistingTargetUser(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('User does not exist');
$this->expectExceptionCode(101);
@@ -3469,7 +3469,7 @@ public function testRemoveSubAdminNotExistingTargetUser(): void {
public function testRemoveSubAdminNotExistingTargetGroup(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Group does not exist');
$this->expectExceptionCode(101);
@@ -3491,7 +3491,7 @@ public function testRemoveSubAdminNotExistingTargetGroup(): void {
public function testRemoveSubAdminFromNotASubadmin(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('User is not a sub-admin of this group');
$this->expectExceptionCode(102);
@@ -3556,7 +3556,7 @@ public function testRemoveSubAdminSuccessful(): void {
public function testGetUserSubAdminGroupsNotExistingTargetUser(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('User does not exist');
$this->expectExceptionCode(404);
@@ -3728,7 +3728,7 @@ public function testGetCurrentUserLoggedIn(): void {
public function testGetCurrentUserNotLoggedIn(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->userSession->expects($this->once())->method('getUser')
@@ -3804,7 +3804,7 @@ public function testGetUser(): void {
public function testResendWelcomeMessageWithNotExistingTargetUser(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(998);
$this->userManager
@@ -3818,7 +3818,7 @@ public function testResendWelcomeMessageWithNotExistingTargetUser(): void {
public function testResendWelcomeMessageAsSubAdminAndUserIsNotAccessible(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionCode(998);
$loggedInUser = $this->getMockBuilder(IUser::class)
@@ -3863,7 +3863,7 @@ public function testResendWelcomeMessageAsSubAdminAndUserIsNotAccessible(): void
public function testResendWelcomeMessageNoEmail(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Email address not available');
$this->expectExceptionCode(101);
@@ -3908,7 +3908,7 @@ public function testResendWelcomeMessageNoEmail(): void {
public function testResendWelcomeMessageNullEmail(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Email address not available');
$this->expectExceptionCode(101);
@@ -4055,7 +4055,7 @@ public function testResendWelcomeMessageSuccessWithFallbackLanguage(): void {
public function testResendWelcomeMessageFailed(): void {
- $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectException(OCSException::class);
$this->expectExceptionMessage('Sending email failed');
$this->expectExceptionCode(102);
diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php
index a971a893393c2..7f8e2db44182d 100644
--- a/apps/settings/lib/Controller/AppSettingsController.php
+++ b/apps/settings/lib/Controller/AppSettingsController.php
@@ -37,11 +37,13 @@
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\IGroup;
use OCP\IL10N;
use OCP\INavigationManager;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
+use OCP\Util;
use Psr\Log\LoggerInterface;
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
@@ -93,8 +95,8 @@ public function viewApps(): TemplateResponse {
$templateResponse = new TemplateResponse('settings', 'settings/empty', ['pageTitle' => $this->l10n->t('Settings')]);
$templateResponse->setContentSecurityPolicy($policy);
- \OCP\Util::addStyle('settings', 'settings');
- \OCP\Util::addScript('settings', 'vue-settings-apps-users-management');
+ Util::addStyle('settings', 'settings');
+ Util::addScript('settings', 'vue-settings-apps-users-management');
return $templateResponse;
}
@@ -512,7 +514,7 @@ private function getGroupList(array $groups) {
$groupsList = [];
foreach ($groups as $group) {
$groupItem = $groupManager->get($group);
- if ($groupItem instanceof \OCP\IGroup) {
+ if ($groupItem instanceof IGroup) {
$groupsList[] = $groupManager->get($group);
}
}
diff --git a/apps/settings/lib/Controller/ChangePasswordController.php b/apps/settings/lib/Controller/ChangePasswordController.php
index 32bbebb210c0e..13a83e175499d 100644
--- a/apps/settings/lib/Controller/ChangePasswordController.php
+++ b/apps/settings/lib/Controller/ChangePasswordController.php
@@ -11,6 +11,8 @@
use OC\Group\Manager as GroupManager;
use OC\User\Session;
+use OCA\Encryption\KeyManager;
+use OCA\Encryption\Recovery;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
@@ -24,6 +26,7 @@
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\Server;
class ChangePasswordController extends Controller {
private ?string $userId;
@@ -146,8 +149,8 @@ public function changeUserPassword(?string $username = null, ?string $password =
if ($this->appManager->isEnabledForUser('encryption')) {
//handle the recovery case
- $keyManager = \OCP\Server::get(\OCA\Encryption\KeyManager::class);
- $recovery = \OCP\Server::get(\OCA\Encryption\Recovery::class);
+ $keyManager = Server::get(KeyManager::class);
+ $recovery = Server::get(Recovery::class);
$recoveryAdminEnabled = $recovery->isRecoveryKeyEnabled();
$validRecoveryPassword = false;
diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php
index 71f256f57d69d..0ff2f86accad6 100644
--- a/apps/settings/lib/Controller/UsersController.php
+++ b/apps/settings/lib/Controller/UsersController.php
@@ -14,6 +14,7 @@
use OC\AppFramework\Http;
use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
use OC\ForbiddenException;
+use OC\Group\MetaData;
use OC\KnownUser\KnownUserService;
use OC\Security\IdentityProof\Manager;
use OC\User\Manager as UserManager;
@@ -46,6 +47,7 @@
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
+use OCP\Util;
use function in_array;
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
@@ -101,17 +103,17 @@ public function usersList(): TemplateResponse {
\OC::$server->getNavigationManager()->setActiveEntry('core_users');
/* SORT OPTION: SORT_USERCOUNT or SORT_GROUPNAME */
- $sortGroupsBy = \OC\Group\MetaData::SORT_USERCOUNT;
+ $sortGroupsBy = MetaData::SORT_USERCOUNT;
$isLDAPUsed = false;
if ($this->config->getSystemValueBool('sort_groups_by_name', false)) {
- $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
+ $sortGroupsBy = MetaData::SORT_GROUPNAME;
} else {
if ($this->appManager->isEnabledForUser('user_ldap')) {
$isLDAPUsed =
$this->groupManager->isBackendUsed('\OCA\User_LDAP\Group_Proxy');
if ($isLDAPUsed) {
// LDAP user count can be slow, so we sort by group name here
- $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
+ $sortGroupsBy = MetaData::SORT_GROUPNAME;
}
}
}
@@ -119,7 +121,7 @@ public function usersList(): TemplateResponse {
$canChangePassword = $this->canAdminChangeUserPasswords();
/* GROUPS */
- $groupsInfo = new \OC\Group\MetaData(
+ $groupsInfo = new MetaData(
$uid,
$isAdmin,
$isDelegatedAdmin,
@@ -198,7 +200,7 @@ public function usersList(): TemplateResponse {
$languages = $this->l10nFactory->getLanguages();
/** Using LDAP or admins (system config) can enfore sorting by group name, in this case the frontend setting is overwritten */
- $forceSortGroupByName = $sortGroupsBy === \OC\Group\MetaData::SORT_GROUPNAME;
+ $forceSortGroupByName = $sortGroupsBy === MetaData::SORT_GROUPNAME;
/* FINAL DATA */
$serverData = [];
@@ -208,8 +210,8 @@ public function usersList(): TemplateResponse {
$serverData['isAdmin'] = $isAdmin;
$serverData['isDelegatedAdmin'] = $isDelegatedAdmin;
$serverData['sortGroups'] = $forceSortGroupByName
- ? \OC\Group\MetaData::SORT_GROUPNAME
- : (int)$this->config->getAppValue('core', 'group.sortBy', (string)\OC\Group\MetaData::SORT_USERCOUNT);
+ ? MetaData::SORT_GROUPNAME
+ : (int)$this->config->getAppValue('core', 'group.sortBy', (string)MetaData::SORT_USERCOUNT);
$serverData['forceSortGroupByName'] = $forceSortGroupByName;
$serverData['quotaPreset'] = $quotaPreset;
$serverData['allowUnlimitedQuota'] = $allowUnlimitedQuota;
@@ -226,8 +228,8 @@ public function usersList(): TemplateResponse {
$this->initialState->provideInitialState('usersSettings', $serverData);
- \OCP\Util::addStyle('settings', 'settings');
- \OCP\Util::addScript('settings', 'vue-settings-apps-users-management');
+ Util::addStyle('settings', 'settings');
+ Util::addScript('settings', 'vue-settings-apps-users-management');
return new TemplateResponse('settings', 'settings/empty', ['pageTitle' => $this->l10n->t('Settings')]);
}
diff --git a/apps/settings/lib/Settings/Admin/Mail.php b/apps/settings/lib/Settings/Admin/Mail.php
index a94e3da18fe89..3614c637f41ae 100644
--- a/apps/settings/lib/Settings/Admin/Mail.php
+++ b/apps/settings/lib/Settings/Admin/Mail.php
@@ -9,6 +9,7 @@
use OCP\IBinaryFinder;
use OCP\IConfig;
use OCP\IL10N;
+use OCP\Server;
use OCP\Settings\IDelegatedSettings;
class Mail implements IDelegatedSettings {
@@ -33,7 +34,7 @@ public function __construct(IConfig $config, IL10N $l) {
public function getForm() {
$parameters = [
// Mail
- 'sendmail_is_available' => (bool)\OCP\Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'),
+ 'sendmail_is_available' => (bool)Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'),
'mail_domain' => $this->config->getSystemValue('mail_domain', ''),
'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''),
'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''),
diff --git a/apps/settings/lib/Settings/Admin/Sharing.php b/apps/settings/lib/Settings/Admin/Sharing.php
index 34c91f3bce97b..c9ad58250c9ac 100644
--- a/apps/settings/lib/Settings/Admin/Sharing.php
+++ b/apps/settings/lib/Settings/Admin/Sharing.php
@@ -77,7 +77,7 @@ public function getForm() {
$this->initialState->provideInitialState('sharingDocumentation', $this->urlGenerator->linkToDocs('admin-sharing'));
$this->initialState->provideInitialState('sharingSettings', $parameters);
- \OCP\Util::addScript($this->appName, 'vue-settings-admin-sharing');
+ Util::addScript($this->appName, 'vue-settings-admin-sharing');
return new TemplateResponse($this->appName, 'settings/admin/sharing', [], '');
}
diff --git a/apps/settings/lib/SetupChecks/MemcacheConfigured.php b/apps/settings/lib/SetupChecks/MemcacheConfigured.php
index 03cdc91cb5f46..d42b0f6729827 100644
--- a/apps/settings/lib/SetupChecks/MemcacheConfigured.php
+++ b/apps/settings/lib/SetupChecks/MemcacheConfigured.php
@@ -8,6 +8,7 @@
*/
namespace OCA\Settings\SetupChecks;
+use OC\Memcache\Memcached;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -35,7 +36,7 @@ public function run(): SetupResult {
$memcacheLockingClass = $this->config->getSystemValue('memcache.locking', null);
$memcacheLocalClass = $this->config->getSystemValue('memcache.local', null);
$caches = array_filter([$memcacheDistributedClass,$memcacheLockingClass,$memcacheLocalClass]);
- if (in_array(\OC\Memcache\Memcached::class, array_map(fn (string $class) => ltrim($class, '\\'), $caches))) {
+ if (in_array(Memcached::class, array_map(fn (string $class) => ltrim($class, '\\'), $caches))) {
// wrong PHP module is installed
if (extension_loaded('memcache') && !extension_loaded('memcached')) {
return SetupResult::warning(
diff --git a/apps/settings/lib/UserMigration/AccountMigrator.php b/apps/settings/lib/UserMigration/AccountMigrator.php
index 81107cd81c599..4306c63560ea7 100644
--- a/apps/settings/lib/UserMigration/AccountMigrator.php
+++ b/apps/settings/lib/UserMigration/AccountMigrator.php
@@ -18,6 +18,7 @@
use OCP\Accounts\IAccountManager;
use OCP\IAvatarManager;
use OCP\IL10N;
+use OCP\Image;
use OCP\IUser;
use OCP\UserMigration\IExportDestination;
use OCP\UserMigration\IImportSource;
@@ -156,7 +157,7 @@ public function import(IUser $user, IImportSource $importSource, OutputInterface
$output->writeln('Importing avatar from ' . $importPath . '…');
$stream = $importSource->getFileAsStream($importPath);
- $image = new \OCP\Image();
+ $image = new Image();
$image->loadFromFileHandle($stream);
try {
diff --git a/apps/settings/tests/Mailer/NewUserMailHelperTest.php b/apps/settings/tests/Mailer/NewUserMailHelperTest.php
index 579ab2cdbb0c9..87ad301dee71a 100644
--- a/apps/settings/tests/Mailer/NewUserMailHelperTest.php
+++ b/apps/settings/tests/Mailer/NewUserMailHelperTest.php
@@ -7,6 +7,7 @@
use OC\Mail\EMailTemplate;
use OC\Mail\Message;
+use OCA\Settings\Mailer\NewUserMailHelper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Defaults;
use OCP\IConfig;
@@ -40,7 +41,7 @@ class NewUserMailHelperTest extends TestCase {
private $config;
/** @var ICrypto|\PHPUnit\Framework\MockObject\MockObject */
private $crypto;
- /** @var \OCA\Settings\Mailer\NewUserMailHelper */
+ /** @var NewUserMailHelper */
private $newUserMailHelper;
protected function setUp(): void {
@@ -89,7 +90,7 @@ protected function setUp(): void {
return $this->l10n;
});
- $this->newUserMailHelper = new \OCA\Settings\Mailer\NewUserMailHelper(
+ $this->newUserMailHelper = new NewUserMailHelper(
$this->defaults,
$this->urlGenerator,
$this->l10nFactory,
diff --git a/apps/settings/tests/Middleware/SubadminMiddlewareTest.php b/apps/settings/tests/Middleware/SubadminMiddlewareTest.php
index c4672a06d4939..dc725e2d377d9 100644
--- a/apps/settings/tests/Middleware/SubadminMiddlewareTest.php
+++ b/apps/settings/tests/Middleware/SubadminMiddlewareTest.php
@@ -45,7 +45,7 @@ protected function setUp(): void {
public function testBeforeControllerAsUserWithExemption(): void {
- $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\NotAdminException::class);
+ $this->expectException(NotAdminException::class);
$this->reflector
->expects($this->exactly(2))
diff --git a/apps/settings/tests/Settings/Admin/MailTest.php b/apps/settings/tests/Settings/Admin/MailTest.php
index 8ea0ea9bb0ced..f5c5b91aad7fe 100644
--- a/apps/settings/tests/Settings/Admin/MailTest.php
+++ b/apps/settings/tests/Settings/Admin/MailTest.php
@@ -10,6 +10,7 @@
use OCP\IBinaryFinder;
use OCP\IConfig;
use OCP\IL10N;
+use OCP\Server;
use Test\TestCase;
class MailTest extends TestCase {
@@ -52,7 +53,7 @@ public function testGetForm(): void {
'settings',
'settings/admin/additional-mail',
[
- 'sendmail_is_available' => (bool)\OCP\Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'),
+ 'sendmail_is_available' => (bool)Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'),
'mail_domain' => 'mx.nextcloud.com',
'mail_from_address' => 'no-reply@nextcloud.com',
'mail_smtpmode' => 'smtp',
diff --git a/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php b/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php
index 0ba1621c5febb..4bf529da6bb81 100644
--- a/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php
+++ b/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php
@@ -12,6 +12,7 @@
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IUrlGenerator;
+use OCP\Server;
use OCP\SetupCheck\SetupResult;
use Test\TestCase;
@@ -30,12 +31,12 @@ protected function setUp(): void {
$this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
$this->urlGenerator = $this->getMockBuilder(IUrlGenerator::class)->getMock();
- $this->connection = \OCP\Server::get(IDBConnection::class);
+ $this->connection = Server::get(IDBConnection::class);
$this->check = new SupportedDatabase(
$this->l10n,
$this->urlGenerator,
- \OCP\Server::get(IDBConnection::class)
+ Server::get(IDBConnection::class)
);
}
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php
index fd43e7c089e9a..64dacbcbdc7a5 100644
--- a/apps/sharebymail/lib/ShareByMailProvider.php
+++ b/apps/sharebymail/lib/ShareByMailProvider.php
@@ -35,6 +35,7 @@
use OCP\Share\IManager as IShareManager;
use OCP\Share\IShare;
use OCP\Share\IShareProviderWithNotification;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
@@ -382,7 +383,7 @@ protected function sendEmail(IShare $share, array $emails): void {
]
);
}
- $message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]);
+ $message->setFrom([Util::getDefaultEmailAddress($instanceName) => $senderName]);
// The "Reply-To" is set to the sharer if an mail address is configured
// also the default footer contains a "Do not reply" which needs to be adjusted.
@@ -478,7 +479,7 @@ protected function sendPassword(IShare $share, string $password, array $emails):
]
);
}
- $message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]);
+ $message->setFrom([Util::getDefaultEmailAddress($instanceName) => $senderName]);
// The "Reply-To" is set to the sharer if an mail address is configured
// also the default footer contains a "Do not reply" which needs to be adjusted.
@@ -548,7 +549,7 @@ protected function sendNote(IShare $share): void {
]
);
}
- $message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]);
+ $message->setFrom([Util::getDefaultEmailAddress($instanceName) => $senderName]);
if ($this->settingsManager->replyToInitiator() && $initiatorEmailAddress !== null) {
$message->setReplyTo([$initiatorEmailAddress => $initiatorDisplayName]);
$emailTemplate->addFooter($instanceName . ' - ' . $this->defaults->getSlogan());
@@ -617,7 +618,7 @@ protected function sendPasswordToOwner(IShare $share, string $password): bool {
$instanceName
]
);
- $message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]);
+ $message->setFrom([Util::getDefaultEmailAddress($instanceName) => $senderName]);
$message->setTo([$initiatorEMailAddress => $initiatorDisplayName]);
$message->useTemplate($emailTemplate);
$this->mailer->send($message);
@@ -1200,7 +1201,7 @@ public function getAllShares(): iterable {
->from('share')
->where(
$qb->expr()->orX(
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share\IShare::TYPE_EMAIL))
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))
)
);
diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php
index c01f5b476325d..639df8283a4f5 100644
--- a/apps/sharebymail/tests/ShareByMailProviderTest.php
+++ b/apps/sharebymail/tests/ShareByMailProviderTest.php
@@ -7,9 +7,11 @@
use DateTime;
use OC\Mail\Message;
+use OC\Share20\Share;
use OCA\ShareByMail\Settings\SettingsManager;
use OCA\ShareByMail\ShareByMailProvider;
use OCP\Activity\IManager as IActivityManager;
+use OCP\Constants;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\File;
@@ -28,9 +30,12 @@
use OCP\Security\IHasher;
use OCP\Security\ISecureRandom;
use OCP\Security\PasswordContext;
+use OCP\Server;
+use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IAttributes;
use OCP\Share\IManager;
use OCP\Share\IShare;
+use OCP\Util;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@@ -64,7 +69,7 @@ class ShareByMailProviderTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->connection = \OCP\Server::get(IDBConnection::class);
+ $this->connection = Server::get(IDBConnection::class);
$this->l = $this->getMockBuilder(IL10N::class)->getMock();
$this->l->method('t')
@@ -883,7 +888,7 @@ function ($data) use ($uidOwner, $sharedBy, $id2) {
public function testGetShareByIdFailed(): void {
- $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+ $this->expectException(ShareNotFound::class);
$instance = $this->getInstance(['createShareObject']);
@@ -966,7 +971,7 @@ function ($data) use ($idMail) {
public function testGetShareByTokenFailed(): void {
- $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+ $this->expectException(ShareNotFound::class);
$itemSource = 11;
@@ -1093,7 +1098,7 @@ public function testGetRawShare(): void {
public function testGetRawShareFailed(): void {
- $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+ $this->expectException(ShareNotFound::class);
$itemSource = 11;
$itemType = 'file';
@@ -1143,7 +1148,7 @@ public function testGetSharesInFolder(): void {
$this->shareManager->expects($this->any())
->method('newShare')
- ->willReturn(new \OC\Share20\Share($rootFolder, $userManager));
+ ->willReturn(new Share($rootFolder, $userManager));
$provider = $this->getInstance(['sendMailNotification', 'createShareActivity']);
$this->mailer->expects($this->any())->method('validateMailAddress')->willReturn(true);
@@ -1159,7 +1164,7 @@ public function testGetSharesInFolder(): void {
$share1->setSharedWith('user@server.com')
->setSharedBy($u1->getUID())
->setShareOwner($u1->getUID())
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file1);
$provider->create($share1);
@@ -1167,7 +1172,7 @@ public function testGetSharesInFolder(): void {
$share2->setSharedWith('user@server.com')
->setSharedBy($u2->getUID())
->setShareOwner($u1->getUID())
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($file2);
$provider->create($share2);
@@ -1190,7 +1195,7 @@ public function testGetAccessList(): void {
$this->shareManager->expects($this->any())
->method('newShare')
- ->willReturn(new \OC\Share20\Share($rootFolder, $userManager));
+ ->willReturn(new Share($rootFolder, $userManager));
$provider = $this->getInstance(['sendMailNotification', 'createShareActivity']);
$this->mailer->expects($this->any())->method('validateMailAddress')->willReturn(true);
@@ -1211,7 +1216,7 @@ public function testGetAccessList(): void {
$share1->setSharedWith('user@server.com')
->setSharedBy($u1->getUID())
->setShareOwner($u1->getUID())
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder);
$share1 = $provider->create($share1);
@@ -1219,7 +1224,7 @@ public function testGetAccessList(): void {
$share2->setSharedWith('user2@server.com')
->setSharedBy($u2->getUID())
->setShareOwner($u1->getUID())
- ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setPermissions(Constants::PERMISSION_READ)
->setNode($folder);
$share2 = $provider->create($share2);
@@ -1308,7 +1313,7 @@ public function testSendMailNotificationWithSameUserAndUserEmail(): void {
->expects($this->once())
->method('setFrom')
->with([
- \OCP\Util::getDefaultEmailAddress('UnitTestCloud') => 'Mrs. Owner User via UnitTestCloud'
+ Util::getDefaultEmailAddress('UnitTestCloud') => 'Mrs. Owner User via UnitTestCloud'
]);
$user
->expects($this->once())
@@ -1434,7 +1439,7 @@ public function testSendMailNotificationWithSameUserAndUserEmailAndNote(): void
->expects($this->once())
->method('setFrom')
->with([
- \OCP\Util::getDefaultEmailAddress('UnitTestCloud') => 'Mrs. Owner User via UnitTestCloud'
+ Util::getDefaultEmailAddress('UnitTestCloud') => 'Mrs. Owner User via UnitTestCloud'
]);
$user
->expects($this->once())
@@ -1565,7 +1570,7 @@ public function testSendMailNotificationWithSameUserAndUserEmailAndExpiration():
->expects($this->once())
->method('setFrom')
->with([
- \OCP\Util::getDefaultEmailAddress('UnitTestCloud') => 'Mrs. Owner User via UnitTestCloud'
+ Util::getDefaultEmailAddress('UnitTestCloud') => 'Mrs. Owner User via UnitTestCloud'
]);
$user
->expects($this->once())
@@ -1679,7 +1684,7 @@ public function testSendMailNotificationWithDifferentUserAndNoUserEmail(): void
->expects($this->once())
->method('setFrom')
->with([
- \OCP\Util::getDefaultEmailAddress('UnitTestCloud') => 'Mr. Initiator User via UnitTestCloud'
+ Util::getDefaultEmailAddress('UnitTestCloud') => 'Mr. Initiator User via UnitTestCloud'
]);
$message
->expects($this->never())
@@ -1783,7 +1788,7 @@ public function testSendMailNotificationWithSameUserAndUserEmailAndReplyToDesact
->expects($this->once())
->method('setFrom')
->with([
- \OCP\Util::getDefaultEmailAddress('UnitTestCloud') => 'UnitTestCloud'
+ Util::getDefaultEmailAddress('UnitTestCloud') => 'UnitTestCloud'
]);
// Since replyToInitiator is false, we never get the initiator email address
$user
@@ -1891,7 +1896,7 @@ public function testSendMailNotificationWithDifferentUserAndNoUserEmailAndReplyT
->expects($this->once())
->method('setFrom')
->with([
- \OCP\Util::getDefaultEmailAddress('UnitTestCloud') => 'UnitTestCloud'
+ Util::getDefaultEmailAddress('UnitTestCloud') => 'UnitTestCloud'
]);
$message
->expects($this->never())
diff --git a/apps/systemtags/lib/AppInfo/Application.php b/apps/systemtags/lib/AppInfo/Application.php
index 2fbdf7853e7b3..dee21ffb9cc49 100644
--- a/apps/systemtags/lib/AppInfo/Application.php
+++ b/apps/systemtags/lib/AppInfo/Application.php
@@ -19,6 +19,7 @@
use OCP\EventDispatcher\IEventDispatcher;
use OCP\SystemTag\ManagerEvent;
use OCP\SystemTag\MapperEvent;
+use OCP\Util;
class Application extends App implements IBootstrap {
public const APP_ID = 'systemtags';
@@ -40,13 +41,13 @@ public function boot(IBootContext $context): void {
$dispatcher->addListener(
LoadAdditionalScriptsEvent::class,
function (): void {
- \OCP\Util::addScript('core', 'systemtags');
- \OCP\Util::addInitScript(self::APP_ID, 'init');
+ Util::addScript('core', 'systemtags');
+ Util::addInitScript(self::APP_ID, 'init');
}
);
$managerListener = function (ManagerEvent $event) use ($context): void {
- /** @var \OCA\SystemTags\Activity\Listener $listener */
+ /** @var Listener $listener */
$listener = $context->getServerContainer()->query(Listener::class);
$listener->event($event);
};
@@ -55,7 +56,7 @@ function (): void {
$dispatcher->addListener(ManagerEvent::EVENT_UPDATE, $managerListener);
$mapperListener = function (MapperEvent $event) use ($context): void {
- /** @var \OCA\SystemTags\Activity\Listener $listener */
+ /** @var Listener $listener */
$listener = $context->getServerContainer()->query(Listener::class);
$listener->mapperEvent($event);
};
diff --git a/apps/systemtags/lib/Settings/Admin.php b/apps/systemtags/lib/Settings/Admin.php
index 544138316dfc6..b032e6b769458 100644
--- a/apps/systemtags/lib/Settings/Admin.php
+++ b/apps/systemtags/lib/Settings/Admin.php
@@ -7,6 +7,7 @@
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Settings\ISettings;
+use OCP\Util;
class Admin implements ISettings {
@@ -14,7 +15,7 @@ class Admin implements ISettings {
* @return TemplateResponse
*/
public function getForm() {
- \OCP\Util::addScript('systemtags', 'admin');
+ Util::addScript('systemtags', 'admin');
return new TemplateResponse('systemtags', 'admin', [], '');
}
diff --git a/apps/testing/lib/AlternativeHomeUserBackend.php b/apps/testing/lib/AlternativeHomeUserBackend.php
index 38ceb40420896..730b11bcf74b7 100644
--- a/apps/testing/lib/AlternativeHomeUserBackend.php
+++ b/apps/testing/lib/AlternativeHomeUserBackend.php
@@ -5,6 +5,8 @@
*/
namespace OCA\Testing;
+use OC\User\Database;
+
/**
* Alternative home user backend.
*
@@ -17,7 +19,7 @@
* ],
* ]
*/
-class AlternativeHomeUserBackend extends \OC\User\Database {
+class AlternativeHomeUserBackend extends Database {
public function __construct() {
parent::__construct();
}
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php
index cda149cd48fa3..1b02595fa39a6 100644
--- a/apps/theming/lib/Controller/ThemingController.php
+++ b/apps/theming/lib/Controller/ThemingController.php
@@ -17,6 +17,7 @@
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
+use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
@@ -346,7 +347,7 @@ public function getImage(string $key, bool $useSvg = true) {
}
$response = new FileDisplayResponse($file);
- $csp = new Http\ContentSecurityPolicy();
+ $csp = new ContentSecurityPolicy();
$csp->allowInlineStyle();
$response->setContentSecurityPolicy($csp);
$response->cacheFor(3600);
diff --git a/apps/theming/lib/Controller/UserThemeController.php b/apps/theming/lib/Controller/UserThemeController.php
index bef0f38f598c0..f75c46de85cbb 100644
--- a/apps/theming/lib/Controller/UserThemeController.php
+++ b/apps/theming/lib/Controller/UserThemeController.php
@@ -21,6 +21,7 @@
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\NotFoundResponse;
+use OCP\AppFramework\Http\Response;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCSController;
@@ -136,7 +137,7 @@ private function validateTheme(string $themeId): ITheme {
*/
#[NoAdminRequired]
#[NoCSRFRequired]
- public function getBackground(): Http\Response {
+ public function getBackground(): Response {
$file = $this->backgroundService->getBackground();
if ($file !== null) {
$response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $file->getMimeType()]);
diff --git a/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php b/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php
index 2ad495b02397d..3aae941745853 100644
--- a/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php
+++ b/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php
@@ -19,6 +19,7 @@
use OCP\EventDispatcher\IEventListener;
use OCP\IConfig;
use OCP\IUserSession;
+use OCP\Util;
use Psr\Container\ContainerInterface;
/** @template-implements IEventListener */
@@ -64,6 +65,6 @@ public function handle(Event $event): void {
$this->themeInjectionService->injectHeaders();
// Making sure to inject just after core
- \OCP\Util::addScript('theming', 'theming', 'core');
+ Util::addScript('theming', 'theming', 'core');
}
}
diff --git a/apps/theming/lib/Migration/InitBackgroundImagesMigration.php b/apps/theming/lib/Migration/InitBackgroundImagesMigration.php
index a070ebb3d5649..0f0a019a49059 100644
--- a/apps/theming/lib/Migration/InitBackgroundImagesMigration.php
+++ b/apps/theming/lib/Migration/InitBackgroundImagesMigration.php
@@ -12,8 +12,9 @@
use OCA\Theming\Jobs\MigrateBackgroundImages;
use OCP\BackgroundJob\IJobList;
use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
-class InitBackgroundImagesMigration implements \OCP\Migration\IRepairStep {
+class InitBackgroundImagesMigration implements IRepairStep {
private IJobList $jobList;
diff --git a/apps/theming/lib/Migration/Version2006Date20240905111627.php b/apps/theming/lib/Migration/Version2006Date20240905111627.php
index dcec954f585a0..92b3c0e4cfadf 100644
--- a/apps/theming/lib/Migration/Version2006Date20240905111627.php
+++ b/apps/theming/lib/Migration/Version2006Date20240905111627.php
@@ -15,11 +15,12 @@
use OCP\BackgroundJob\IJobList;
use OCP\IAppConfig;
use OCP\IDBConnection;
+use OCP\Migration\IMigrationStep;
use OCP\Migration\IOutput;
// This can only be executed once because `background_color` is again used with Nextcloud 30,
// so this part only works when updating -> Nextcloud 29 -> 30
-class Version2006Date20240905111627 implements \OCP\Migration\IMigrationStep {
+class Version2006Date20240905111627 implements IMigrationStep {
public function __construct(
private IJobList $jobList,
diff --git a/apps/theming/lib/Service/BackgroundService.php b/apps/theming/lib/Service/BackgroundService.php
index bf6508744487c..cde18a3a8783b 100644
--- a/apps/theming/lib/Service/BackgroundService.php
+++ b/apps/theming/lib/Service/BackgroundService.php
@@ -19,6 +19,7 @@
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
+use OCP\Image;
use OCP\Lock\LockedException;
use OCP\PreConditionNotMetException;
use RuntimeException;
@@ -247,7 +248,7 @@ public function recalculateMeanColor(?string $userId = null): void {
throw new RuntimeException('No currently logged-in user');
}
- $image = new \OCP\Image();
+ $image = new Image();
$handle = $this->getAppDataFolder($userId)->getFile('background.jpg')->read();
if ($handle === false || $image->loadFromFileHandle($handle) === false) {
throw new InvalidArgumentException('Invalid image file');
@@ -322,7 +323,7 @@ public function getBackground(): ?ISimpleFile {
* @return string|null The fallback background color - if any
*/
public function setGlobalBackground($path): ?string {
- $image = new \OCP\Image();
+ $image = new Image();
$handle = is_resource($path) ? $path : fopen($path, 'rb');
if ($handle && $image->loadFromFileHandle($handle) !== false) {
@@ -339,7 +340,7 @@ public function setGlobalBackground($path): ?string {
* Calculate mean color of an given image
* It only takes the upper part into account so that a matching text color can be derived for the app menu
*/
- private function calculateMeanColor(\OCP\Image $image): false|string {
+ private function calculateMeanColor(Image $image): false|string {
/**
* Small helper to ensure one channel is returned as 8byte hex
*/
@@ -353,7 +354,7 @@ function toHex(int $channel): string {
};
}
- $tempImage = new \OCP\Image();
+ $tempImage = new Image();
// Crop to only analyze top bar
$resource = $image->cropNew(0, 0, $image->width(), min(max(50, (int)($image->height() * 0.125)), $image->height()));
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index 100b0722bddac..eead85d1ca314 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -12,7 +12,11 @@
use OCA\Theming\ThemingDefaults;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http\FileDisplayResponse;
+use OCP\AppFramework\Http\JSONResponse;
+use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\NotFoundException;
@@ -638,7 +642,7 @@ public function testGetLogoNotExistent(): void {
->with($this->equalTo('logo'))
->willThrowException(new NotFoundException());
- $expected = new Http\NotFoundResponse();
+ $expected = new NotFoundResponse();
$this->assertEquals($expected, $this->themingController->getImage('logo'));
}
@@ -655,11 +659,11 @@ public function testGetLogo(): void {
->with('theming', 'logoMime', '')
->willReturn('text/svg');
- @$expected = new Http\FileDisplayResponse($file);
+ @$expected = new FileDisplayResponse($file);
$expected->cacheFor(3600);
$expected->addHeader('Content-Type', 'text/svg');
$expected->addHeader('Content-Disposition', 'attachment; filename="logo"');
- $csp = new Http\ContentSecurityPolicy();
+ $csp = new ContentSecurityPolicy();
$csp->allowInlineStyle();
$expected->setContentSecurityPolicy($csp);
@$this->assertEquals($expected, $this->themingController->getImage('logo'));
@@ -670,7 +674,7 @@ public function testGetLoginBackgroundNotExistent(): void {
$this->imageManager->method('getImage')
->with($this->equalTo('background'))
->willThrowException(new NotFoundException());
- $expected = new Http\NotFoundResponse();
+ $expected = new NotFoundResponse();
$this->assertEquals($expected, $this->themingController->getImage('background'));
}
@@ -688,11 +692,11 @@ public function testGetLoginBackground(): void {
->with('theming', 'backgroundMime', '')
->willReturn('image/png');
- @$expected = new Http\FileDisplayResponse($file);
+ @$expected = new FileDisplayResponse($file);
$expected->cacheFor(3600);
$expected->addHeader('Content-Type', 'image/png');
$expected->addHeader('Content-Disposition', 'attachment; filename="background"');
- $csp = new Http\ContentSecurityPolicy();
+ $csp = new ContentSecurityPolicy();
$csp->allowInlineStyle();
$expected->setContentSecurityPolicy($csp);
@$this->assertEquals($expected, $this->themingController->getImage('background'));
@@ -719,7 +723,7 @@ public function testGetManifest(): void {
['theming.Icon.getTouchIcon', ['app' => 'core'], 'touchicon'],
['theming.Icon.getFavicon', ['app' => 'core'], 'favicon'],
]);
- $response = new Http\JSONResponse([
+ $response = new JSONResponse([
'name' => 'Nextcloud',
'start_url' => 'localhost',
'icons' =>
diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php
index a3fba874289ea..68c8a06ee2ffd 100644
--- a/apps/theming/tests/ImageManagerTest.php
+++ b/apps/theming/tests/ImageManagerTest.php
@@ -168,7 +168,7 @@ public function testGetImage(): void {
public function testGetImageUnset(): void {
- $this->expectException(\OCP\Files\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$this->config->expects($this->once())
->method('getAppValue')->with('theming', 'logoMime', false)
@@ -223,13 +223,13 @@ public function testGetCachedImage(): void {
public function testGetCachedImageNotFound(): void {
- $this->expectException(\OCP\Files\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$folder = $this->setupCacheFolder();
$folder->expects($this->once())
->method('getFile')
->with('filename')
- ->will($this->throwException(new \OCP\Files\NotFoundException()));
+ ->will($this->throwException(new NotFoundException()));
$image = $this->imageManager->getCachedImage('filename');
}
diff --git a/apps/theming/tests/Themes/DyslexiaFontTest.php b/apps/theming/tests/Themes/DyslexiaFontTest.php
index a022ee4011400..4bd8b329f2dcc 100644
--- a/apps/theming/tests/Themes/DyslexiaFontTest.php
+++ b/apps/theming/tests/Themes/DyslexiaFontTest.php
@@ -6,6 +6,7 @@
namespace OCA\Theming\Tests\Service;
use OC\Route\Router;
+use OC\URLGenerator;
use OCA\Theming\ImageManager;
use OCA\Theming\ITheme;
use OCA\Theming\Themes\DyslexiaFont;
@@ -61,7 +62,7 @@ protected function setUp(): void {
$cacheFactory = $this->createMock(ICacheFactory::class);
$request = $this->createMock(IRequest::class);
$router = $this->createMock(Router::class);
- $this->urlGenerator = new \OC\URLGenerator(
+ $this->urlGenerator = new URLGenerator(
$this->config,
$userSession,
$cacheFactory,
diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php
index 9a05c77a27485..f664a46733daa 100644
--- a/apps/theming/tests/UtilTest.php
+++ b/apps/theming/tests/UtilTest.php
@@ -13,6 +13,7 @@
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
+use OCP\Server;
use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -29,7 +30,7 @@ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->appData = $this->createMock(IAppData::class);
- $this->appManager = \OCP\Server::get(IAppManager::class);
+ $this->appManager = Server::get(IAppManager::class);
$this->imageManager = $this->createMock(ImageManager::class);
$this->util = new Util($this->createMock(ServerVersion::class), $this->config, $this->appManager, $this->appData, $this->imageManager);
}
@@ -154,9 +155,9 @@ public function testGetAppIcon($app, $expected): void {
public function dataGetAppIcon() {
return [
- ['user_ldap', \OCP\Server::get(IAppManager::class)->getAppPath('user_ldap') . '/img/app.svg'],
+ ['user_ldap', Server::get(IAppManager::class)->getAppPath('user_ldap') . '/img/app.svg'],
['noapplikethis', \OC::$SERVERROOT . '/core/img/logo/logo.svg'],
- ['comments', \OCP\Server::get(IAppManager::class)->getAppPath('comments') . '/img/comments.svg'],
+ ['comments', Server::get(IAppManager::class)->getAppPath('comments') . '/img/comments.svg'],
];
}
diff --git a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
index f184cb1c75c7d..083efa9d273ef 100644
--- a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
+++ b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
@@ -9,6 +9,7 @@
namespace OCA\TwoFactorBackupCodes\Tests\Service;
use OCA\TwoFactorBackupCodes\Service\BackupCodeStorage;
+use OCP\IUser;
use OCP\Notification\IManager;
use OCP\Notification\INotification;
use Test\TestCase;
@@ -39,7 +40,7 @@ protected function setUp(): void {
}
public function testSimpleWorkFlow(): void {
- $user = $this->getMockBuilder(\OCP\IUser::class)->getMock();
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$user->expects($this->any())
->method('getUID')
->willReturn($this->testUID);
diff --git a/apps/updatenotification/lib/Controller/ChangelogController.php b/apps/updatenotification/lib/Controller/ChangelogController.php
index 709cd7ef9e5e8..a274ed3d2b275 100644
--- a/apps/updatenotification/lib/Controller/ChangelogController.php
+++ b/apps/updatenotification/lib/Controller/ChangelogController.php
@@ -17,6 +17,7 @@
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\IRequest;
+use OCP\Util;
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
class ChangelogController extends Controller {
@@ -55,7 +56,7 @@ public function showChangelog(string $app, ?string $version = null): TemplateRes
'text' => $changes,
]);
- \OCP\Util::addScript($this->appName, 'view-changelog-page');
+ Util::addScript($this->appName, 'view-changelog-page');
return new TemplateResponse($this->appName, 'empty');
}
}
diff --git a/apps/updatenotification/lib/Listener/BeforeTemplateRenderedEventListener.php b/apps/updatenotification/lib/Listener/BeforeTemplateRenderedEventListener.php
index 0e221fb9bcf74..974734a76f499 100644
--- a/apps/updatenotification/lib/Listener/BeforeTemplateRenderedEventListener.php
+++ b/apps/updatenotification/lib/Listener/BeforeTemplateRenderedEventListener.php
@@ -14,6 +14,7 @@
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IAppConfig;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/** @template-implements IEventListener */
@@ -48,6 +49,6 @@ public function handle(Event $event): void {
return;
}
- \OCP\Util::addInitScript(Application::APP_NAME, 'init');
+ Util::addInitScript(Application::APP_NAME, 'init');
}
}
diff --git a/apps/updatenotification/lib/Migration/Version011901Date20240305120000.php b/apps/updatenotification/lib/Migration/Version011901Date20240305120000.php
index f731df5399ed4..6c608df313d26 100644
--- a/apps/updatenotification/lib/Migration/Version011901Date20240305120000.php
+++ b/apps/updatenotification/lib/Migration/Version011901Date20240305120000.php
@@ -10,6 +10,8 @@
namespace OCA\UpdateNotification\Migration;
use OCA\UpdateNotification\BackgroundJob\ResetToken;
+use OCA\UpdateNotification\Notification\BackgroundJob;
+use OCA\UpdateNotification\ResetTokenBackgroundJob;
use OCP\BackgroundJob\IJobList;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
@@ -30,13 +32,13 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array
* This class was renamed so it is now unknow but we still need to remove it
* @psalm-suppress UndefinedClass, InvalidArgument
*/
- $hasOldResetToken = $this->joblist->has(\OCA\UpdateNotification\ResetTokenBackgroundJob::class, null);
+ $hasOldResetToken = $this->joblist->has(ResetTokenBackgroundJob::class, null);
$hasNewResetToken = $this->joblist->has(ResetToken::class, null);
if ($hasOldResetToken) {
/**
* @psalm-suppress UndefinedClass, InvalidArgument
*/
- $this->joblist->remove(\OCA\UpdateNotification\ResetTokenBackgroundJob::class);
+ $this->joblist->remove(ResetTokenBackgroundJob::class);
if (!$hasNewResetToken) {
$this->joblist->add(ResetToken::class);
}
@@ -46,11 +48,11 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array
* Remove the "has updates" background job, the new one is automatically started from the info.xml
* @psalm-suppress UndefinedClass, InvalidArgument
*/
- if ($this->joblist->has(\OCA\UpdateNotification\Notification\BackgroundJob::class, null)) {
+ if ($this->joblist->has(BackgroundJob::class, null)) {
/**
* @psalm-suppress UndefinedClass, InvalidArgument
*/
- $this->joblist->remove(\OCA\UpdateNotification\Notification\BackgroundJob::class);
+ $this->joblist->remove(BackgroundJob::class);
}
}
}
diff --git a/apps/updatenotification/lib/Notification/Notifier.php b/apps/updatenotification/lib/Notification/Notifier.php
index ce7d2a6a62bd7..7b270547bbb82 100644
--- a/apps/updatenotification/lib/Notification/Notifier.php
+++ b/apps/updatenotification/lib/Notification/Notifier.php
@@ -20,6 +20,7 @@
use OCP\Notification\INotification;
use OCP\Notification\INotifier;
use OCP\Notification\UnknownNotificationException;
+use OCP\Server;
use OCP\Util;
class Notifier implements INotifier {
@@ -188,6 +189,6 @@ protected function getAppVersions(): array {
}
protected function getAppInfo($appId, $languageCode) {
- return \OCP\Server::get(IAppManager::class)->getAppInfo($appId, false, $languageCode);
+ return Server::get(IAppManager::class)->getAppInfo($appId, false, $languageCode);
}
}
diff --git a/apps/user_ldap/ajax/clearMappings.php b/apps/user_ldap/ajax/clearMappings.php
index bd866769cc844..7df622f5e377d 100644
--- a/apps/user_ldap/ajax/clearMappings.php
+++ b/apps/user_ldap/ajax/clearMappings.php
@@ -5,13 +5,13 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
-
use OCA\User_LDAP\Mapping\GroupMapping;
use OCA\User_LDAP\Mapping\UserMapping;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Server;
use OCP\User\Events\BeforeUserIdUnassignedEvent;
use OCP\User\Events\UserIdUnassignedEvent;
+use OCP\Util;
// Check user and app status
\OC_JSON::checkAdminUser();
@@ -41,7 +41,7 @@ function (string $uid) use ($dispatcher): void {
}
if ($mapping === null || !$result) {
- $l = \OCP\Util::getL10N('user_ldap');
+ $l = Util::getL10N('user_ldap');
throw new \Exception($l->t('Failed to clear the mappings.'));
}
\OC_JSON::success();
diff --git a/apps/user_ldap/ajax/deleteConfiguration.php b/apps/user_ldap/ajax/deleteConfiguration.php
index b8e9a09dc1c37..09899a7c6c642 100644
--- a/apps/user_ldap/ajax/deleteConfiguration.php
+++ b/apps/user_ldap/ajax/deleteConfiguration.php
@@ -1,5 +1,8 @@
getConfig(), \OC::$server->getDatabaseConnection());
+$helper = new Helper(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection());
if ($helper->deleteServerConfiguration($prefix)) {
\OC_JSON::success();
} else {
- $l = \OCP\Util::getL10N('user_ldap');
+ $l = Util::getL10N('user_ldap');
\OC_JSON::error(['message' => $l->t('Failed to delete the server configuration')]);
}
diff --git a/apps/user_ldap/ajax/getConfiguration.php b/apps/user_ldap/ajax/getConfiguration.php
index 31372e89c20de..bab9e066509d6 100644
--- a/apps/user_ldap/ajax/getConfiguration.php
+++ b/apps/user_ldap/ajax/getConfiguration.php
@@ -1,5 +1,8 @@
getConfiguration();
if (isset($configuration['ldap_agent_password']) && $configuration['ldap_agent_password'] !== '') {
// hide password
diff --git a/apps/user_ldap/ajax/getNewServerConfigPrefix.php b/apps/user_ldap/ajax/getNewServerConfigPrefix.php
index ccd96250d524f..9ee225ddaa02e 100644
--- a/apps/user_ldap/ajax/getNewServerConfigPrefix.php
+++ b/apps/user_ldap/ajax/getNewServerConfigPrefix.php
@@ -1,5 +1,8 @@
getConfig(), \OC::$server->getDatabaseConnection());
+$helper = new Helper(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection());
$serverConnections = $helper->getServerConfigurationPrefixes();
sort($serverConnections);
$lk = array_pop($serverConnections);
@@ -19,12 +22,12 @@
$resultData = ['configPrefix' => $nk];
-$newConfig = new \OCA\User_LDAP\Configuration($nk, false);
+$newConfig = new Configuration($nk, false);
if (isset($_POST['copyConfig'])) {
- $originalConfig = new \OCA\User_LDAP\Configuration($_POST['copyConfig']);
+ $originalConfig = new Configuration($_POST['copyConfig']);
$newConfig->setConfiguration($originalConfig->getConfiguration());
} else {
- $configuration = new \OCA\User_LDAP\Configuration($nk, false);
+ $configuration = new Configuration($nk, false);
$newConfig->setConfiguration($configuration->getDefaults());
$resultData['defaults'] = $configuration->getDefaults();
}
diff --git a/apps/user_ldap/ajax/setConfiguration.php b/apps/user_ldap/ajax/setConfiguration.php
index afa3b551899ed..5b873a808bbfc 100644
--- a/apps/user_ldap/ajax/setConfiguration.php
+++ b/apps/user_ldap/ajax/setConfiguration.php
@@ -1,5 +1,8 @@
setConfiguration($_POST);
$connection->saveConfiguration();
\OC_JSON::success();
diff --git a/apps/user_ldap/ajax/testConfiguration.php b/apps/user_ldap/ajax/testConfiguration.php
index 93e4813d8b0e5..4f1c92cb33f18 100644
--- a/apps/user_ldap/ajax/testConfiguration.php
+++ b/apps/user_ldap/ajax/testConfiguration.php
@@ -1,5 +1,9 @@
$l->t('No action specified')]);
@@ -22,18 +29,18 @@
}
$prefix = (string)$_POST['ldap_serverconfig_chooser'];
-$ldapWrapper = new \OCA\User_LDAP\LDAP();
-$configuration = new \OCA\User_LDAP\Configuration($prefix);
+$ldapWrapper = new LDAP();
+$configuration = new Configuration($prefix);
-$con = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix, null);
+$con = new Connection($ldapWrapper, $prefix, null);
$con->setConfiguration($configuration->getConfiguration());
$con->ldapConfigurationActive = (string)true;
$con->setIgnoreValidation(true);
-$factory = \OC::$server->get(\OCA\User_LDAP\AccessFactory::class);
+$factory = \OC::$server->get(AccessFactory::class);
$access = $factory->get($con);
-$wizard = new \OCA\User_LDAP\Wizard($configuration, $ldapWrapper, $access);
+$wizard = new Wizard($configuration, $ldapWrapper, $access);
switch ($action) {
case 'guessPortAndTLS':
@@ -104,7 +111,7 @@
}
$configuration->saveConfiguration();
//clear the cache on save
- $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix);
+ $connection = new Connection($ldapWrapper, $prefix);
$connection->clearCache();
\OC_JSON::success();
break;
diff --git a/apps/user_ldap/appinfo/routes.php b/apps/user_ldap/appinfo/routes.php
index fae78b8982e30..fb49c6f54d5f7 100644
--- a/apps/user_ldap/appinfo/routes.php
+++ b/apps/user_ldap/appinfo/routes.php
@@ -2,6 +2,9 @@
declare(strict_types=1);
+use OCA\User_LDAP\AppInfo\Application;
+use OCP\AppFramework\App;
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -22,7 +25,7 @@
$this->create('user_ldap_ajax_wizard', 'apps/user_ldap/ajax/wizard.php')
->actionInclude('user_ldap/ajax/wizard.php');
-$application = new \OCP\AppFramework\App('user_ldap');
+$application = new App('user_ldap');
$application->registerRoutes($this, [
'ocs' => [
['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'],
@@ -32,8 +35,8 @@
]
]);
-/** @var \OCA\User_LDAP\AppInfo\Application $application */
-$application = \OC::$server->query(\OCA\User_LDAP\AppInfo\Application::class);
+/** @var Application $application */
+$application = \OC::$server->query(Application::class);
$application->registerRoutes($this, [
'routes' => [
['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'],
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index f1e47e90418cb..2dfefc04f8080 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -21,6 +21,7 @@
use OCP\IConfig;
use OCP\IUserManager;
use OCP\User\Events\UserIdAssignedEvent;
+use OCP\Util;
use Psr\Log\LoggerInterface;
use function strlen;
use function substr;
@@ -108,7 +109,7 @@ private function checkConnection() {
/**
* returns the Connection instance
*
- * @return \OCA\User_LDAP\Connection
+ * @return Connection
*/
public function getConnection() {
return $this->connection;
@@ -260,7 +261,7 @@ public function executeRead(string $dn, string|array $attribute, string $filter)
return false;
}
//LDAP attributes are not case sensitive
- $result = \OCP\Util::mb_array_change_key_case(
+ $result = Util::mb_array_change_key_case(
$this->invokeLDAPMethod('getAttributes', $er), MB_CASE_LOWER, 'UTF-8');
return $result;
@@ -341,7 +342,7 @@ public function setPassword($userDN, $password) {
return @$this->invokeLDAPMethod('exopPasswd', $userDN, '', $password) ||
@$this->invokeLDAPMethod('modReplace', $userDN, $password);
} catch (ConstraintViolationException $e) {
- throw new HintException('Password change rejected.', \OCP\Util::getL10N('user_ldap')->t('Password change rejected. Hint: ') . $e->getMessage(), (int)$e->getCode());
+ throw new HintException('Password change rejected.', Util::getL10N('user_ldap')->t('Password change rejected. Hint: ') . $e->getMessage(), (int)$e->getCode());
}
}
@@ -1329,7 +1330,7 @@ public function search(
if (!is_array($item)) {
continue;
}
- $item = \OCP\Util::mb_array_change_key_case($item, MB_CASE_LOWER, 'UTF-8');
+ $item = Util::mb_array_change_key_case($item, MB_CASE_LOWER, 'UTF-8');
foreach ($attr as $key) {
if (isset($item[$key])) {
if (is_array($item[$key]) && isset($item[$key]['count'])) {
diff --git a/apps/user_ldap/lib/AppInfo/Application.php b/apps/user_ldap/lib/AppInfo/Application.php
index ae6092ae10183..3c1cb5daa123b 100644
--- a/apps/user_ldap/lib/AppInfo/Application.php
+++ b/apps/user_ldap/lib/AppInfo/Application.php
@@ -40,6 +40,7 @@
use OCP\Notification\IManager as INotificationManager;
use OCP\Share\IManager as IShareManager;
use OCP\User\Events\PostLoginEvent;
+use OCP\Util;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
@@ -129,7 +130,7 @@ public function boot(IBootContext $context): void {
$context->injectFn(Closure::fromCallable([$this, 'registerBackendDependents']));
- \OCP\Util::connectHook(
+ Util::connectHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
'\OCA\User_LDAP\Helper',
diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php
index 989d0bd3929d8..658ade62f5dc2 100644
--- a/apps/user_ldap/lib/Configuration.php
+++ b/apps/user_ldap/lib/Configuration.php
@@ -7,6 +7,7 @@
*/
namespace OCA\User_LDAP;
+use OCP\Server;
use Psr\Log\LoggerInterface;
/**
@@ -673,7 +674,7 @@ public function getAvatarAttributes(): array {
return [strtolower($attribute)];
}
if ($value !== self::AVATAR_PREFIX_DEFAULT) {
- \OCP\Server::get(LoggerInterface::class)->warning('Invalid config value to ldapUserAvatarRule; falling back to default.');
+ Server::get(LoggerInterface::class)->warning('Invalid config value to ldapUserAvatarRule; falling back to default.');
}
return $defaultAttributes;
}
diff --git a/apps/user_ldap/lib/FilesystemHelper.php b/apps/user_ldap/lib/FilesystemHelper.php
index 2a17282361a1c..eea7ec62ad8de 100644
--- a/apps/user_ldap/lib/FilesystemHelper.php
+++ b/apps/user_ldap/lib/FilesystemHelper.php
@@ -7,6 +7,8 @@
*/
namespace OCA\User_LDAP;
+use OC\Files\Filesystem;
+
/**
* @brief wraps around static Nextcloud core methods
*/
@@ -17,7 +19,7 @@ class FilesystemHelper {
* @return bool
*/
public function isLoaded() {
- return \OC\Files\Filesystem::$loaded;
+ return Filesystem::$loaded;
}
/**
diff --git a/apps/user_ldap/lib/GroupPluginManager.php b/apps/user_ldap/lib/GroupPluginManager.php
index 37622a5348068..6bdb5559a0224 100644
--- a/apps/user_ldap/lib/GroupPluginManager.php
+++ b/apps/user_ldap/lib/GroupPluginManager.php
@@ -6,6 +6,7 @@
namespace OCA\User_LDAP;
use OCP\GroupInterface;
+use OCP\Server;
use Psr\Log\LoggerInterface;
class GroupPluginManager {
@@ -41,7 +42,7 @@ public function register(ILDAPGroupPlugin $plugin) {
foreach ($this->which as $action => $v) {
if ((bool)($respondToActions & $action)) {
$this->which[$action] = $plugin;
- \OCP\Server::get(LoggerInterface::class)->debug('Registered action ' . $action . ' to plugin ' . get_class($plugin), ['app' => 'user_ldap']);
+ Server::get(LoggerInterface::class)->debug('Registered action ' . $action . ' to plugin ' . get_class($plugin), ['app' => 'user_ldap']);
}
}
}
diff --git a/apps/user_ldap/lib/Group_Proxy.php b/apps/user_ldap/lib/Group_Proxy.php
index 1a78a65e61ec2..931ad7d181a8b 100644
--- a/apps/user_ldap/lib/Group_Proxy.php
+++ b/apps/user_ldap/lib/Group_Proxy.php
@@ -18,7 +18,7 @@
use OCP\IConfig;
use OCP\IUserManager;
-class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGetDisplayNameBackend, INamedBackend, IDeleteGroupBackend, IBatchMethodsBackend, IIsAdminBackend {
+class Group_Proxy extends Proxy implements GroupInterface, IGroupLDAP, IGetDisplayNameBackend, INamedBackend, IDeleteGroupBackend, IBatchMethodsBackend, IIsAdminBackend {
private $backends = [];
private ?Group_LDAP $refBackend = null;
private Helper $helper;
diff --git a/apps/user_ldap/lib/Jobs/CleanUp.php b/apps/user_ldap/lib/Jobs/CleanUp.php
index b04dc67ef4923..fdae3e7ae8741 100644
--- a/apps/user_ldap/lib/Jobs/CleanUp.php
+++ b/apps/user_ldap/lib/Jobs/CleanUp.php
@@ -14,6 +14,7 @@
use OCA\User_LDAP\User_Proxy;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
+use OCP\Server;
/**
* Class CleanUp
@@ -95,7 +96,7 @@ public function setArguments($arguments): void {
if (isset($arguments['mapping'])) {
$this->mapping = $arguments['mapping'];
} else {
- $this->mapping = \OCP\Server::get(UserMapping::class);
+ $this->mapping = Server::get(UserMapping::class);
}
if (isset($arguments['deletedUsersIndex'])) {
diff --git a/apps/user_ldap/lib/LDAP.php b/apps/user_ldap/lib/LDAP.php
index b57cae72436c2..5e801dec72075 100644
--- a/apps/user_ldap/lib/LDAP.php
+++ b/apps/user_ldap/lib/LDAP.php
@@ -12,6 +12,7 @@
use OCA\User_LDAP\Exceptions\ConstraintViolationException;
use OCP\IConfig;
use OCP\Profiler\IProfiler;
+use OCP\Server;
use Psr\Log\LoggerInterface;
class LDAP implements ILDAPWrapper {
@@ -31,7 +32,7 @@ public function __construct(string $logFile = '') {
$profiler->add($this->dataCollector);
}
- $this->logger = \OCP\Server::get(LoggerInterface::class);
+ $this->logger = Server::get(LoggerInterface::class);
}
/**
diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php
index 94ac3c985cae2..a8f0cf84d7610 100644
--- a/apps/user_ldap/lib/Mapping/AbstractMapping.php
+++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php
@@ -11,6 +11,7 @@
use OCP\DB\IPreparedStatement;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
+use OCP\Server;
use Psr\Log\LoggerInterface;
/**
@@ -34,7 +35,7 @@ abstract protected function getTableName(bool $includePrefix = true);
/**
* @param \OCP\IDBConnection $dbc
*/
- public function __construct(\OCP\IDBConnection $dbc) {
+ public function __construct(IDBConnection $dbc) {
$this->dbc = $dbc;
}
@@ -333,7 +334,7 @@ public function getList(int $offset = 0, ?int $limit = null, bool $invalidatedOn
*/
public function map($fdn, $name, $uuid) {
if (mb_strlen($fdn) > 4000) {
- \OCP\Server::get(LoggerInterface::class)->error(
+ Server::get(LoggerInterface::class)->error(
'Cannot map, because the DN exceeds 4000 characters: {dn}',
[
'app' => 'user_ldap',
diff --git a/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php b/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php
index 85b046ab7c944..82bf0b150273b 100644
--- a/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php
+++ b/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php
@@ -10,6 +10,7 @@
namespace OCA\User_LDAP\Migration;
use Closure;
+use OCP\DB\Exception;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\IDBConnection;
@@ -95,7 +96,7 @@ protected function copyGroupMembershipData(): void {
;
$insert->executeStatement();
- } catch (\OCP\DB\Exception $e) {
+ } catch (Exception $e) {
/*
* If it fails on unique constaint violation it may just be left over value from previous half-migration
* If it fails on something else, ignore as well, data will be filled by background job later anyway
diff --git a/apps/user_ldap/lib/Notification/Notifier.php b/apps/user_ldap/lib/Notification/Notifier.php
index 23ad77f75f2ac..8858bc33f802d 100644
--- a/apps/user_ldap/lib/Notification/Notifier.php
+++ b/apps/user_ldap/lib/Notification/Notifier.php
@@ -18,7 +18,7 @@ class Notifier implements INotifier {
/**
* @param IFactory $l10nFactory
*/
- public function __construct(\OCP\L10N\IFactory $l10nFactory) {
+ public function __construct(IFactory $l10nFactory) {
$this->l10nFactory = $l10nFactory;
}
diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php
index 5d5ad8b26585f..7b03483200da6 100644
--- a/apps/user_ldap/lib/User/Manager.php
+++ b/apps/user_ldap/lib/User/Manager.php
@@ -77,7 +77,7 @@ public function setLdapAccess(Access $access) {
* property array
* @param string $dn the DN of the user
* @param string $uid the internal (owncloud) username
- * @return \OCA\User_LDAP\User\User
+ * @return User
*/
private function createAndCache($dn, $uid) {
$this->checkAccess();
@@ -188,7 +188,7 @@ public function isDeletedUser($id) {
/**
* creates and returns an instance of OfflineUser for the specified user
* @param string $id
- * @return \OCA\User_LDAP\User\OfflineUser
+ * @return OfflineUser
*/
public function getDeletedUser($id) {
return new OfflineUser(
@@ -202,7 +202,7 @@ public function getDeletedUser($id) {
/**
* @brief returns a User object by its Nextcloud username
* @param string $id the DN or username of the user
- * @return \OCA\User_LDAP\User\User|\OCA\User_LDAP\User\OfflineUser|null
+ * @return User|OfflineUser|null
*/
protected function createInstancyByUserName($id) {
//most likely a uid. Check whether it is a deleted user
@@ -219,7 +219,7 @@ protected function createInstancyByUserName($id) {
/**
* @brief returns a User object by its DN or Nextcloud username
* @param string $id the DN or username of the user
- * @return \OCA\User_LDAP\User\User|\OCA\User_LDAP\User\OfflineUser|null
+ * @return User|OfflineUser|null
* @throws \Exception when connection could not be established
*/
public function get($id) {
diff --git a/apps/user_ldap/lib/User/OfflineUser.php b/apps/user_ldap/lib/User/OfflineUser.php
index eed715ccc1cc3..873bd597df83c 100644
--- a/apps/user_ldap/lib/User/OfflineUser.php
+++ b/apps/user_ldap/lib/User/OfflineUser.php
@@ -60,7 +60,7 @@ class OfflineUser {
*/
protected $db;
/**
- * @var \OCA\User_LDAP\Mapping\UserMapping
+ * @var UserMapping
*/
protected $mapping;
/** @var IManager */
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
index 0688a843bd7e2..eeab1153b1792 100644
--- a/apps/user_ldap/lib/User/User.php
+++ b/apps/user_ldap/lib/User/User.php
@@ -23,6 +23,7 @@
use OCP\IUserManager;
use OCP\Notification\IManager as INotificationManager;
use OCP\Server;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
@@ -121,7 +122,7 @@ public function __construct($username, $dn, Access $access,
$this->notificationManager = $notificationManager;
$this->birthdateParser = new BirthdateParserService();
- \OCP\Util::connectHook('OC_User', 'post_login', $this, 'handlePasswordExpiry');
+ Util::connectHook('OC_User', 'post_login', $this, 'handlePasswordExpiry');
}
/**
@@ -228,7 +229,7 @@ public function processAttributes($ldapEntry) {
//User Profile Field - Phone number
$attr = strtolower($this->connection->ldapAttributePhone);
if (!empty($attr)) { // attribute configured
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_PHONE]
+ $profileValues[IAccountManager::PROPERTY_PHONE]
= $ldapEntry[$attr][0] ?? '';
}
//User Profile Field - website
@@ -237,57 +238,57 @@ public function processAttributes($ldapEntry) {
$cutPosition = strpos($ldapEntry[$attr][0], ' ');
if ($cutPosition) {
// drop appended label
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_WEBSITE]
+ $profileValues[IAccountManager::PROPERTY_WEBSITE]
= substr($ldapEntry[$attr][0], 0, $cutPosition);
} else {
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_WEBSITE]
+ $profileValues[IAccountManager::PROPERTY_WEBSITE]
= $ldapEntry[$attr][0];
}
} elseif (!empty($attr)) { // configured, but not defined
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_WEBSITE] = '';
+ $profileValues[IAccountManager::PROPERTY_WEBSITE] = '';
}
//User Profile Field - Address
$attr = strtolower($this->connection->ldapAttributeAddress);
if (isset($ldapEntry[$attr])) {
if (str_contains($ldapEntry[$attr][0], '$')) {
// basic format conversion from postalAddress syntax to commata delimited
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_ADDRESS]
+ $profileValues[IAccountManager::PROPERTY_ADDRESS]
= str_replace('$', ', ', $ldapEntry[$attr][0]);
} else {
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_ADDRESS]
+ $profileValues[IAccountManager::PROPERTY_ADDRESS]
= $ldapEntry[$attr][0];
}
} elseif (!empty($attr)) { // configured, but not defined
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_ADDRESS] = '';
+ $profileValues[IAccountManager::PROPERTY_ADDRESS] = '';
}
//User Profile Field - Twitter
$attr = strtolower($this->connection->ldapAttributeTwitter);
if (!empty($attr)) {
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_TWITTER]
+ $profileValues[IAccountManager::PROPERTY_TWITTER]
= $ldapEntry[$attr][0] ?? '';
}
//User Profile Field - fediverse
$attr = strtolower($this->connection->ldapAttributeFediverse);
if (!empty($attr)) {
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_FEDIVERSE]
+ $profileValues[IAccountManager::PROPERTY_FEDIVERSE]
= $ldapEntry[$attr][0] ?? '';
}
//User Profile Field - organisation
$attr = strtolower($this->connection->ldapAttributeOrganisation);
if (!empty($attr)) {
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_ORGANISATION]
+ $profileValues[IAccountManager::PROPERTY_ORGANISATION]
= $ldapEntry[$attr][0] ?? '';
}
//User Profile Field - role
$attr = strtolower($this->connection->ldapAttributeRole);
if (!empty($attr)) {
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_ROLE]
+ $profileValues[IAccountManager::PROPERTY_ROLE]
= $ldapEntry[$attr][0] ?? '';
}
//User Profile Field - headline
$attr = strtolower($this->connection->ldapAttributeHeadline);
if (!empty($attr)) {
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_HEADLINE]
+ $profileValues[IAccountManager::PROPERTY_HEADLINE]
= $ldapEntry[$attr][0] ?? '';
}
//User Profile Field - biography
@@ -295,14 +296,14 @@ public function processAttributes($ldapEntry) {
if (isset($ldapEntry[$attr])) {
if (str_contains($ldapEntry[$attr][0], '\r')) {
// convert line endings
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_BIOGRAPHY]
+ $profileValues[IAccountManager::PROPERTY_BIOGRAPHY]
= str_replace(["\r\n","\r"], "\n", $ldapEntry[$attr][0]);
} else {
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_BIOGRAPHY]
+ $profileValues[IAccountManager::PROPERTY_BIOGRAPHY]
= $ldapEntry[$attr][0];
}
} elseif (!empty($attr)) { // configured, but not defined
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_BIOGRAPHY] = '';
+ $profileValues[IAccountManager::PROPERTY_BIOGRAPHY] = '';
}
//User Profile Field - birthday
$attr = strtolower($this->connection->ldapAttributeBirthDate);
@@ -310,7 +311,7 @@ public function processAttributes($ldapEntry) {
$value = $ldapEntry[$attr][0];
try {
$birthdate = $this->birthdateParser->parseBirthdate($value);
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_BIRTHDATE]
+ $profileValues[IAccountManager::PROPERTY_BIRTHDATE]
= $birthdate->format('Y-m-d');
} catch (InvalidArgumentException $e) {
// Invalid date -> just skip the property
@@ -323,7 +324,7 @@ public function processAttributes($ldapEntry) {
//User Profile Field - pronouns
$attr = strtolower($this->connection->ldapAttributePronouns);
if (!empty($attr)) {
- $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS]
+ $profileValues[IAccountManager::PROPERTY_PRONOUNS]
= $ldapEntry[$attr][0] ?? '';
}
// check for changed data and cache just for TTL checking
@@ -354,7 +355,7 @@ public function processAttributes($ldapEntry) {
// system must be postponed after the login. It is to ensure
// external mounts are mounted properly (e.g. with login
// credentials from the session).
- \OCP\Util::connectHook('OC_User', 'post_login', $this, 'updateAvatarPostLogin');
+ Util::connectHook('OC_User', 'post_login', $this, 'updateAvatarPostLogin');
break;
}
}
diff --git a/apps/user_ldap/lib/UserPluginManager.php b/apps/user_ldap/lib/UserPluginManager.php
index 4a36794bca523..402464b56a5f9 100644
--- a/apps/user_ldap/lib/UserPluginManager.php
+++ b/apps/user_ldap/lib/UserPluginManager.php
@@ -6,6 +6,7 @@
namespace OCA\User_LDAP;
use OC\User\Backend;
+use OCP\Server;
use Psr\Log\LoggerInterface;
class UserPluginManager {
@@ -43,12 +44,12 @@ public function register(ILDAPUserPlugin $plugin) {
foreach ($this->which as $action => $v) {
if (is_int($action) && (bool)($respondToActions & $action)) {
$this->which[$action] = $plugin;
- \OCP\Server::get(LoggerInterface::class)->debug('Registered action ' . $action . ' to plugin ' . get_class($plugin), ['app' => 'user_ldap']);
+ Server::get(LoggerInterface::class)->debug('Registered action ' . $action . ' to plugin ' . get_class($plugin), ['app' => 'user_ldap']);
}
}
if (method_exists($plugin, 'deleteUser')) {
$this->which['deleteUser'] = $plugin;
- \OCP\Server::get(LoggerInterface::class)->debug('Registered action deleteUser to plugin ' . get_class($plugin), ['app' => 'user_ldap']);
+ Server::get(LoggerInterface::class)->debug('Registered action deleteUser to plugin ' . get_class($plugin), ['app' => 'user_ldap']);
}
}
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index e34f0fcb18506..04b1d85a80856 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -258,8 +258,8 @@ public function getUsers($search = '', $limit = 10, $offset = 0) {
/**
* checks whether a user is still available on LDAP
*
- * @param string|\OCA\User_LDAP\User\User $user either the Nextcloud user
- * name or an instance of that user
+ * @param string|User $user either the Nextcloud user
+ * name or an instance of that user
* @throws \Exception
* @throws \OC\ServerNotAvailableException
*/
diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php
index 0cb0e6e6cdeda..35f5d8b0f3321 100644
--- a/apps/user_ldap/lib/User_Proxy.php
+++ b/apps/user_ldap/lib/User_Proxy.php
@@ -220,8 +220,8 @@ public function userExists($uid) {
/**
* check if a user exists on LDAP
*
- * @param string|\OCA\User_LDAP\User\User $user either the Nextcloud user
- * name or an instance of that user
+ * @param string|User $user either the Nextcloud user
+ * name or an instance of that user
*/
public function userExistsOnLDAP($user, bool $ignoreCache = false): bool {
$id = ($user instanceof User) ? $user->getUsername() : $user;
diff --git a/apps/user_ldap/lib/Wizard.php b/apps/user_ldap/lib/Wizard.php
index 87f0d04f4974a..262777c5022f9 100644
--- a/apps/user_ldap/lib/Wizard.php
+++ b/apps/user_ldap/lib/Wizard.php
@@ -11,6 +11,7 @@
use OC\ServerNotAvailableException;
use OCP\IL10N;
use OCP\L10N\IFactory as IL10NFactory;
+use OCP\Util;
use Psr\Log\LoggerInterface;
class Wizard extends LDAPUtility {
@@ -1253,7 +1254,7 @@ private function getAttributeValuesFromEntry(array $result, string $attribute, a
}
// strtolower on all keys for proper comparison
- $result = \OCP\Util::mb_array_change_key_case($result);
+ $result = Util::mb_array_change_key_case($result);
$attribute = strtolower($attribute);
if (isset($result[$attribute])) {
foreach ($result[$attribute] as $key => $val) {
diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php
index 6deaad763f12e..5bb4a4657cbed 100644
--- a/apps/user_ldap/tests/AccessTest.php
+++ b/apps/user_ldap/tests/AccessTest.php
@@ -6,6 +6,7 @@
*/
namespace OCA\User_LDAP\Tests;
+use OC\ServerNotAvailableException;
use OCA\User_LDAP\Access;
use OCA\User_LDAP\Connection;
use OCA\User_LDAP\Exceptions\ConstraintViolationException;
@@ -19,6 +20,7 @@
use OCA\User_LDAP\User\OfflineUser;
use OCA\User_LDAP\User\User;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\HintException;
use OCP\IAppConfig;
use OCP\IAvatarManager;
use OCP\IConfig;
@@ -470,19 +472,19 @@ public function testSetPasswordWithLdapNotAvailable(): void {
$this->connection
->expects($this->once())
->method('getConnectionResource')
- ->willThrowException(new \OC\ServerNotAvailableException('Connection to LDAP server could not be established'));
+ ->willThrowException(new ServerNotAvailableException('Connection to LDAP server could not be established'));
$this->ldap
->expects($this->never())
->method('isResource');
- $this->expectException(\OC\ServerNotAvailableException::class);
+ $this->expectException(ServerNotAvailableException::class);
$this->expectExceptionMessage('Connection to LDAP server could not be established');
$this->access->setPassword('CN=foo', 'MyPassword');
}
public function testSetPasswordWithRejectedChange(): void {
- $this->expectException(\OCP\HintException::class);
+ $this->expectException(HintException::class);
$this->expectExceptionMessage('Password change rejected.');
$this->connection
diff --git a/apps/user_ldap/tests/ConnectionTest.php b/apps/user_ldap/tests/ConnectionTest.php
index bc65de39f94fc..9cb19891b3dc4 100644
--- a/apps/user_ldap/tests/ConnectionTest.php
+++ b/apps/user_ldap/tests/ConnectionTest.php
@@ -7,6 +7,7 @@
*/
namespace OCA\User_LDAP\Tests;
+use OC\ServerNotAvailableException;
use OCA\User_LDAP\Connection;
use OCA\User_LDAP\ILDAPWrapper;
@@ -18,7 +19,7 @@
* @package OCA\User_LDAP\Tests
*/
class ConnectionTest extends \Test\TestCase {
- /** @var \OCA\User_LDAP\ILDAPWrapper|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var ILDAPWrapper|\PHPUnit\Framework\MockObject\MockObject */
protected $ldap;
/** @var Connection */
@@ -114,7 +115,7 @@ public function testUseBackupServer(): void {
->willReturnCallback(function () use (&$isThrown) {
if (!$isThrown) {
$isThrown = true;
- throw new \OC\ServerNotAvailableException();
+ throw new ServerNotAvailableException();
}
return true;
});
@@ -212,7 +213,7 @@ public function testBindWithInvalidCredentials(): void {
try {
$this->assertFalse($this->connection->bind(), 'Connection::bind() should not return true with invalid credentials.');
- } catch (\OC\ServerNotAvailableException $e) {
+ } catch (ServerNotAvailableException $e) {
$this->fail('Failed asserting that exception of type "OC\ServerNotAvailableException" is not thrown.');
}
}
@@ -260,7 +261,7 @@ public function testStartTlsNegotiationFailure(): void {
->method('startTls')
->willReturn(false);
- $this->expectException(\OC\ServerNotAvailableException::class);
+ $this->expectException(ServerNotAvailableException::class);
$this->expectExceptionMessage('Start TLS failed, when connecting to LDAP host ' . $host . '.');
$this->connection->init();
diff --git a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
index fd24fe8a89126..30b3e573cd470 100644
--- a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
+++ b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
@@ -16,6 +16,8 @@
use OCA\User_LDAP\User\Manager;
use OCA\User_LDAP\UserPluginManager;
use OCP\IAvatarManager;
+use OCP\Image;
+use OCP\Server;
use OCP\Share\IManager;
use Psr\Log\LoggerInterface;
@@ -57,10 +59,10 @@ public function __construct($host, $port, $bind, $pwd, $base) {
*/
public function init() {
\OC::$server->registerService(UserPluginManager::class, function () {
- return new \OCA\User_LDAP\UserPluginManager();
+ return new UserPluginManager();
});
\OC::$server->registerService(GroupPluginManager::class, function () {
- return new \OCA\User_LDAP\GroupPluginManager();
+ return new GroupPluginManager();
});
$this->initLDAPWrapper();
@@ -106,7 +108,7 @@ protected function initUserManager() {
new FilesystemHelper(),
\OC::$server->get(LoggerInterface::class),
\OC::$server->get(IAvatarManager::class),
- new \OCP\Image(),
+ new Image(),
\OC::$server->getUserManager(),
\OC::$server->getNotificationManager(),
\OC::$server->get(IManager::class)
@@ -124,7 +126,7 @@ protected function initHelper() {
* initializes the Access test instance
*/
protected function initAccess() {
- $this->access = new Access($this->connection, $this->ldap, $this->userManager, $this->helper, \OC::$server->getConfig(), \OCP\Server::get(LoggerInterface::class));
+ $this->access = new Access($this->connection, $this->ldap, $this->userManager, $this->helper, \OC::$server->getConfig(), Server::get(LoggerInterface::class));
}
/**
diff --git a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php
index 4618179f8abc0..2beab95b71f2b 100644
--- a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php
+++ b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php
@@ -39,7 +39,7 @@ class ExceptionOnLostConnection {
/** @var string */
private $ldapHost;
- /** @var \OCA\User_LDAP\LDAP */
+ /** @var LDAP */
private $ldap;
/** @var bool */
diff --git a/apps/user_ldap/tests/LDAPProviderTest.php b/apps/user_ldap/tests/LDAPProviderTest.php
index e96b7b59a9436..5888c6624f305 100644
--- a/apps/user_ldap/tests/LDAPProviderTest.php
+++ b/apps/user_ldap/tests/LDAPProviderTest.php
@@ -5,12 +5,15 @@
*/
namespace OCA\User_LDAP\Tests;
+use OC\Config;
use OC\User\Manager;
use OCA\User_LDAP\Access;
use OCA\User_LDAP\Connection;
use OCA\User_LDAP\Group_LDAP;
+use OCA\User_LDAP\Helper;
use OCA\User_LDAP\IGroupLDAP;
use OCA\User_LDAP\IUserLDAP;
+use OCA\User_LDAP\LDAPProviderFactory;
use OCA\User_LDAP\User_LDAP;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ICacheFactory;
@@ -33,7 +36,7 @@ protected function setUp(): void {
private function getServerMock(IUserLDAP $userBackend, IGroupLDAP $groupBackend) {
$server = $this->getMockBuilder('OC\Server')
->setMethods(['getUserManager', 'getBackends', 'getGroupManager'])
- ->setConstructorArgs(['', new \OC\Config(\OC::$configDir)])
+ ->setConstructorArgs(['', new Config(\OC::$configDir)])
->getMock();
$server->expects($this->any())
->method('getUserManager')
@@ -84,7 +87,7 @@ private function getDefaultGroupBackendMock() {
}
private function getLDAPProvider(IServerContainer $serverContainer) {
- $factory = new \OCA\User_LDAP\LDAPProviderFactory($serverContainer);
+ $factory = new LDAPProviderFactory($serverContainer);
return $factory->getLDAPProvider();
}
@@ -201,7 +204,7 @@ public function testDNasBaseParameter(): void {
$server = $this->getServerMock($userBackend, $this->getDefaultGroupBackendMock());
- $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection());
+ $helper = new Helper(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection());
$ldapProvider = $this->getLDAPProvider($server);
$this->assertEquals(
@@ -217,7 +220,7 @@ public function testSanitizeDN(): void {
$server = $this->getServerMock($userBackend, $this->getDefaultGroupBackendMock());
- $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection());
+ $helper = new Helper(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection());
$ldapProvider = $this->getLDAPProvider($server);
$this->assertEquals(
diff --git a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
index 84703e096160b..b95856a0f4c09 100644
--- a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
+++ b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
@@ -11,7 +11,7 @@
use OCP\IDBConnection;
abstract class AbstractMappingTest extends \Test\TestCase {
- abstract public function getMapper(\OCP\IDBConnection $dbMock);
+ abstract public function getMapper(IDBConnection $dbMock);
/**
* kiss test on isColNameValid
@@ -52,7 +52,7 @@ protected function getTestData() {
/**
* calls map() on the given mapper and asserts result for true
- * @param \OCA\User_LDAP\Mapping\AbstractMapping $mapper
+ * @param AbstractMapping $mapper
* @param array $data
*/
protected function mapEntries($mapper, $data) {
diff --git a/apps/user_ldap/tests/Mapping/GroupMappingTest.php b/apps/user_ldap/tests/Mapping/GroupMappingTest.php
index 0d407577e1b9e..efa42e478633b 100644
--- a/apps/user_ldap/tests/Mapping/GroupMappingTest.php
+++ b/apps/user_ldap/tests/Mapping/GroupMappingTest.php
@@ -8,6 +8,7 @@
namespace OCA\User_LDAP\Tests\Mapping;
use OCA\User_LDAP\Mapping\GroupMapping;
+use OCP\IDBConnection;
/**
* Class GroupMappingTest
@@ -17,7 +18,7 @@
* @package OCA\User_LDAP\Tests\Mapping
*/
class GroupMappingTest extends AbstractMappingTest {
- public function getMapper(\OCP\IDBConnection $dbMock) {
+ public function getMapper(IDBConnection $dbMock) {
return new GroupMapping($dbMock);
}
}
diff --git a/apps/user_ldap/tests/Mapping/UserMappingTest.php b/apps/user_ldap/tests/Mapping/UserMappingTest.php
index 1792a4124be7c..07980ba470c79 100644
--- a/apps/user_ldap/tests/Mapping/UserMappingTest.php
+++ b/apps/user_ldap/tests/Mapping/UserMappingTest.php
@@ -8,6 +8,7 @@
namespace OCA\User_LDAP\Tests\Mapping;
use OCA\User_LDAP\Mapping\UserMapping;
+use OCP\IDBConnection;
use OCP\Support\Subscription\IAssertion;
/**
@@ -18,7 +19,7 @@
* @package OCA\User_LDAP\Tests\Mapping
*/
class UserMappingTest extends AbstractMappingTest {
- public function getMapper(\OCP\IDBConnection $dbMock) {
+ public function getMapper(IDBConnection $dbMock) {
return new UserMapping($dbMock, $this->createMock(IAssertion::class));
}
}
diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php
index d596402d32296..3939c41c4ca0f 100644
--- a/apps/user_ldap/tests/User/UserTest.php
+++ b/apps/user_ldap/tests/User/UserTest.php
@@ -19,6 +19,7 @@
use OCP\IUserManager;
use OCP\Notification\IManager as INotificationManager;
use OCP\Notification\INotification;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
@@ -1149,7 +1150,7 @@ public function testHandlePasswordExpiryWarningDefaultPolicy(): void {
->method('notify');
\OC_Hook::clear();//disconnect irrelevant hooks
- \OCP\Util::connectHook('OC_User', 'post_login', $this->user, 'handlePasswordExpiry');
+ Util::connectHook('OC_User', 'post_login', $this->user, 'handlePasswordExpiry');
/** @noinspection PhpUnhandledExceptionInspection */
\OC_Hook::emit('OC_User', 'post_login', ['uid' => $this->uid]);
}
@@ -1213,7 +1214,7 @@ public function testHandlePasswordExpiryWarningCustomPolicy(): void {
->method('notify');
\OC_Hook::clear();//disconnect irrelevant hooks
- \OCP\Util::connectHook('OC_User', 'post_login', $this->user, 'handlePasswordExpiry');
+ Util::connectHook('OC_User', 'post_login', $this->user, 'handlePasswordExpiry');
/** @noinspection PhpUnhandledExceptionInspection */
\OC_Hook::emit('OC_User', 'post_login', ['uid' => $this->uid]);
}
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php
index f766c7f583aeb..5b01b25109f3d 100644
--- a/apps/user_ldap/tests/User_LDAPTest.php
+++ b/apps/user_ldap/tests/User_LDAPTest.php
@@ -1238,7 +1238,7 @@ private function prepareAccessForSetPassword($enablePasswordChange = true) {
public function testSetPasswordInvalid(): void {
- $this->expectException(\OCP\HintException::class);
+ $this->expectException(HintException::class);
$this->expectExceptionMessage('Password fails quality checking policy');
$this->prepareAccessForSetPassword($this->access);
@@ -1383,7 +1383,7 @@ public function testSetDisplayNameWithPlugin(): void {
public function testSetDisplayNameErrorWithPlugin(): void {
- $this->expectException(\OCP\HintException::class);
+ $this->expectException(HintException::class);
$newDisplayName = 'J. Baker';
$this->pluginManager->expects($this->once())
diff --git a/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php b/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php
index 49ac93573dd96..031ad4f9126a7 100644
--- a/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php
+++ b/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php
@@ -18,6 +18,7 @@
use OCP\EventDispatcher\IEventListener;
use OCP\IInitialStateService;
use OCP\IUserSession;
+use OCP\Util;
/** @template-implements IEventListener */
class BeforeTemplateRenderedListener implements IEventListener {
@@ -80,7 +81,7 @@ public function handle(Event $event): void {
return ['profileEnabled' => $this->profileManager->isProfileEnabled($user)];
});
- \OCP\Util::addScript('user_status', 'menu');
- \OCP\Util::addStyle('user_status', 'user-status-menu');
+ Util::addScript('user_status', 'menu');
+ Util::addStyle('user_status', 'user-status-menu');
}
}
diff --git a/apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php b/apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php
index c78be6e4e6b5d..997e8931703ed 100644
--- a/apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php
+++ b/apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php
@@ -9,6 +9,7 @@
namespace OCA\WebhookListeners\BackgroundJobs;
+use OCA\AppAPI\PublicFunctions;
use OCA\WebhookListeners\Db\AuthMethod;
use OCA\WebhookListeners\Db\WebhookListenerMapper;
use OCP\App\IAppManager;
@@ -16,6 +17,7 @@
use OCP\BackgroundJob\QueuedJob;
use OCP\Http\Client\IClientService;
use OCP\ICertificateManager;
+use OCP\Server;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
@@ -62,7 +64,7 @@ protected function run($argument): void {
throw new RuntimeException('AppAPI is disabled or not installed.');
}
try {
- $appApiFunctions = \OCP\Server::get(\OCA\AppAPI\PublicFunctions::class);
+ $appApiFunctions = Server::get(PublicFunctions::class);
} catch (ContainerExceptionInterface|NotFoundExceptionInterface) {
throw new RuntimeException('Could not get AppAPI public functions.');
}
diff --git a/apps/webhook_listeners/lib/Db/WebhookListener.php b/apps/webhook_listeners/lib/Db/WebhookListener.php
index 4f226a3407ca7..af974e7b0e25f 100644
--- a/apps/webhook_listeners/lib/Db/WebhookListener.php
+++ b/apps/webhook_listeners/lib/Db/WebhookListener.php
@@ -11,6 +11,7 @@
use OCP\AppFramework\Db\Entity;
use OCP\Security\ICrypto;
+use OCP\Server;
/**
* @method void setUserId(?string $userId)
@@ -89,7 +90,7 @@ public function __construct(
?ICrypto $crypto = null,
) {
if ($crypto === null) {
- $crypto = \OCP\Server::get(ICrypto::class);
+ $crypto = Server::get(ICrypto::class);
}
$this->crypto = $crypto;
$this->addType('appId', 'string');
diff --git a/apps/webhook_listeners/tests/Db/WebhookListenerMapperTest.php b/apps/webhook_listeners/tests/Db/WebhookListenerMapperTest.php
index aefed2961ead1..be99bccb67739 100644
--- a/apps/webhook_listeners/tests/Db/WebhookListenerMapperTest.php
+++ b/apps/webhook_listeners/tests/Db/WebhookListenerMapperTest.php
@@ -14,6 +14,7 @@
use OCP\Files\Events\Node\NodeWrittenEvent;
use OCP\ICacheFactory;
use OCP\IDBConnection;
+use OCP\Server;
use OCP\User\Events\UserCreatedEvent;
use Test\TestCase;
@@ -28,8 +29,8 @@ class WebhookListenerMapperTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->connection = \OCP\Server::get(IDBConnection::class);
- $this->cacheFactory = \OCP\Server::get(ICacheFactory::class);
+ $this->connection = Server::get(IDBConnection::class);
+ $this->cacheFactory = Server::get(ICacheFactory::class);
$this->pruneTables();
$this->mapper = new WebhookListenerMapper(
diff --git a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php
index c598c756bedef..774f866bf127d 100644
--- a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php
+++ b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php
@@ -5,6 +5,7 @@
*/
namespace OCA\WorkflowEngine\Tests\Check;
+use OCA\WorkflowEngine\Check\AbstractStringCheck;
use OCP\IL10N;
class AbstractStringCheckTest extends \Test\TestCase {
@@ -55,7 +56,7 @@ public function dataExecuteStringCheck() {
public function testExecuteStringCheck($operation, $checkValue, $actualValue, $expected): void {
$check = $this->getCheckMock();
- /** @var \OCA\WorkflowEngine\Check\AbstractStringCheck $check */
+ /** @var AbstractStringCheck $check */
$this->assertEquals($expected, $this->invokePrivate($check, 'executeStringCheck', [$operation, $checkValue, $actualValue]));
}
@@ -76,7 +77,7 @@ public function dataValidateCheck() {
public function testValidateCheck($operator, $value): void {
$check = $this->getCheckMock();
- /** @var \OCA\WorkflowEngine\Check\AbstractStringCheck $check */
+ /** @var AbstractStringCheck $check */
$check->validateCheck($operator, $value);
$this->addToAssertionCount(1);
@@ -102,7 +103,7 @@ public function testValidateCheckInvalid($operator, $value, $exceptionCode, $exc
$check = $this->getCheckMock();
try {
- /** @var \OCA\WorkflowEngine\Check\AbstractStringCheck $check */
+ /** @var AbstractStringCheck $check */
$check->validateCheck($operator, $value);
} catch (\UnexpectedValueException $e) {
$this->assertEquals($exceptionCode, $e->getCode());
diff --git a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php
index 438a59a8a48e4..3775d7ff76827 100644
--- a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php
+++ b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php
@@ -5,6 +5,7 @@
*/
namespace OCA\WorkflowEngine\Tests\Check;
+use OCA\WorkflowEngine\Check\RequestRemoteAddress;
use OCP\IL10N;
use OCP\IRequest;
@@ -53,7 +54,7 @@ public function dataExecuteCheckIPv4() {
* @param bool $expected
*/
public function testExecuteCheckMatchesIPv4($value, $ip, $expected): void {
- $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->getL10NMock(), $this->request);
+ $check = new RequestRemoteAddress($this->getL10NMock(), $this->request);
$this->request->expects($this->once())
->method('getRemoteAddress')
@@ -69,7 +70,7 @@ public function testExecuteCheckMatchesIPv4($value, $ip, $expected): void {
* @param bool $expected
*/
public function testExecuteCheckNotMatchesIPv4($value, $ip, $expected): void {
- $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->getL10NMock(), $this->request);
+ $check = new RequestRemoteAddress($this->getL10NMock(), $this->request);
$this->request->expects($this->once())
->method('getRemoteAddress')
@@ -97,7 +98,7 @@ public function dataExecuteCheckIPv6() {
* @param bool $expected
*/
public function testExecuteCheckMatchesIPv6($value, $ip, $expected): void {
- $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->getL10NMock(), $this->request);
+ $check = new RequestRemoteAddress($this->getL10NMock(), $this->request);
$this->request->expects($this->once())
->method('getRemoteAddress')
@@ -113,7 +114,7 @@ public function testExecuteCheckMatchesIPv6($value, $ip, $expected): void {
* @param bool $expected
*/
public function testExecuteCheckNotMatchesIPv6($value, $ip, $expected): void {
- $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->getL10NMock(), $this->request);
+ $check = new RequestRemoteAddress($this->getL10NMock(), $this->request);
$this->request->expects($this->once())
->method('getRemoteAddress')
diff --git a/apps/workflowengine/tests/Check/RequestTimeTest.php b/apps/workflowengine/tests/Check/RequestTimeTest.php
index 34ea656f416f9..083e6171d29a1 100644
--- a/apps/workflowengine/tests/Check/RequestTimeTest.php
+++ b/apps/workflowengine/tests/Check/RequestTimeTest.php
@@ -5,6 +5,7 @@
*/
namespace OCA\WorkflowEngine\Tests\Check;
+use OCA\WorkflowEngine\Check\RequestTime;
use OCP\IL10N;
class RequestTimeTest extends \Test\TestCase {
@@ -72,7 +73,7 @@ public function dataExecuteCheck() {
* @param bool $expected
*/
public function testExecuteCheckIn($value, $timestamp, $expected): void {
- $check = new \OCA\WorkflowEngine\Check\RequestTime($this->getL10NMock(), $this->timeFactory);
+ $check = new RequestTime($this->getL10NMock(), $this->timeFactory);
$this->timeFactory->expects($this->once())
->method('getTime')
@@ -88,7 +89,7 @@ public function testExecuteCheckIn($value, $timestamp, $expected): void {
* @param bool $expected
*/
public function testExecuteCheckNotIn($value, $timestamp, $expected): void {
- $check = new \OCA\WorkflowEngine\Check\RequestTime($this->getL10NMock(), $this->timeFactory);
+ $check = new RequestTime($this->getL10NMock(), $this->timeFactory);
$this->timeFactory->expects($this->once())
->method('getTime')
@@ -111,7 +112,7 @@ public function dataValidateCheck() {
* @param string $value
*/
public function testValidateCheck($operator, $value): void {
- $check = new \OCA\WorkflowEngine\Check\RequestTime($this->getL10NMock(), $this->timeFactory);
+ $check = new RequestTime($this->getL10NMock(), $this->timeFactory);
$check->validateCheck($operator, $value);
$this->addToAssertionCount(1);
}
@@ -136,7 +137,7 @@ public function dataValidateCheckInvalid() {
* @param string $exceptionMessage
*/
public function testValidateCheckInvalid($operator, $value, $exceptionCode, $exceptionMessage): void {
- $check = new \OCA\WorkflowEngine\Check\RequestTime($this->getL10NMock(), $this->timeFactory);
+ $check = new RequestTime($this->getL10NMock(), $this->timeFactory);
try {
$check->validateCheck($operator, $value);
diff --git a/apps/workflowengine/tests/Check/RequestUserAgentTest.php b/apps/workflowengine/tests/Check/RequestUserAgentTest.php
index f74cf669cc7b9..cc5cf3209b3bf 100644
--- a/apps/workflowengine/tests/Check/RequestUserAgentTest.php
+++ b/apps/workflowengine/tests/Check/RequestUserAgentTest.php
@@ -5,6 +5,7 @@
*/
namespace OCA\WorkflowEngine\Tests\Check;
+use OCA\WorkflowEngine\Check\AbstractStringCheck;
use OCA\WorkflowEngine\Check\RequestUserAgent;
use OCP\IL10N;
use OCP\IRequest;
@@ -95,7 +96,7 @@ public function testExecuteCheck($operation, $checkValue, $actualValue, $expecte
->method('getHeader')
->willReturn($actualValue);
- /** @var \OCA\WorkflowEngine\Check\AbstractStringCheck $check */
+ /** @var AbstractStringCheck $check */
$this->assertEquals($expected, $this->check->executeCheck($operation, $checkValue));
}
}