Skip to content

Commit 63099de

Browse files
committed
chore(apps): Apply "use" auto-import of Nextcloud classes to all apps
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent ec5b140 commit 63099de

File tree

315 files changed

+2157
-1662
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

315 files changed

+2157
-1662
lines changed

apps/admin_audit/lib/Actions/Files.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\Files\Events\Node\NodeWrittenEvent;
1919
use OCP\Files\InvalidPathException;
2020
use OCP\Files\NotFoundException;
21+
use OCP\Server;
2122
use Psr\Log\LoggerInterface;
2223

2324
/**
@@ -41,7 +42,7 @@ public function read(BeforeNodeReadEvent $event): void {
4142
'path' => mb_substr($node->getInternalPath(), 5),
4243
];
4344
} catch (InvalidPathException|NotFoundException $e) {
44-
\OCP\Server::get(LoggerInterface::class)->error(
45+
Server::get(LoggerInterface::class)->error(
4546
'Exception thrown in file read: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
4647
);
4748
return;
@@ -63,7 +64,7 @@ public function beforeRename(BeforeNodeRenamedEvent $event): void {
6364
$source = $event->getSource();
6465
$this->renamedNodes[$source->getId()] = $source;
6566
} catch (InvalidPathException|NotFoundException $e) {
66-
\OCP\Server::get(LoggerInterface::class)->error(
67+
Server::get(LoggerInterface::class)->error(
6768
'Exception thrown in file rename: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
6869
);
6970
return;
@@ -85,7 +86,7 @@ public function afterRename(NodeRenamedEvent $event): void {
8586
'newpath' => mb_substr($target->getInternalPath(), 5),
8687
];
8788
} catch (InvalidPathException|NotFoundException $e) {
88-
\OCP\Server::get(LoggerInterface::class)->error(
89+
Server::get(LoggerInterface::class)->error(
8990
'Exception thrown in file rename: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
9091
);
9192
return;
@@ -111,7 +112,7 @@ public function create(NodeCreatedEvent $event): void {
111112
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
112113
];
113114
} catch (InvalidPathException|NotFoundException $e) {
114-
\OCP\Server::get(LoggerInterface::class)->error(
115+
Server::get(LoggerInterface::class)->error(
115116
'Exception thrown in file create: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
116117
);
117118
return;
@@ -140,7 +141,7 @@ public function copy(NodeCopiedEvent $event): void {
140141
'newpath' => mb_substr($event->getTarget()->getInternalPath(), 5),
141142
];
142143
} catch (InvalidPathException|NotFoundException $e) {
143-
\OCP\Server::get(LoggerInterface::class)->error(
144+
Server::get(LoggerInterface::class)->error(
144145
'Exception thrown in file copy: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
145146
);
146147
return;
@@ -165,7 +166,7 @@ public function write(BeforeNodeWrittenEvent $event): void {
165166
'path' => mb_substr($node->getInternalPath(), 5),
166167
];
167168
} catch (InvalidPathException|NotFoundException $e) {
168-
\OCP\Server::get(LoggerInterface::class)->error(
169+
Server::get(LoggerInterface::class)->error(
169170
'Exception thrown in file write: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
170171
);
171172
return;
@@ -193,7 +194,7 @@ public function update(NodeWrittenEvent $event): void {
193194
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
194195
];
195196
} catch (InvalidPathException|NotFoundException $e) {
196-
\OCP\Server::get(LoggerInterface::class)->error(
197+
Server::get(LoggerInterface::class)->error(
197198
'Exception thrown in file update: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
198199
);
199200
return;
@@ -217,7 +218,7 @@ public function delete(NodeDeletedEvent $event): void {
217218
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
218219
];
219220
} catch (InvalidPathException|NotFoundException $e) {
220-
\OCP\Server::get(LoggerInterface::class)->error(
221+
Server::get(LoggerInterface::class)->error(
221222
'Exception thrown in file delete: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
222223
);
223224
return;

apps/admin_audit/lib/AppInfo/Application.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
use OCP\Share;
5858
use OCP\Share\Events\ShareCreatedEvent;
5959
use OCP\Share\Events\ShareDeletedEvent;
60+
use OCP\SystemTag\ManagerEvent;
6061
use OCP\User\Events\BeforeUserLoggedInEvent;
6162
use OCP\User\Events\BeforeUserLoggedOutEvent;
6263
use OCP\User\Events\PasswordUpdatedEvent;
@@ -157,7 +158,7 @@ private function sharingLegacyHooks(IAuditLogger $logger): void {
157158

158159
private function tagHooks(IAuditLogger $logger,
159160
IEventDispatcher $eventDispatcher): void {
160-
$eventDispatcher->addListener(\OCP\SystemTag\ManagerEvent::EVENT_CREATE, function (\OCP\SystemTag\ManagerEvent $event) use ($logger): void {
161+
$eventDispatcher->addListener(ManagerEvent::EVENT_CREATE, function (ManagerEvent $event) use ($logger): void {
161162
$tagActions = new TagManagement($logger);
162163
$tagActions->createTag($event->getTag());
163164
});

apps/admin_audit/lib/Listener/FileEventListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OCP\Files\InvalidPathException;
1616
use OCP\Files\NotFoundException;
1717
use OCP\Preview\BeforePreviewFetchedEvent;
18+
use OCP\Server;
1819
use Psr\Log\LoggerInterface;
1920

2021
/**
@@ -47,7 +48,7 @@ private function beforePreviewFetched(BeforePreviewFetchedEvent $event): void {
4748
array_keys($params)
4849
);
4950
} catch (InvalidPathException|NotFoundException $e) {
50-
\OCP\Server::get(LoggerInterface::class)->error(
51+
Server::get(LoggerInterface::class)->error(
5152
'Exception thrown in file preview: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e]
5253
);
5354
return;

apps/cloud_federation_api/lib/Controller/RequestHandlerController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use OCP\IURLGenerator;
2828
use OCP\IUserManager;
2929
use OCP\Share\Exceptions\ShareNotFound;
30+
use OCP\Util;
3031
use Psr\Log\LoggerInterface;
3132

3233
/**
@@ -276,7 +277,7 @@ public function receiveNotification($notificationType, $resourceType, $providerI
276277
private function mapUid($uid) {
277278
// FIXME this should be a method in the user management instead
278279
$this->logger->debug('shareWith before, ' . $uid, ['app' => $this->appName]);
279-
\OCP\Util::emitHook(
280+
Util::emitHook(
280281
'\OCA\Files_Sharing\API\Server2Server',
281282
'preLoginNameUsedAsUserName',
282283
['uid' => &$uid]

apps/comments/tests/Unit/Notification/ListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class ListenerTest extends TestCase {
3232
protected function setUp(): void {
3333
parent::setUp();
3434

35-
$this->notificationManager = $this->createMock(\OCP\Notification\IManager::class);
36-
$this->userManager = $this->createMock(\OCP\IUserManager::class);
35+
$this->notificationManager = $this->createMock(IManager::class);
36+
$this->userManager = $this->createMock(IUserManager::class);
3737

3838
$this->listener = new Listener(
3939
$this->notificationManager,

apps/dashboard/lib/Controller/DashboardController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
use OCA\Dashboard\Service\DashboardService;
1212
use OCP\AppFramework\Controller;
13-
use OCP\AppFramework\Http;
1413
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
1514
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
1615
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
1716
use OCP\AppFramework\Http\Attribute\OpenAPI;
17+
use OCP\AppFramework\Http\FeaturePolicy;
1818
use OCP\AppFramework\Http\TemplateResponse;
1919
use OCP\AppFramework\Services\IInitialState;
2020
use OCP\Dashboard\IIconWidget;
@@ -24,6 +24,7 @@
2424
use OCP\IConfig;
2525
use OCP\IL10N;
2626
use OCP\IRequest;
27+
use OCP\Util;
2728

2829
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
2930
class DashboardController extends Controller {
@@ -49,8 +50,8 @@ public function __construct(
4950
#[NoAdminRequired]
5051
#[FrontpageRoute(verb: 'GET', url: '/')]
5152
public function index(): TemplateResponse {
52-
\OCP\Util::addStyle('dashboard', 'dashboard');
53-
\OCP\Util::addScript('dashboard', 'main', 'theming');
53+
Util::addStyle('dashboard', 'dashboard');
54+
Util::addScript('dashboard', 'main', 'theming');
5455

5556
$widgets = array_map(function (IWidget $widget) {
5657
return [
@@ -76,7 +77,7 @@ public function index(): TemplateResponse {
7677
]);
7778

7879
// For the weather widget we should allow the geolocation
79-
$featurePolicy = new Http\FeaturePolicy();
80+
$featurePolicy = new FeaturePolicy();
8081
$featurePolicy->addAllowedGeoLocationDomain('\'self\'');
8182
$response->setFeaturePolicy($featurePolicy);
8283

apps/dav/appinfo/v1/caldav.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@
1010
use OCA\DAV\CalDAV\CalDavBackend;
1111
use OCA\DAV\CalDAV\CalendarRoot;
1212
use OCA\DAV\CalDAV\DefaultCalendarValidator;
13+
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
14+
use OCA\DAV\CalDAV\Schedule\IMipPlugin;
15+
use OCA\DAV\CalDAV\Schedule\Plugin;
1316
use OCA\DAV\CalDAV\Security\RateLimitingPlugin;
17+
use OCA\DAV\CalDAV\Sharing\Backend;
1418
use OCA\DAV\CalDAV\Validation\CalDavValidatePlugin;
1519
use OCA\DAV\Connector\LegacyDAVACL;
1620
use OCA\DAV\Connector\Sabre\Auth;
1721
use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
1822
use OCA\DAV\Connector\Sabre\MaintenancePlugin;
1923
use OCA\DAV\Connector\Sabre\Principal;
2024
use OCP\Accounts\IAccountManager;
25+
use OCP\EventDispatcher\IEventDispatcher;
26+
use OCP\IConfig;
27+
use OCP\Server;
2128
use Psr\Log\LoggerInterface;
2229

2330
$authBackend = new Auth(
@@ -35,7 +42,7 @@
3542
\OC::$server->getShareManager(),
3643
\OC::$server->getUserSession(),
3744
\OC::$server->getAppManager(),
38-
\OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class),
45+
\OC::$server->query(ProxyMapper::class),
3946
\OC::$server->get(KnownUserService::class),
4047
\OC::$server->getConfig(),
4148
\OC::$server->getL10NFactory(),
@@ -45,8 +52,8 @@
4552
$userManager = \OC::$server->getUserManager();
4653
$random = \OC::$server->getSecureRandom();
4754
$logger = \OC::$server->get(LoggerInterface::class);
48-
$dispatcher = \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class);
49-
$config = \OC::$server->get(\OCP\IConfig::class);
55+
$dispatcher = \OC::$server->get(IEventDispatcher::class);
56+
$config = \OC::$server->get(IConfig::class);
5057

5158
$calDavBackend = new CalDavBackend(
5259
$db,
@@ -56,7 +63,7 @@
5663
$logger,
5764
$dispatcher,
5865
$config,
59-
OC::$server->get(\OCA\DAV\CalDAV\Sharing\Backend::class),
66+
OC::$server->get(Backend::class),
6067
true
6168
);
6269

@@ -93,14 +100,14 @@
93100

94101
$server->addPlugin(new \Sabre\DAV\Sync\Plugin());
95102
$server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
96-
$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DefaultCalendarValidator::class)));
103+
$server->addPlugin(new Plugin(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DefaultCalendarValidator::class)));
97104

98105
if ($sendInvitations) {
99-
$server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
106+
$server->addPlugin(\OC::$server->query(IMipPlugin::class));
100107
}
101108
$server->addPlugin(new ExceptionLoggerPlugin('caldav', $logger));
102-
$server->addPlugin(\OCP\Server::get(RateLimitingPlugin::class));
103-
$server->addPlugin(\OCP\Server::get(CalDavValidatePlugin::class));
109+
$server->addPlugin(Server::get(RateLimitingPlugin::class));
110+
$server->addPlugin(Server::get(CalDavValidatePlugin::class));
104111

105112
// And off we go!
106113
$server->exec();

apps/dav/appinfo/v1/carddav.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
// Backends
99
use OC\KnownUser\KnownUserService;
1010
use OCA\DAV\AppInfo\PluginManager;
11+
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
1112
use OCA\DAV\CardDAV\AddressBookRoot;
1213
use OCA\DAV\CardDAV\CardDavBackend;
14+
use OCA\DAV\CardDAV\ImageExportPlugin;
15+
use OCA\DAV\CardDAV\PhotoCache;
1316
use OCA\DAV\CardDAV\Security\CardDavRateLimitingPlugin;
17+
use OCA\DAV\CardDAV\Sharing\Backend;
1418
use OCA\DAV\CardDAV\Validation\CardDavValidatePlugin;
1519
use OCA\DAV\Connector\LegacyDAVACL;
1620
use OCA\DAV\Connector\Sabre\Auth;
@@ -19,6 +23,9 @@
1923
use OCA\DAV\Connector\Sabre\Principal;
2024
use OCP\Accounts\IAccountManager;
2125
use OCP\App\IAppManager;
26+
use OCP\EventDispatcher\IEventDispatcher;
27+
use OCP\IGroupManager;
28+
use OCP\Server;
2229
use Psr\Log\LoggerInterface;
2330
use Sabre\CardDAV\Plugin;
2431

@@ -37,7 +44,7 @@
3744
\OC::$server->getShareManager(),
3845
\OC::$server->getUserSession(),
3946
\OC::$server->getAppManager(),
40-
\OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class),
47+
\OC::$server->query(ProxyMapper::class),
4148
\OC::$server->get(KnownUserService::class),
4249
\OC::$server->getConfig(),
4350
\OC::$server->getL10NFactory(),
@@ -48,8 +55,8 @@
4855
$db,
4956
$principalBackend,
5057
\OC::$server->getUserManager(),
51-
\OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class),
52-
\OC::$server->get(\OCA\DAV\CardDAV\Sharing\Backend::class),
58+
\OC::$server->get(IEventDispatcher::class),
59+
\OC::$server->get(Backend::class),
5360
);
5461

5562
$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);
@@ -59,7 +66,7 @@
5966
$principalCollection->disableListing = !$debugging; // Disable listing
6067

6168
$pluginManager = new PluginManager(\OC::$server, \OC::$server->query(IAppManager::class));
62-
$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, $pluginManager, \OC::$server->getUserSession()->getUser(), \OC::$server->get(\OCP\IGroupManager::class));
69+
$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, $pluginManager, \OC::$server->getUserSession()->getUser(), \OC::$server->get(IGroupManager::class));
6370
$addressBookRoot->disableListing = !$debugging; // Disable listing
6471

6572
$nodes = [
@@ -84,13 +91,13 @@
8491

8592
$server->addPlugin(new \Sabre\DAV\Sync\Plugin());
8693
$server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
87-
$server->addPlugin(new \OCA\DAV\CardDAV\ImageExportPlugin(new \OCA\DAV\CardDAV\PhotoCache(
94+
$server->addPlugin(new ImageExportPlugin(new PhotoCache(
8895
\OC::$server->getAppDataDir('dav-photocache'),
8996
\OC::$server->get(LoggerInterface::class)
9097
)));
9198
$server->addPlugin(new ExceptionLoggerPlugin('carddav', \OC::$server->get(LoggerInterface::class)));
92-
$server->addPlugin(\OCP\Server::get(CardDavRateLimitingPlugin::class));
93-
$server->addPlugin(\OCP\Server::get(CardDavValidatePlugin::class));
99+
$server->addPlugin(Server::get(CardDavRateLimitingPlugin::class));
100+
$server->addPlugin(Server::get(CardDavValidatePlugin::class));
94101

95102
// And off we go!
96103
$server->exec();

0 commit comments

Comments
 (0)