diff --git a/apps/dav/appinfo/v1/carddav.php b/apps/dav/appinfo/v1/carddav.php
index 5fe9f93d8b542..d883bae450bbb 100644
--- a/apps/dav/appinfo/v1/carddav.php
+++ b/apps/dav/appinfo/v1/carddav.php
@@ -89,7 +89,7 @@
/** @var string $baseuri defined in remote.php */
$server->setBaseUri($baseuri);
// Add plugins
-$server->addPlugin(new MaintenancePlugin(Server::get(IConfig::class), \OCP\Server::get(IL10nFactory::class)->get('dav')));
+$server->addPlugin(new MaintenancePlugin(Server::get(IConfig::class), Server::get(IL10nFactory::class)->get('dav')));
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend));
$server->addPlugin(new Plugin());
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index f4e8ee1d99a77..d0bde46e96de3 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -532,7 +532,7 @@ public function getNodeForPath($path): INode {
}
if ($info->getMimeType() === FileInfo::MIMETYPE_FOLDER) {
- $node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this->tree, $this->shareManager);
+ $node = new Directory($this->fileView, $info, $this->tree, $this->shareManager);
} else {
// In case reading a directory was allowed but it turns out the node was a not a directory, reject it now.
if (!$this->info->isReadable()) {
diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipServiceTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipServiceTest.php
index 7d58930f0700b..5f9d6adfa737b 100644
--- a/apps/dav/tests/unit/CalDAV/Schedule/IMipServiceTest.php
+++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipServiceTest.php
@@ -17,6 +17,7 @@
use OCP\IAppConfig;
use OCP\IDBConnection;
use OCP\IL10N;
+use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
@@ -163,7 +164,7 @@ public function testGetFrom(): void {
public function testIsSystemUserWhenUserExists(): void {
$email = 'user@example.com';
- $user = $this->createMock(\OCP\IUser::class);
+ $user = $this->createMock(IUser::class);
$this->userManager->expects(self::once())
->method('getByEmail')
diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
index 896f36f12536d..8f501d684415b 100644
--- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
@@ -55,7 +55,7 @@ public static function davPermissionsProvider(): array {
public function testDavPermissions(int $permissions, string $type, bool $shared, int $shareRootPermissions, bool $mounted, string $internalPath, string $expected): void {
$info = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()
- ->onlyMethods(['getPermissions', 'isShared', 'isMounted', 'getType', 'getInternalPath', 'getStorage', 'getMountPoint'])
+ ->onlyMethods(['getPermissions', 'isShared', 'isMounted', 'getType', 'getInternalPath', 'getStorage', 'getMountPoint', 'getPath'])
->getMock();
$info->method('getPermissions')
->willReturn($permissions);
@@ -65,6 +65,8 @@ public function testDavPermissions(int $permissions, string $type, bool $shared,
->willReturn($mounted);
$info->method('getType')
->willReturn($type);
+ $info->method('getPath')
+ ->willReturn('');
$info->method('getInternalPath')
->willReturn($internalPath);
$info->method('getMountPoint')
@@ -160,18 +162,18 @@ public function testSharePermissions(string $type, ?string $user, int $permissio
$info = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()
- ->onlyMethods(['getStorage', 'getType', 'getMountPoint', 'getPermissions'])
+ ->onlyMethods(['getStorage', 'getType', 'getMountPoint', 'getPermissions', 'getPath'])
->getMock();
$info->method('getStorage')->willReturn($storage);
+ $info->method('getPath')->willReturn('notMyPath');
$info->method('getType')->willReturn($type);
$info->method('getMountPoint')->willReturn($mountpoint);
$info->method('getPermissions')->willReturn($permissions);
$view = $this->createMock(View::class);
- $node = new File($view, $info);
- $this->invokePrivate($node, 'shareManager', [$shareManager]);
+ $node = new File($view, $info, $shareManager);
$this->assertEquals($expected, $node->getSharePermissions($user));
}
@@ -196,9 +198,10 @@ public function testShareAttributes(): void {
/** @var Folder&MockObject $info */
$info = $this->getMockBuilder(Folder::class)
->disableOriginalConstructor()
- ->onlyMethods(['getStorage', 'getType'])
+ ->onlyMethods(['getStorage', 'getType', 'getPath'])
->getMock();
+ $info->method('getPath')->willReturn('myPath');
$info->method('getStorage')->willReturn($storage);
$info->method('getType')->willReturn(FileInfo::TYPE_FOLDER);
@@ -217,9 +220,10 @@ public function testShareAttributesNonShare(): void {
/** @var Folder&MockObject */
$info = $this->getMockBuilder(Folder::class)
->disableOriginalConstructor()
- ->onlyMethods(['getStorage', 'getType'])
+ ->onlyMethods(['getStorage', 'getType', 'getPath'])
->getMock();
+ $info->method('getPath')->willReturn('myPath');
$info->method('getStorage')->willReturn($storage);
$info->method('getType')->willReturn(FileInfo::TYPE_FOLDER);
diff --git a/apps/federatedfilesharing/lib/AppInfo/Application.php b/apps/federatedfilesharing/lib/AppInfo/Application.php
index b77c76acf5ac6..ca22ce2cbc649 100644
--- a/apps/federatedfilesharing/lib/AppInfo/Application.php
+++ b/apps/federatedfilesharing/lib/AppInfo/Application.php
@@ -17,6 +17,7 @@
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Federation\ICloudFederationProviderManager;
+use OCP\Server;
class Application extends App implements IBootstrap {
@@ -41,7 +42,7 @@ private function registerCloudFederationProvider(ICloudFederationProviderManager
$manager->addCloudFederationProvider($type,
'Federated Files Sharing',
function (): CloudFederationProviderFiles {
- return \OCP\Server::get(CloudFederationProviderFiles::class);
+ return Server::get(CloudFederationProviderFiles::class);
});
}
}
diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php
index e66f1a1e41781..20b7ca62ad00d 100644
--- a/apps/federatedfilesharing/lib/Settings/Admin.php
+++ b/apps/federatedfilesharing/lib/Settings/Admin.php
@@ -14,6 +14,7 @@
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\IDelegatedSettings;
+use OCP\Util;
class Admin implements IDelegatedSettings {
/**
@@ -44,8 +45,8 @@ public function getForm() {
$this->initialState->provideInitialState('lookupServerUploadEnabled', $this->fedShareProvider->isLookupServerUploadEnabled());
$this->initialState->provideInitialState('federatedTrustedShareAutoAccept', $this->fedShareProvider->isFederatedTrustedShareAutoAccept());
- \OCP\Util::addStyle(Application::APP_ID, 'settings-admin');
- \OCP\Util::addScript(Application::APP_ID, 'settings-admin');
+ Util::addStyle(Application::APP_ID, 'settings-admin');
+ Util::addScript(Application::APP_ID, 'settings-admin');
return new TemplateResponse(Application::APP_ID, 'settings-admin', renderAs: '');
}
diff --git a/apps/federatedfilesharing/lib/Settings/Personal.php b/apps/federatedfilesharing/lib/Settings/Personal.php
index fc401c404d421..01239fbe14084 100644
--- a/apps/federatedfilesharing/lib/Settings/Personal.php
+++ b/apps/federatedfilesharing/lib/Settings/Personal.php
@@ -16,6 +16,7 @@
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\Settings\ISettings;
+use OCP\Util;
class Personal implements ISettings {
public function __construct(
@@ -42,8 +43,8 @@ public function getForm(): TemplateResponse {
$this->initialState->provideInitialState('cloudId', $cloudID);
$this->initialState->provideInitialState('docUrlFederated', $this->urlGenerator->linkToDocs('user-sharing-federated'));
- \OCP\Util::addStyle(Application::APP_ID, 'settings-personal');
- \OCP\Util::addScript(Application::APP_ID, 'settings-personal');
+ Util::addStyle(Application::APP_ID, 'settings-personal');
+ Util::addScript(Application::APP_ID, 'settings-personal');
return new TemplateResponse(Application::APP_ID, 'settings-personal', renderAs: TemplateResponse::RENDER_AS_BLANK);
}
diff --git a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
index 8f16107377182..e4bc42e8d4c33 100644
--- a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
+++ b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
@@ -39,10 +39,7 @@ public function __construct(
]);
}
- /**
- * @return void
- */
- public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
+ public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null): void {
try {
$credentials = $this->credentialsStore->getLoginCredentials();
} catch (CredentialsUnavailableException $e) {
diff --git a/apps/files_external/lib/Lib/SessionStorageWrapper.php b/apps/files_external/lib/Lib/SessionStorageWrapper.php
index 8754041b2fa39..2d35358601ad6 100644
--- a/apps/files_external/lib/Lib/SessionStorageWrapper.php
+++ b/apps/files_external/lib/Lib/SessionStorageWrapper.php
@@ -9,13 +9,15 @@
use OC\Files\Storage\Wrapper\PermissionsMask;
use OCP\Constants;
+use OCP\Files\Storage;
+use OCP\Files\Storage\IStorage;
/**
* Wrap Storage in PermissionsMask for session ephemeral use
*/
class SessionStorageWrapper extends PermissionsMask {
/**
- * @param array $parameters ['storage' => $storage]
+ * @param array{storage: IStorage} $parameters
*/
public function __construct(array $parameters) {
// disable sharing permission
diff --git a/apps/files_external/tests/Settings/AdminTest.php b/apps/files_external/tests/Settings/AdminTest.php
index b8524b5fc2a68..07f4e2df2b4c9 100644
--- a/apps/files_external/tests/Settings/AdminTest.php
+++ b/apps/files_external/tests/Settings/AdminTest.php
@@ -85,7 +85,7 @@ public function testGetForm(): void {
$this->initialState
->expects($this->atLeastOnce())
->method('provideInitialState')
- ->willReturnCallback(function () use (&$initialState) {
+ ->willReturnCallback(function () use (&$initialState): void {
$args = func_get_args();
$initialState[$args[0]] = $args[1];
});
diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
index e7ddab8a40bf2..42105dca1333c 100644
--- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
@@ -8,6 +8,7 @@
*/
namespace OCA\Files_Sharing\Controller;
+use OCA\Deck\Sharing\ShareAPIHelper;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
@@ -204,12 +205,12 @@ private function getRoomShareHelper(): \OCA\Talk\Share\Helper\DeletedShareAPICon
* @psalm-suppress UndefinedClass
* @throws ContainerExceptionInterface
*/
- private function getDeckShareHelper(): \OCA\Deck\Sharing\ShareAPIHelper {
+ private function getDeckShareHelper(): ShareAPIHelper {
if (!$this->appManager->isEnabledForUser('deck')) {
throw new QueryException();
}
/** @psalm-suppress UndefinedClass */
- return Server::get(\OCA\Deck\Sharing\ShareAPIHelper::class);
+ return Server::get(ShareAPIHelper::class);
}
}
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index aeaaa54f3708d..6204d150fc0b2 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -70,7 +70,7 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage
private LoggerInterface $logger;
- /** @var IStorage */
+ /** @var Storage */
private $nonMaskedStorage;
private array $mountOptions = [];
@@ -85,12 +85,6 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage
private static int $initDepth = 0;
- /**
- * @psalm-suppress NonInvariantDocblockPropertyType
- * @var ?Storage $storage
- */
- protected $storage;
-
public function __construct(array $parameters) {
$this->ownerView = $parameters['ownerView'];
$this->logger = Server::get(LoggerInterface::class);
@@ -105,6 +99,7 @@ public function __construct(array $parameters) {
$this->sharingDisabledForUser = false;
}
+ /** @psalm-suppress InvalidArgument This is fine as we also overwrite getWrappedStorage */
parent::__construct([
'storage' => null,
'root' => null,
@@ -129,7 +124,7 @@ private function getSourceRootInfo() {
/**
* @psalm-assert Storage $this->storage
*/
- private function init() {
+ private function init(): void {
if ($this->initialized) {
if (!$this->storage) {
// marked as initialized but no storage set
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index 8d1e13556e9c0..d578e14238672 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -16,6 +16,7 @@
use OC\Files\View;
use OC\User\NoUserException;
use OC_User;
+use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Trashbin\Command\Expire;
use OCA\Files_Trashbin\Events\BeforeNodeRestoredEvent;
use OCA\Files_Trashbin\Events\NodeRestoredEvent;
@@ -1194,7 +1195,7 @@ private static function overwriteDeletedBy(string $user) {
return $user;
}
- $federatedShareProvider = Server::get(\OCA\FederatedFileSharing\FederatedShareProvider::class);
+ $federatedShareProvider = Server::get(FederatedShareProvider::class);
$share = $federatedShareProvider->getShareByToken($token);
return $share->getSharedWith();
diff --git a/apps/oauth2/lib/Settings/Admin.php b/apps/oauth2/lib/Settings/Admin.php
index e707a263b40dd..b843b31af1701 100644
--- a/apps/oauth2/lib/Settings/Admin.php
+++ b/apps/oauth2/lib/Settings/Admin.php
@@ -13,6 +13,7 @@
use OCP\AppFramework\Services\IInitialState;
use OCP\IURLGenerator;
use OCP\Settings\ISettings;
+use OCP\Util;
use Psr\Log\LoggerInterface;
class Admin implements ISettings {
@@ -45,8 +46,8 @@ public function getForm(): TemplateResponse {
$this->initialState->provideInitialState('clients', $result);
$this->initialState->provideInitialState('oauth2-doc-link', $this->urlGenerator->linkToDocs('admin-oauth2'));
- \OCP\Util::addStyle('oauth2', 'settings-admin');
- \OCP\Util::addScript('oauth2', 'settings-admin', 'core');
+ Util::addStyle('oauth2', 'settings-admin');
+ Util::addScript('oauth2', 'settings-admin', 'core');
return new TemplateResponse(
'oauth2',
'admin',
diff --git a/apps/settings/tests/Controller/AdminSettingsControllerTest.php b/apps/settings/tests/Controller/AdminSettingsControllerTest.php
index 7ac0b73e37a17..ce4f983bbbd79 100644
--- a/apps/settings/tests/Controller/AdminSettingsControllerTest.php
+++ b/apps/settings/tests/Controller/AdminSettingsControllerTest.php
@@ -125,7 +125,7 @@ public function testIndex(): void {
$initialState = [];
$this->initialState->expects(self::atLeastOnce())
->method('provideInitialState')
- ->willReturnCallback(function () use (&$initialState) {
+ ->willReturnCallback(function () use (&$initialState): void {
$initialState[] = func_get_args();
});
diff --git a/apps/settings/tests/Integration/DuplicateAssignmentIntegrationTest.php b/apps/settings/tests/Integration/DuplicateAssignmentIntegrationTest.php
index 281e6335ee913..43ba37c5d0756 100644
--- a/apps/settings/tests/Integration/DuplicateAssignmentIntegrationTest.php
+++ b/apps/settings/tests/Integration/DuplicateAssignmentIntegrationTest.php
@@ -10,7 +10,9 @@
use OC\Settings\AuthorizedGroupMapper;
use OCA\Settings\Service\AuthorizedGroupService;
use OCA\Settings\Service\ConflictException;
+use OCA\Settings\Service\NotFoundException;
use OCP\AppFramework\Db\DoesNotExistException;
+use OCP\Server;
use Test\TestCase;
/**
@@ -27,7 +29,7 @@ protected function setUp(): void {
parent::setUp();
// Use real mapper for integration testing
- $this->mapper = \OCP\Server::get(AuthorizedGroupMapper::class);
+ $this->mapper = Server::get(AuthorizedGroupMapper::class);
$this->service = new AuthorizedGroupService($this->mapper);
}
@@ -109,10 +111,10 @@ public function testCreateAfterDelete(): void {
$this->service->delete($initialId);
// Verify it's deleted by trying to find it
- $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
+ $this->expectException(DoesNotExistException::class);
try {
$this->service->find($initialId);
- } catch (\OCA\Settings\Service\NotFoundException $e) {
+ } catch (NotFoundException $e) {
// Expected - now create the same assignment again, which should succeed
$result2 = $this->service->create($groupId, $class);
diff --git a/apps/settings/tests/Service/AuthorizedGroupServiceTest.php b/apps/settings/tests/Service/AuthorizedGroupServiceTest.php
index f8a3c5c0e47ee..9d8ca16f94eb7 100644
--- a/apps/settings/tests/Service/AuthorizedGroupServiceTest.php
+++ b/apps/settings/tests/Service/AuthorizedGroupServiceTest.php
@@ -88,7 +88,7 @@ public function testCreateAllowsDifferentGroupsSameClass(): void {
// Mock that no duplicate exists for group1
$this->mapper->expects($this->exactly(2))
->method('findByGroupIdAndClass')
- ->willReturnCallback(function ($groupId, $classArg) use ($groupId1, $groupId2, $class) {
+ ->willReturnCallback(function ($groupId, $classArg) use ($groupId1, $groupId2, $class): void {
$this->assertContains($groupId, [$groupId1, $groupId2]);
$this->assertEquals($class, $classArg);
throw new DoesNotExistException('Not found');
@@ -126,7 +126,7 @@ public function testCreateAllowsSameGroupDifferentClasses(): void {
// Mock that no duplicate exists for either class
$this->mapper->expects($this->exactly(2))
->method('findByGroupIdAndClass')
- ->willReturnCallback(function ($groupIdArg, $class) use ($groupId, $class1, $class2) {
+ ->willReturnCallback(function ($groupIdArg, $class) use ($groupId, $class1, $class2): void {
$this->assertEquals($groupId, $groupIdArg);
$this->assertContains($class, [$class1, $class2]);
throw new DoesNotExistException('Not found');
diff --git a/apps/user_ldap/lib/Settings/Admin.php b/apps/user_ldap/lib/Settings/Admin.php
index e1410441292ed..aab8fcfeccfc9 100644
--- a/apps/user_ldap/lib/Settings/Admin.php
+++ b/apps/user_ldap/lib/Settings/Admin.php
@@ -15,6 +15,7 @@
use OCP\Server;
use OCP\Settings\IDelegatedSettings;
use OCP\Template\ITemplateManager;
+use OCP\Util;
class Admin implements IDelegatedSettings {
public function __construct(
@@ -60,8 +61,8 @@ public function getForm(): TemplateResponse {
$this->initialState->provideInitialState('ldapConfigs', $ldapConfigs);
$this->initialState->provideInitialState('ldapModuleInstalled', function_exists('ldap_connect'));
- \OCP\Util::addStyle(Application::APP_ID, 'settings-admin');
- \OCP\Util::addScript(Application::APP_ID, 'settings-admin');
+ Util::addStyle(Application::APP_ID, 'settings-admin');
+ Util::addScript(Application::APP_ID, 'settings-admin');
return new TemplateResponse(Application::APP_ID, 'settings', $parameters);
}
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index 04c44c1d9b9c9..9c807a512f44c 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -3641,22 +3641,6 @@
fileInfo]]>
-
-
-
- mountManager->findByNumericId($numericId)]]>
- mountManager->findByStorageId($storageId)]]>
- mountManager->findIn($mountPoint)]]>
-
-
-
-
-
-
-
-
-
-
diff --git a/core/Controller/ContactsMenuController.php b/core/Controller/ContactsMenuController.php
index b3cb7de78816c..7224b124122ef 100644
--- a/core/Controller/ContactsMenuController.php
+++ b/core/Controller/ContactsMenuController.php
@@ -8,6 +8,7 @@
use Exception;
use OC\Contacts\ContactsMenu\Manager;
+use OC\Teams\TeamManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
@@ -37,7 +38,7 @@ public function __construct(
public function index(?string $filter = null, ?string $teamId = null): array {
$entries = $this->manager->getEntries($this->userSession->getUser(), $filter);
if ($teamId !== null) {
- /** @var \OC\Teams\TeamManager */
+ /** @var TeamManager */
$teamManager = $this->teamManager;
$memberIds = $teamManager->getMembersOfTeam($teamId, $this->userSession->getUser()->getUID());
$entries['contacts'] = array_filter(
diff --git a/core/Controller/OpenMetricsController.php b/core/Controller/OpenMetricsController.php
index 8c57eb1a66335..c6e6c1673aa73 100644
--- a/core/Controller/OpenMetricsController.php
+++ b/core/Controller/OpenMetricsController.php
@@ -15,6 +15,8 @@
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
+use OCP\AppFramework\Http\Response;
+use OCP\AppFramework\Http\StreamTraversableResponse;
use OCP\IConfig;
use OCP\IRequest;
use OCP\OpenMetrics\IMetricFamily;
@@ -44,12 +46,12 @@ public function __construct(
#[NoCSRFRequired]
#[PublicPage]
#[FrontpageRoute(verb: 'GET', url: '/metrics')]
- public function export(): Http\Response {
+ public function export(): Response {
if (!$this->isRemoteAddressAllowed()) {
- return new Http\Response(Http::STATUS_FORBIDDEN);
+ return new Response(Http::STATUS_FORBIDDEN);
}
- return new Http\StreamTraversableResponse(
+ return new StreamTraversableResponse(
$this->generate(),
Http::STATUS_OK,
[
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php
index 258c88f56f87b..4ea5ce84d142e 100644
--- a/lib/private/AppFramework/DependencyInjection/DIContainer.php
+++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php
@@ -38,6 +38,7 @@
use OC\AppFramework\Services\InitialState;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OC\AppFramework\Utility\SimpleContainer;
+use OC\CapabilitiesManager;
use OC\Core\Middleware\TwoFactorMiddleware;
use OC\Diagnostics\EventLogger;
use OC\Log\PsrLoggerAdapter;
@@ -305,7 +306,7 @@ private function getUserId(): string {
* @param string $serviceName e.g. 'OCA\Files\Capabilities'
*/
public function registerCapability($serviceName) {
- $this->query(\OC\CapabilitiesManager::class)->registerCapability(function () use ($serviceName) {
+ $this->query(CapabilitiesManager::class)->registerCapability(function () use ($serviceName) {
return $this->query($serviceName);
});
}
diff --git a/lib/private/Cache/File.php b/lib/private/Cache/File.php
index 82afdd4ce3e8b..d9a3e5e8b6331 100644
--- a/lib/private/Cache/File.php
+++ b/lib/private/Cache/File.php
@@ -13,6 +13,7 @@
use OC\User\NoUserException;
use OCP\Files\LockNotAcquiredException;
use OCP\ICache;
+use OCP\IConfig;
use OCP\IUserSession;
use OCP\Lock\LockedException;
use OCP\Security\ISecureRandom;
@@ -161,7 +162,7 @@ public function clear($prefix = '') {
public function gc() {
$storage = $this->getStorage();
if ($storage) {
- $ttl = \OC::$server->getConfig()->getSystemValueInt('cache_chunk_gc_ttl', 60 * 60 * 24);
+ $ttl = Server::get(IConfig::class)->getSystemValueInt('cache_chunk_gc_ttl', 60 * 60 * 24);
$now = time() - $ttl;
$dh = $storage->opendir('/');
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index cfadf7ed4ec89..2c36b40344b34 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -27,6 +27,7 @@
use OCP\Files\Cache\CacheUpdateEvent;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
+use OCP\Files\Config\IUserMountCache;
use OCP\Files\FileInfo;
use OCP\Files\IMimeTypeLoader;
use OCP\Files\Search\ISearchComparison;
@@ -825,7 +826,7 @@ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
$this->connection->commit();
if ($sourceCache->getNumericStorageId() !== $this->getNumericStorageId()) {
- \OCP\Server::get(\OCP\Files\Config\IUserMountCache::class)->clear();
+ Server::get(IUserMountCache::class)->clear();
$event = new CacheEntryRemovedEvent($this->storage, $sourcePath, $sourceId, $sourceCache->getNumericStorageId());
$this->eventDispatcher->dispatchTyped($event);
diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php
index 967d404b8a4f0..d9fa2a03071be 100644
--- a/lib/private/Files/FileInfo.php
+++ b/lib/private/Files/FileInfo.php
@@ -10,36 +10,16 @@
use OC\Files\Mount\HomeMountPoint;
use OCA\Files_Sharing\External\Mount;
use OCA\Files_Sharing\ISharedMountPoint;
+use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Mount\IMountPoint;
+use OCP\Files\Storage\IStorage;
use OCP\IUser;
/**
* @template-implements \ArrayAccess
*/
class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
- private array|ICacheEntry $data;
- /**
- * @var string
- */
- private $path;
-
- /**
- * @var \OC\Files\Storage\Storage $storage
- */
- private $storage;
-
- /**
- * @var string
- */
- private $internalPath;
-
- /**
- * @var \OCP\Files\Mount\IMountPoint
- */
- private $mount;
-
- private ?IUser $owner;
/**
* @var string[]
@@ -59,20 +39,18 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
private int|float $rawSize = 0;
/**
- * @param string|boolean $path
- * @param Storage\Storage $storage
* @param string $internalPath
- * @param array|ICacheEntry $data
+ * @param IStorage $storage
* @param IMountPoint $mount
- * @param ?IUser $owner
*/
- public function __construct($path, $storage, $internalPath, $data, $mount, $owner = null) {
- $this->path = $path;
- $this->storage = $storage;
- $this->internalPath = $internalPath;
- $this->data = $data;
- $this->mount = $mount;
- $this->owner = $owner;
+ public function __construct(
+ private string $path,
+ private $storage,
+ private $internalPath,
+ private array|ICacheEntry $data,
+ private $mount,
+ private ?IUser $owner = null,
+ ) {
if (isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] !== 0) {
$this->rawSize = $this->data['unencrypted_size'];
} else {
@@ -106,13 +84,13 @@ public function offsetGet(mixed $offset): mixed {
};
}
- /**
- * @return string
- */
- public function getPath() {
+ public function getPath(): string {
return $this->path;
}
+ /**
+ * @return IStorage
+ */
public function getStorage() {
return $this->storage;
}
@@ -239,14 +217,14 @@ protected function checkPermissions($permissions) {
* @return bool
*/
public function isReadable() {
- return $this->checkPermissions(\OCP\Constants::PERMISSION_READ);
+ return $this->checkPermissions(Constants::PERMISSION_READ);
}
/**
* @return bool
*/
public function isUpdateable() {
- return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE);
+ return $this->checkPermissions(Constants::PERMISSION_UPDATE);
}
/**
@@ -255,21 +233,21 @@ public function isUpdateable() {
* @return bool
*/
public function isCreatable() {
- return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE);
+ return $this->checkPermissions(Constants::PERMISSION_CREATE);
}
/**
* @return bool
*/
public function isDeletable() {
- return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE);
+ return $this->checkPermissions(Constants::PERMISSION_DELETE);
}
/**
* @return bool
*/
public function isShareable() {
- return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE);
+ return $this->checkPermissions(Constants::PERMISSION_SHARE);
}
/**
@@ -289,7 +267,7 @@ public function isMounted() {
/**
* Get the mountpoint the file belongs to
*
- * @return \OCP\Files\Mount\IMountPoint
+ * @return IMountPoint
*/
public function getMountPoint() {
return $this->mount;
diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php
index eb6411d7d137c..86c77b478f5e8 100644
--- a/lib/private/Files/Node/File.php
+++ b/lib/private/Files/Node/File.php
@@ -7,6 +7,7 @@
*/
namespace OC\Files\Node;
+use OCP\Constants;
use OCP\Files\GenericFileException;
use OCP\Files\NotPermittedException;
use OCP\Lock\LockedException;
@@ -18,7 +19,7 @@ class File extends Node implements \OCP\Files\File {
* @param string $path path
* @return NonExistingFile non-existing node
*/
- protected function createNonExistingNode($path) {
+ protected function createNonExistingNode(string $path): NonExistingFile {
return new NonExistingFile($this->root, $this->view, $path);
}
@@ -29,7 +30,7 @@ protected function createNonExistingNode($path) {
* @throws LockedException
*/
public function getContent() {
- if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) {
+ if ($this->checkPermissions(Constants::PERMISSION_READ)) {
$content = $this->view->file_get_contents($this->path);
if ($content === false) {
throw new GenericFileException();
@@ -47,7 +48,7 @@ public function getContent() {
* @throws LockedException
*/
public function putContent($data) {
- if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) {
+ if ($this->checkPermissions(Constants::PERMISSION_UPDATE)) {
$this->sendHooks(['preWrite']);
if ($this->view->file_put_contents($this->path, $data) === false) {
throw new GenericFileException('file_put_contents failed');
@@ -68,7 +69,7 @@ public function putContent($data) {
public function fopen($mode) {
$preHooks = [];
$postHooks = [];
- $requiredPermissions = \OCP\Constants::PERMISSION_READ;
+ $requiredPermissions = Constants::PERMISSION_READ;
switch ($mode) {
case 'r+':
case 'rb+':
@@ -86,7 +87,7 @@ public function fopen($mode) {
case 'ab':
$preHooks[] = 'preWrite';
$postHooks[] = 'postWrite';
- $requiredPermissions |= \OCP\Constants::PERMISSION_UPDATE;
+ $requiredPermissions |= Constants::PERMISSION_UPDATE;
break;
}
@@ -106,7 +107,7 @@ public function fopen($mode) {
* @throws \OCP\Files\NotFoundException
*/
public function delete() {
- if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) {
+ if ($this->checkPermissions(Constants::PERMISSION_DELETE)) {
$this->sendHooks(['preDelete']);
$fileInfo = $this->getFileInfo();
$this->view->unlink($this->path);
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php
index fef0d634f0562..d51f1ea8f3ac5 100644
--- a/lib/private/Files/Node/Folder.php
+++ b/lib/private/Files/Node/Folder.php
@@ -14,6 +14,7 @@
use OC\Files\Search\SearchQuery;
use OC\Files\Utils\PathHelper;
use OC\User\LazyUser;
+use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\FileInfo;
use OCP\Files\Folder as IFolder;
@@ -26,7 +27,9 @@
use OCP\Files\Search\ISearchOperator;
use OCP\Files\Search\ISearchOrder;
use OCP\Files\Search\ISearchQuery;
+use OCP\IConfig;
use OCP\IUserManager;
+use OCP\Server;
use Override;
class Folder extends Node implements IFolder {
@@ -35,13 +38,8 @@ class Folder extends Node implements IFolder {
private bool $wasDeleted = false;
- /**
- * Creates a Folder that represents a non-existing path
- *
- * @param string $path path
- * @return NonExistingFolder non-existing node
- */
- protected function createNonExistingNode($path) {
+ #[Override]
+ protected function createNonExistingNode(string $path): NonExistingFolder {
return new NonExistingFolder($this->root, $this->view, $path);
}
@@ -127,7 +125,7 @@ public function nodeExists($path) {
* @throws \OCP\Files\NotPermittedException
*/
public function newFolder($path) {
- if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) {
+ if ($this->checkPermissions(Constants::PERMISSION_CREATE)) {
$fullPath = $this->getFullPath($path);
$nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath);
$this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]);
@@ -159,15 +157,14 @@ public function newFolder($path) {
/**
* @param string $path
* @param string | resource | null $content
- * @return \OC\Files\Node\File
* @throws \OCP\Files\NotPermittedException
*/
- public function newFile($path, $content = null) {
+ public function newFile($path, $content = null): File {
if ($path === '') {
throw new NotPermittedException('Could not create as provided path is empty');
}
$this->recreateIfNeeded();
- if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) {
+ if ($this->checkPermissions(Constants::PERMISSION_CREATE)) {
$fullPath = $this->getFullPath($path);
$nonExisting = new NonExistingFile($this->root, $this->view, $fullPath);
$this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]);
@@ -191,7 +188,7 @@ private function queryFromOperator(ISearchOperator $operator, ?string $uid = nul
$user = null;
} else {
/** @var IUserManager $userManager */
- $userManager = \OCP\Server::get(IUserManager::class);
+ $userManager = Server::get(IUserManager::class);
$user = $userManager->get($uid);
}
return new SearchQuery($operator, $limit, $offset, [], $user);
@@ -217,7 +214,7 @@ public function search($query) {
}
/** @var QuerySearchHelper $searchHelper */
- $searchHelper = \OC::$server->get(QuerySearchHelper::class);
+ $searchHelper = Server::get(QuerySearchHelper::class);
[$caches, $mountByMountPoint] = $searchHelper->getCachesAndMountPointsForSearch($this->root, $this->path, $limitToHome);
$resultsPerCache = $searchHelper->searchInCaches($query, $caches);
@@ -264,7 +261,7 @@ private function cacheEntryToFileInfo(IMountPoint $mount, string $appendRoot, IC
if ($ownerId !== false) {
// Cache the user manager (for performance)
if ($this->userManager === null) {
- $this->userManager = \OCP\Server::get(IUserManager::class);
+ $this->userManager = Server::get(IUserManager::class);
}
$owner = new LazyUser($ownerId, $this->userManager);
}
@@ -319,12 +316,12 @@ public function getById($id) {
return $this->root->getByIdInPath((int)$id, $this->getPath());
}
- public function getFirstNodeById(int $id): ?\OCP\Files\Node {
+ public function getFirstNodeById(int $id): ?INode {
return $this->root->getFirstNodeByIdInPath($id, $this->getPath());
}
public function getAppDataDirectoryName(): string {
- $instanceId = \OC::$server->getConfig()->getSystemValueString('instanceid');
+ $instanceId = Server::get(IConfig::class)->getSystemValueString('instanceid');
return 'appdata_' . $instanceId;
}
@@ -337,8 +334,7 @@ public function getAppDataDirectoryName(): string {
* the id. If it does we check if the path is inside the path we are working
* in.
*
- * @param int $id
- * @return array
+ * @return list
*/
protected function getByIdInRootMount(int $id): array {
if (!method_exists($this->root, 'createNode')) {
@@ -376,7 +372,7 @@ public function getFreeSpace() {
}
public function delete() {
- if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) {
+ if ($this->checkPermissions(Constants::PERMISSION_DELETE)) {
$this->sendHooks(['preDelete']);
$fileInfo = $this->getFileInfo();
$this->view->rmdir($this->path);
diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php
index 50b441ebc6903..4f2b5ab85bd3a 100644
--- a/lib/private/Files/Node/LazyFolder.php
+++ b/lib/private/Files/Node/LazyFolder.php
@@ -13,6 +13,7 @@
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
+use OCP\Files\Node;
use OCP\Files\NotPermittedException;
use Override;
@@ -25,21 +26,17 @@
* @package OC\Files\Node
*/
class LazyFolder implements Folder {
- /** @var \Closure(): Folder */
- private \Closure $folderClosure;
protected ?Folder $folder = null;
- protected IRootFolder $rootFolder;
- protected array $data;
/**
- * @param IRootFolder $rootFolder
* @param \Closure(): Folder $folderClosure
* @param array $data
*/
- public function __construct(IRootFolder $rootFolder, \Closure $folderClosure, array $data = []) {
- $this->rootFolder = $rootFolder;
- $this->folderClosure = $folderClosure;
- $this->data = $data;
+ public function __construct(
+ protected IRootFolder $rootFolder,
+ private \Closure $folderClosure,
+ protected array $data = [],
+ ) {
}
protected function getRootFolder(): IRootFolder {
@@ -472,7 +469,7 @@ public function getById($id) {
return $this->getRootFolder()->getByIdInPath((int)$id, $this->getPath());
}
- public function getFirstNodeById(int $id): ?\OCP\Files\Node {
+ public function getFirstNodeById(int $id): ?Node {
return $this->getRootFolder()->getFirstNodeByIdInPath($id, $this->getPath());
}
diff --git a/lib/private/Files/Node/LazyRoot.php b/lib/private/Files/Node/LazyRoot.php
index bc3f3a2e80f38..8920a2f68f67e 100644
--- a/lib/private/Files/Node/LazyRoot.php
+++ b/lib/private/Files/Node/LazyRoot.php
@@ -10,7 +10,6 @@
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
-use OCP\Files\Node;
use OCP\Files\Node as INode;
/**
@@ -42,7 +41,7 @@ public function getByIdInPath(int $id, string $path) {
return $this->__call(__FUNCTION__, func_get_args());
}
- public function getFirstNodeByIdInPath(int $id, string $path): ?Node {
+ public function getFirstNodeByIdInPath(int $id, string $path): ?INode {
return $this->__call(__FUNCTION__, func_get_args());
}
diff --git a/lib/private/Files/Node/LazyUserFolder.php b/lib/private/Files/Node/LazyUserFolder.php
index d7afb199b913f..5ac74e2705e21 100644
--- a/lib/private/Files/Node/LazyUserFolder.php
+++ b/lib/private/Files/Node/LazyUserFolder.php
@@ -16,6 +16,7 @@
use OCP\Files\Mount\IMountManager;
use OCP\Files\NotFoundException;
use OCP\IUser;
+use OCP\Server;
use Psr\Log\LoggerInterface;
class LazyUserFolder extends LazyFolder {
@@ -48,7 +49,7 @@ function () use ($user): Folder {
$node = $this->getRootFolder()->get($this->path);
if ($node instanceof File) {
$e = new \RuntimeException();
- \OCP\Server::get(LoggerInterface::class)->error('User root storage is not a folder: ' . $this->path, [
+ Server::get(LoggerInterface::class)->error('User root storage is not a folder: ' . $this->path, [
'exception' => $e,
]);
throw $e;
diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php
index fd8d84883d964..fc26914b0cb90 100644
--- a/lib/private/Files/Node/Node.php
+++ b/lib/private/Files/Node/Node.php
@@ -10,6 +10,8 @@
use OC\Files\Filesystem;
use OC\Files\Mount\MoveableMount;
use OC\Files\Utils\PathHelper;
+use OC\Files\View;
+use OCP\Constants;
use OCP\EventDispatcher\GenericEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\FileInfo;
@@ -20,53 +22,30 @@
use OCP\Files\NotPermittedException;
use OCP\Lock\LockedException;
use OCP\PreConditionNotMetException;
+use OCP\Server;
// FIXME: this class really should be abstract (+1)
class Node implements INode {
- /**
- * @var \OC\Files\View $view
- */
- protected $view;
-
- protected IRootFolder $root;
-
- /**
- * @var string $path Absolute path to the node (e.g. /admin/files/folder/file)
- */
- protected $path;
-
- protected ?FileInfo $fileInfo;
-
- protected ?INode $parent;
-
- private bool $infoHasSubMountsIncluded;
-
- /**
- * @param \OC\Files\View $view
- * @param \OCP\Files\IRootFolder $root
- * @param string $path
- * @param FileInfo $fileInfo
- */
- public function __construct(IRootFolder $root, $view, $path, $fileInfo = null, ?INode $parent = null, bool $infoHasSubMountsIncluded = true) {
+ /** @param string $path */
+ public function __construct(
+ protected IRootFolder $root,
+ protected View $view,
+ protected $path,
+ protected ?FileInfo $fileInfo = null,
+ protected ?INode $parent = null,
+ private bool $infoHasSubMountsIncluded = true,
+ ) {
if (Filesystem::normalizePath($view->getRoot()) !== '/') {
throw new PreConditionNotMetException('The view passed to the node should not have any fake root set');
}
- $this->view = $view;
- $this->root = $root;
- $this->path = $path;
- $this->fileInfo = $fileInfo;
- $this->parent = $parent;
- $this->infoHasSubMountsIncluded = $infoHasSubMountsIncluded;
}
/**
- * Creates a Node of the same type that represents a non-existing path
+ * Get non existing node.
*
- * @param string $path path
- * @return Node non-existing node
* @throws \Exception
*/
- protected function createNonExistingNode($path) {
+ protected function createNonExistingNode(string $path): Node {
throw new \Exception('Must be implemented by subclasses');
}
@@ -104,7 +83,7 @@ public function getFileInfo(bool $includeMountPoint = true) {
protected function sendHooks($hooks, ?array $args = null) {
$args = !empty($args) ? $args : [$this];
/** @var IEventDispatcher $dispatcher */
- $dispatcher = \OC::$server->get(IEventDispatcher::class);
+ $dispatcher = Server::get(IEventDispatcher::class);
foreach ($hooks as $hook) {
if (method_exists($this->root, 'emit')) {
$this->root->emit('\OC\Files', $hook, $args);
@@ -140,7 +119,7 @@ public function delete() {
* @throws NotPermittedException
*/
public function touch($mtime = null) {
- if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) {
+ if ($this->checkPermissions(Constants::PERMISSION_UPDATE)) {
$this->sendHooks(['preTouch']);
$this->view->touch($this->path, $mtime);
$this->sendHooks(['postTouch']);
diff --git a/lib/private/Files/Node/NonExistingFolder.php b/lib/private/Files/Node/NonExistingFolder.php
index 4489fdaf01067..d735c2e94965d 100644
--- a/lib/private/Files/Node/NonExistingFolder.php
+++ b/lib/private/Files/Node/NonExistingFolder.php
@@ -7,6 +7,7 @@
*/
namespace OC\Files\Node;
+use OCP\Files\Node;
use OCP\Files\NotFoundException;
class NonExistingFolder extends Folder {
@@ -14,23 +15,23 @@ class NonExistingFolder extends Folder {
* @param string $newPath
* @throws \OCP\Files\NotFoundException
*/
- public function rename($newPath) {
+ public function rename($newPath): never {
throw new NotFoundException();
}
- public function delete() {
+ public function delete(): never {
throw new NotFoundException();
}
- public function copy($targetPath) {
+ public function copy($targetPath): never {
throw new NotFoundException();
}
- public function touch($mtime = null) {
+ public function touch($mtime = null): never {
throw new NotFoundException();
}
- public function getId() {
+ public function getId(): int {
if ($this->fileInfo) {
return parent::getId();
} else {
@@ -38,7 +39,7 @@ public function getId() {
}
}
- public function getInternalPath() {
+ public function getInternalPath(): string {
if ($this->fileInfo) {
return parent::getInternalPath();
} else {
@@ -46,11 +47,11 @@ public function getInternalPath() {
}
}
- public function stat() {
+ public function stat(): never {
throw new NotFoundException();
}
- public function getMTime() {
+ public function getMTime(): int {
if ($this->fileInfo) {
return parent::getMTime();
} else {
@@ -66,7 +67,7 @@ public function getSize($includeMounts = true): int|float {
}
}
- public function getEtag() {
+ public function getEtag(): string {
if ($this->fileInfo) {
return parent::getEtag();
} else {
@@ -74,7 +75,7 @@ public function getEtag() {
}
}
- public function getPermissions() {
+ public function getPermissions(): int {
if ($this->fileInfo) {
return parent::getPermissions();
} else {
@@ -82,7 +83,7 @@ public function getPermissions() {
}
}
- public function isReadable() {
+ public function isReadable(): bool {
if ($this->fileInfo) {
return parent::isReadable();
} else {
@@ -90,7 +91,7 @@ public function isReadable() {
}
}
- public function isUpdateable() {
+ public function isUpdateable(): bool {
if ($this->fileInfo) {
return parent::isUpdateable();
} else {
@@ -98,7 +99,7 @@ public function isUpdateable() {
}
}
- public function isDeletable() {
+ public function isDeletable(): bool {
if ($this->fileInfo) {
return parent::isDeletable();
} else {
@@ -106,7 +107,7 @@ public function isDeletable() {
}
}
- public function isShareable() {
+ public function isShareable(): bool {
if ($this->fileInfo) {
return parent::isShareable();
} else {
@@ -114,51 +115,51 @@ public function isShareable() {
}
}
- public function get($path) {
+ public function get($path): never {
throw new NotFoundException();
}
- public function getDirectoryListing() {
+ public function getDirectoryListing(): never {
throw new NotFoundException();
}
- public function nodeExists($path) {
+ public function nodeExists($path): false {
return false;
}
- public function newFolder($path) {
+ public function newFolder($path): never {
throw new NotFoundException();
}
- public function newFile($path, $content = null) {
+ public function newFile($path, $content = null): never {
throw new NotFoundException();
}
- public function search($query) {
+ public function search($query): never {
throw new NotFoundException();
}
- public function searchByMime($mimetype) {
+ public function searchByMime($mimetype): never {
throw new NotFoundException();
}
- public function searchByTag($tag, $userId) {
+ public function searchByTag($tag, $userId): never {
throw new NotFoundException();
}
- public function searchBySystemTag(string $tagName, string $userId, int $limit = 0, int $offset = 0): array {
+ public function searchBySystemTag(string $tagName, string $userId, int $limit = 0, int $offset = 0): never {
throw new NotFoundException();
}
- public function getById($id) {
+ public function getById($id): never {
throw new NotFoundException();
}
- public function getFirstNodeById(int $id): ?\OCP\Files\Node {
+ public function getFirstNodeById(int $id): ?Node {
throw new NotFoundException();
}
- public function getFreeSpace() {
+ public function getFreeSpace(): never {
throw new NotFoundException();
}
diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php
index 8354f382aa3be..f86477e5036de 100644
--- a/lib/private/Files/Node/Root.php
+++ b/lib/private/Files/Node/Root.php
@@ -11,6 +11,7 @@
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\Mount\MountPoint;
+use OC\Files\Storage\Storage;
use OC\Files\Utils\PathHelper;
use OC\Files\View;
use OC\Hooks\PublicEmitter;
@@ -18,6 +19,7 @@
use OCA\Files\AppInfo\Application;
use OCA\Files\ConfigLexicon;
use OCP\Cache\CappedMemoryCache;
+use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Config\ICachedMountFileInfo;
@@ -76,7 +78,7 @@ public function __construct(
parent::__construct($this, $view, '');
$this->emitter = new PublicEmitter();
$this->userFolderCache = new CappedMemoryCache();
- $eventDispatcher->addListener(FilesystemTornDownEvent::class, function () {
+ $eventDispatcher->addListener(FilesystemTornDownEvent::class, function (): void {
$this->userFolderCache = new CappedMemoryCache();
});
$this->pathByIdCache = $cacheFactory->createLocal('path-by-id');
@@ -118,7 +120,7 @@ public function emit($scope, $method, $arguments = []) {
}
/**
- * @param \OC\Files\Storage\Storage $storage
+ * @param Storage $storage
* @param string $mountPoint
* @param array $arguments
*/
@@ -133,35 +135,12 @@ public function getMount(string $mountPoint): IMountPoint {
/**
* @param string $mountPoint
- * @return \OC\Files\Mount\MountPoint[]
+ * @return IMountPoint[]
*/
public function getMountsIn(string $mountPoint): array {
return $this->mountManager->findIn($mountPoint);
}
- /**
- * @param string $storageId
- * @return \OC\Files\Mount\MountPoint[]
- */
- public function getMountByStorageId($storageId) {
- return $this->mountManager->findByStorageId($storageId);
- }
-
- /**
- * @param int $numericId
- * @return MountPoint[]
- */
- public function getMountByNumericStorageId($numericId) {
- return $this->mountManager->findByNumericId($numericId);
- }
-
- /**
- * @param \OC\Files\Mount\MountPoint $mount
- */
- public function unMount($mount) {
- $this->mountManager->remove($mount);
- }
-
public function get($path) {
$path = $this->normalizePath($path);
if ($this->isValidPath($path)) {
@@ -181,23 +160,21 @@ public function get($path) {
/**
* @param string $targetPath
- * @return Node
* @throws \OCP\Files\NotPermittedException
*/
- public function rename($targetPath) {
+ public function rename($targetPath): never {
throw new NotPermittedException();
}
- public function delete() {
+ public function delete(): never {
throw new NotPermittedException();
}
/**
* @param string $targetPath
- * @return Node
* @throws \OCP\Files\NotPermittedException
*/
- public function copy($targetPath) {
+ public function copy($targetPath): never {
throw new NotPermittedException();
}
@@ -205,50 +182,34 @@ public function copy($targetPath) {
* @param int $mtime
* @throws \OCP\Files\NotPermittedException
*/
- public function touch($mtime = null) {
+ public function touch($mtime = null): never {
throw new NotPermittedException();
}
/**
- * @return \OC\Files\Storage\Storage
* @throws \OCP\Files\NotFoundException
*/
- public function getStorage() {
+ public function getStorage(): never {
throw new NotFoundException();
}
- /**
- * @return string
- */
- public function getPath() {
+ public function getPath(): string {
return '/';
}
- /**
- * @return string
- */
- public function getInternalPath() {
+ public function getInternalPath(): string {
return '';
}
- /**
- * @return int
- */
- public function getId() {
+ public function getId(): int {
return 0;
}
- /**
- * @return array
- */
- public function stat() {
+ public function stat(): array {
return [];
}
- /**
- * @return int
- */
- public function getMTime() {
+ public function getMTime(): int {
return 0;
}
@@ -260,45 +221,27 @@ public function getSize($includeMounts = true): int|float {
return 0;
}
- /**
- * @return string
- */
- public function getEtag() {
+ public function getEtag(): string {
return '';
}
- /**
- * @return int
- */
- public function getPermissions() {
- return \OCP\Constants::PERMISSION_CREATE;
+ public function getPermissions(): int {
+ return Constants::PERMISSION_CREATE;
}
- /**
- * @return bool
- */
- public function isReadable() {
+ public function isReadable(): bool {
return false;
}
- /**
- * @return bool
- */
- public function isUpdateable() {
+ public function isUpdateable(): bool {
return false;
}
- /**
- * @return bool
- */
- public function isDeletable() {
+ public function isDeletable(): bool {
return false;
}
- /**
- * @return bool
- */
- public function isShareable() {
+ public function isShareable(): bool {
return false;
}
@@ -367,7 +310,7 @@ public function getUserFolder($userId) {
return $this->userFolderCache->get($userId);
}
- public function getUserMountCache() {
+ public function getUserMountCache(): IUserMountCache {
return $this->userMountCache;
}
@@ -401,8 +344,7 @@ public function getFirstNodeByIdInPath(int $id, string $path): ?INode {
}
/**
- * @param int $id
- * @return Node[]
+ * @return list
*/
public function getByIdInPath(int $id, string $path): array {
$mountCache = $this->getUserMountCache();
@@ -473,7 +415,7 @@ public function getByIdInPath(int $id, string $path): array {
return [];
}
- $nodes = array_map(function (IMountPoint $mount) use ($id, $mountRoots) {
+ $nodes = array_map(function (IMountPoint $mount) use ($id, $mountRoots): ?INode {
$rootInternalPath = $mountRoots[$mount->getStorageRootId()];
$cacheEntry = $mount->getStorage()->getCache()->get($id);
if (!$cacheEntry) {
@@ -507,12 +449,10 @@ public function getByIdInPath(int $id, string $path): array {
$nodes = array_filter($nodes);
- $folders = array_filter($nodes, function (Node $node) use ($path) {
+ $folders = array_filter($nodes, function (INode $node) use ($path): bool {
return PathHelper::getRelativePath($path, $node->getPath()) !== null;
});
- usort($folders, function ($a, $b) {
- return $b->getPath() <=> $a->getPath();
- });
+ usort($folders, static fn (INode $a, INode $b): int => $b->getPath() <=> $a->getPath());
return $folders;
}
diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php
index c8945de7caed1..0cc44cfd167ba 100644
--- a/lib/private/Files/SetupManager.php
+++ b/lib/private/Files/SetupManager.php
@@ -629,7 +629,7 @@ static function (ICachedMountInfo $info) use ($rootsMetadata) {
$this->registerMounts($user, $fullProviderMounts, $currentProviders);
}
- $this->setupForUserWith($user, function () use ($fullProviderMounts, $authoritativeMounts) {
+ $this->setupForUserWith($user, function () use ($fullProviderMounts, $authoritativeMounts): void {
$allMounts = [...$fullProviderMounts, ...$authoritativeMounts];
array_walk($allMounts, $this->mountManager->addMount(...));
});
@@ -765,7 +765,7 @@ private function setupListeners() {
$this->eventDispatcher->addListener(ShareCreatedEvent::class, function (ShareCreatedEvent $event): void {
$this->cache->remove($event->getShare()->getSharedWith());
});
- $this->eventDispatcher->addListener(BeforeNodeRenamedEvent::class, function (BeforeNodeRenamedEvent $event) {
+ $this->eventDispatcher->addListener(BeforeNodeRenamedEvent::class, function (BeforeNodeRenamedEvent $event): void {
// update cache information that is cached by mount point
$from = rtrim($event->getSource()->getPath(), '/') . '/';
$to = rtrim($event->getTarget()->getPath(), '/') . '/';
diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php
index 125f5469f926e..c8e0a38798131 100644
--- a/lib/private/Files/Storage/Wrapper/Jail.php
+++ b/lib/private/Files/Storage/Wrapper/Jail.php
@@ -33,7 +33,7 @@ class Jail extends Wrapper {
protected $rootPath;
/**
- * @param array $parameters ['storage' => $storage, 'root' => $root]
+ * @param array{storage: IStorage, root: string} $parameters
*
* $storage: The storage that will be wrapper
* $root: The folder in the wrapped storage that will become the root folder of the wrapped storage
diff --git a/lib/private/Files/Storage/Wrapper/PermissionsMask.php b/lib/private/Files/Storage/Wrapper/PermissionsMask.php
index 885fbb259e088..61ea08c67b7c2 100644
--- a/lib/private/Files/Storage/Wrapper/PermissionsMask.php
+++ b/lib/private/Files/Storage/Wrapper/PermissionsMask.php
@@ -11,6 +11,7 @@
use OCP\Constants;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\IScanner;
+use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
/**
@@ -24,10 +25,10 @@ class PermissionsMask extends Wrapper {
/**
* @var int the permissions bits we want to keep
*/
- private $mask;
+ private int $mask;
/**
- * @param array $parameters ['storage' => $storage, 'mask' => $mask]
+ * @param array{storage: ?IStorage, mask: int} $parameters
*
* $storage: The storage the permissions mask should be applied on
* $mask: The permission bits that should be kept, a combination of the \OCP\Constant::PERMISSION_ constants
diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php
index 19fe9a6621e2d..985153ee41538 100644
--- a/lib/private/Files/Storage/Wrapper/Wrapper.php
+++ b/lib/private/Files/Storage/Wrapper/Wrapper.php
@@ -24,9 +24,7 @@
use Psr\Log\LoggerInterface;
class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage {
- /**
- * @var Storage $storage
- */
+ /** @var Storage $storage */
protected $storage;
public $cache;
@@ -36,14 +34,14 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage {
public $updater;
/**
- * @param array $parameters
+ * @param array{storage: IStorage, ...} $parameters
*/
public function __construct(array $parameters) {
$this->storage = $parameters['storage'];
}
public function getWrapperStorage(): Storage {
- if (!$this->storage) {
+ if ($this->storage === null) {
$message = 'storage wrapper ' . get_class($this) . " doesn't have a wrapped storage set";
$logger = Server::get(LoggerInterface::class);
$logger->error($message);
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index 8790f611baf68..f0bfff5249d29 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -1518,8 +1518,8 @@ public function getDirectoryContent($directory, $mimetype_filter = '', ?\OCP\Fil
$folderId = $data->getId();
$contents = $cache->getFolderContentsById($folderId); //TODO: mimetype_filter
- $sharingDisabled = \OCP\Util::isSharingDisabledForUser();
- $permissionsMask = ~\OCP\Constants::PERMISSION_SHARE;
+ $sharingDisabled = Util::isSharingDisabledForUser();
+ $permissionsMask = ~Constants::PERMISSION_SHARE;
$files = [];
foreach ($contents as $content) {
diff --git a/lib/private/OpenMetrics/ExporterManager.php b/lib/private/OpenMetrics/ExporterManager.php
index 5bf8e59786ae6..0b984fb382ee8 100644
--- a/lib/private/OpenMetrics/ExporterManager.php
+++ b/lib/private/OpenMetrics/ExporterManager.php
@@ -10,6 +10,16 @@
namespace OC\OpenMetrics;
use Generator;
+use OC\OpenMetrics\Exporters\ActiveSessions;
+use OC\OpenMetrics\Exporters\ActiveUsers;
+use OC\OpenMetrics\Exporters\AppsCount;
+use OC\OpenMetrics\Exporters\AppsInfo;
+use OC\OpenMetrics\Exporters\FilesByType;
+use OC\OpenMetrics\Exporters\InstanceInfo;
+use OC\OpenMetrics\Exporters\LogLevel;
+use OC\OpenMetrics\Exporters\Maintenance;
+use OC\OpenMetrics\Exporters\RunningJobs;
+use OC\OpenMetrics\Exporters\UsersByBackend;
use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\OpenMetrics\IMetricFamily;
@@ -33,22 +43,22 @@ public function export(): Generator {
// Core exporters
$exporters = [
// Basic exporters
- Exporters\InstanceInfo::class,
- Exporters\AppsInfo::class,
- Exporters\AppsCount::class,
- Exporters\Maintenance::class,
- Exporters\LogLevel::class,
+ InstanceInfo::class,
+ AppsInfo::class,
+ AppsCount::class,
+ Maintenance::class,
+ LogLevel::class,
// File exporters
- Exporters\FilesByType::class,
+ FilesByType::class,
// Users exporters
- Exporters\ActiveUsers::class,
- Exporters\ActiveSessions::class,
- Exporters\UsersByBackend::class,
+ ActiveUsers::class,
+ ActiveSessions::class,
+ UsersByBackend::class,
// Jobs
- Exporters\RunningJobs::class,
+ RunningJobs::class,
];
$exporters = array_filter($exporters, fn ($classname) => !isset($this->skippedClasses[$classname]));
foreach ($exporters as $classname) {
diff --git a/lib/private/Profiler/FileProfilerStorage.php b/lib/private/Profiler/FileProfilerStorage.php
index 1636b9d60651e..14aaf1b906952 100644
--- a/lib/private/Profiler/FileProfilerStorage.php
+++ b/lib/private/Profiler/FileProfilerStorage.php
@@ -8,6 +8,12 @@
namespace OC\Profiler;
+use OC\DB\DbDataCollector;
+use OC\Memcache\ProfilerWrapperCache;
+use OCA\Profiler\DataCollector\EventLoggerDataProvider;
+use OCA\Profiler\DataCollector\HttpDataCollector;
+use OCA\Profiler\DataCollector\MemoryDataCollector;
+use OCA\User_LDAP\DataCollector\LdapDataCollector;
use OCP\Profiler\IProfile;
/**
@@ -16,13 +22,13 @@
class FileProfilerStorage {
/** @psalm-suppress UndefinedClass */
public const allowedClasses = [
- \OCA\Profiler\DataCollector\EventLoggerDataProvider::class,
- \OCA\Profiler\DataCollector\HttpDataCollector::class,
- \OCA\Profiler\DataCollector\MemoryDataCollector::class,
- \OCA\User_LDAP\DataCollector\LdapDataCollector::class,
- \OC\Memcache\ProfilerWrapperCache::class,
- \OC\Profiler\RoutingDataCollector::class,
- \OC\DB\DbDataCollector::class,
+ EventLoggerDataProvider::class,
+ HttpDataCollector::class,
+ MemoryDataCollector::class,
+ LdapDataCollector::class,
+ ProfilerWrapperCache::class,
+ RoutingDataCollector::class,
+ DbDataCollector::class,
];
/**
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 1d72ec63cb0ff..2ff0bce2acf41 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -58,6 +58,7 @@
use OCP\Share\IProviderFactory;
use OCP\Share\IShare;
use OCP\Share\IShareProvider;
+use OCP\Share\IShareProviderGetUsers;
use OCP\Share\IShareProviderSupportsAccept;
use OCP\Share\IShareProviderSupportsAllSharesInFolder;
use OCP\Share\IShareProviderWithNotification;
@@ -1547,7 +1548,7 @@ public function userDeletedFromGroup(string $uid, string $gid): void {
}
#[\Override]
- public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false): array {
+ public function getAccessList(Node $path, $recursive = true, $currentAccess = false): array {
$owner = $path->getOwner();
if ($owner === null) {
@@ -1942,7 +1943,7 @@ private function dispatchEvent(Event $event, string $name): void {
public function getUsersForShare(IShare $share): iterable {
$provider = $this->factory->getProviderForType($share->getShareType());
- if ($provider instanceof Share\IShareProviderGetUsers) {
+ if ($provider instanceof IShareProviderGetUsers) {
return $provider->getUsersForShare($share);
} else {
return [];
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php
index 36b9f80dd991c..5c899b7892f21 100644
--- a/lib/private/User/Manager.php
+++ b/lib/private/User/Manager.php
@@ -664,7 +664,7 @@ private function getSeenUserIds($limit = null, $offset = null) {
* @internal Only for mocks it in unit tests.
*/
public function getUserConfig(): IUserConfig {
- return \OCP\Server::get(IUserConfig::class);
+ return Server::get(IUserConfig::class);
}
/**
diff --git a/lib/private/legacy/OC_User.php b/lib/private/legacy/OC_User.php
index abdb37b737cc3..ddd426da942e4 100644
--- a/lib/private/legacy/OC_User.php
+++ b/lib/private/legacy/OC_User.php
@@ -9,6 +9,7 @@
use OC\SystemConfig;
use OC\User\Database;
use OC\User\DisabledUserException;
+use OC\User\Session;
use OCP\Authentication\Exceptions\InvalidTokenException;
use OCP\Authentication\Exceptions\WipeTokenException;
use OCP\Authentication\IApacheBackend;
@@ -151,7 +152,7 @@ public static function loginWithApache(IApacheBackend $backend): bool {
if ($uid) {
if (self::getUser() !== $uid) {
self::setUserId($uid);
- /** @var \OC\User\Session $userSession */
+ /** @var Session $userSession */
$userSession = Server::get(IUserSession::class);
/** @var IEventDispatcher $dispatcher */
@@ -234,7 +235,7 @@ public static function handleApacheAuth(): ?bool {
//setup extra user backends
self::setupBackends();
- /** @var \OC\User\Session $session */
+ /** @var Session $session */
$session = Server::get(IUserSession::class);
$session->unsetMagicInCookie();
diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php
index 0a38062e553ca..b3b0f4e3e20ca 100644
--- a/lib/private/legacy/OC_Util.php
+++ b/lib/private/legacy/OC_Util.php
@@ -12,6 +12,7 @@
use OC\Files\SetupManager;
use OC\Setup;
use OC\SystemConfig;
+use OCP\App\IAppManager;
use OCP\Files\FileInfo;
use OCP\Files\Folder;
use OCP\Files\NotFoundException;
@@ -787,14 +788,14 @@ public static function normalizeUnicode(string $value): string {
* @deprecated 32.0.0 Use \OCP\Util::needUpgrade() instead.
* @see \OCP\Util::needUpgrade
*/
- public static function needUpgrade(\OC\SystemConfig $config): bool {
+ public static function needUpgrade(SystemConfig $config): bool {
if (!$config->getValue('installed', false)) {
// not installed (nothing to do)
return false;
}
$installedVersion = (string)$config->getValue('version', '0.0.0');
- $codeVersion = implode('.', \OCP\Util::getVersion());
+ $codeVersion = implode('.', Util::getVersion());
// codebase newer: upgrade needed
if (version_compare($codeVersion, $installedVersion, '>')) {
@@ -815,12 +816,12 @@ public static function needUpgrade(\OC\SystemConfig $config): bool {
// disallow downgrade (not in debug mode or major.minor mismatch)
/** @var \Psr\Log\LoggerInterface $logger */
- $logger = \OCP\Server::get(LoggerInterface::class);
+ $logger = Server::get(LoggerInterface::class);
$logger->error(
'Detected downgrade attempt from installed {installed} to code {code}',
[ 'installed' => $installedVersion, 'code' => $codeVersion, 'app' => 'core', ]
);
- throw new \OCP\HintException(sprintf(
+ throw new HintException(sprintf(
'Downgrading Nextcloud from %s to %s is not supported and may corrupt your instance (database and data directory). '
. 'Restore a full backup (code, database, and data directory) taken before the change, '
. 'or restore the previous codebase so that it matches the installed version (version %s).',
@@ -829,7 +830,7 @@ public static function needUpgrade(\OC\SystemConfig $config): bool {
}
// versions are equal: check whether any enabled apps need upgrading
- $appManager = \OCP\Server::get(\OCP\App\IAppManager::class);
+ $appManager = Server::get(IAppManager::class);
$apps = $appManager->getEnabledApps();
foreach ($apps as $app) {
if ($appManager->isUpgradeRequired($app)) {
diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php
index 7a5bbbec82d5a..39d915e04bce9 100644
--- a/tests/Core/Controller/ClientFlowLoginControllerTest.php
+++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php
@@ -161,7 +161,7 @@ public function testShowAuthPickerPageWithOcsHeader(): void {
$initialState = [];
$this->initialState->expects($this->exactly(2))
->method('provideInitialState')
- ->willReturnCallback(function () use (&$initialState) {
+ ->willReturnCallback(function () use (&$initialState): void {
$initialState[] = func_get_args();
});
@@ -240,7 +240,7 @@ public function testShowAuthPickerPageWithOauth(): void {
$initialState = [];
$this->initialState->expects($this->exactly(2))
->method('provideInitialState')
- ->willReturnCallback(function () use (&$initialState) {
+ ->willReturnCallback(function () use (&$initialState): void {
$initialState[] = func_get_args();
});
diff --git a/tests/Core/Controller/OpenMetricsControllerTest.php b/tests/Core/Controller/OpenMetricsControllerTest.php
index 56e40cdf7d773..fdc81ad5d2c0e 100644
--- a/tests/Core/Controller/OpenMetricsControllerTest.php
+++ b/tests/Core/Controller/OpenMetricsControllerTest.php
@@ -59,7 +59,7 @@ public function testGetMetrics(): void {
$output = $this->createMock(IOutput::class);
$fullOutput = '';
$output->method('setOutput')
- ->willReturnCallback(function ($output) use (&$fullOutput) {
+ ->willReturnCallback(function ($output) use (&$fullOutput): void {
$fullOutput .= $output;
});
$this->config->expects($this->once())
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index cf39642280c20..9a0928a82e9f3 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -970,7 +970,7 @@ function ($appName, $key, $default) {
$this->instantiatePlugin(IShare::TYPE_USER);
- $currentUser = $this->createMock(\OCP\IUser::class);
+ $currentUser = $this->createMock(IUser::class);
$currentUser->expects($this->any())
->method('getUID')
diff --git a/tests/lib/DB/MigrationServiceTest.php b/tests/lib/DB/MigrationServiceTest.php
index c2c8cdc03cc9b..0142c36ee264c 100644
--- a/tests/lib/DB/MigrationServiceTest.php
+++ b/tests/lib/DB/MigrationServiceTest.php
@@ -224,7 +224,7 @@ public function testMigrate(): void {
$migrationService
->expects($this->exactly(2))
->method('executeStep')
- ->willReturnCallback(function (string $migration) use (&$calls) {
+ ->willReturnCallback(function (string $migration) use (&$calls): void {
$calls[] = $migration;
});
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index 0fc3115e13f76..3b7c245eaa8b5 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -86,8 +86,8 @@ public function testGetDirectoryContent(): void {
->method('getDirectoryContent')
->with('/bar/foo')
->willReturn([
- new FileInfo('/bar/foo/asd', null, 'foo/asd', ['fileid' => 2, 'path' => '/bar/foo/asd', 'name' => 'asd', 'size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'], null),
- new FileInfo('/bar/foo/qwerty', null, 'foo/qwerty', ['fileid' => 3, 'path' => '/bar/foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'httpd/unix-directory'], null),
+ new FileInfo('/bar/foo/asd', $this->createMock(IStorage::class), 'foo/asd', ['fileid' => 2, 'path' => '/bar/foo/asd', 'name' => 'asd', 'size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'], null),
+ new FileInfo('/bar/foo/qwerty', $this->createMock(IStorage::class), 'foo/qwerty', ['fileid' => 3, 'path' => '/bar/foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'httpd/unix-directory'], null),
]);
$this->view->method('getFileInfo')
->willReturn($this->createMock(FileInfo::class));
diff --git a/tests/lib/Files/SetupManagerTest.php b/tests/lib/Files/SetupManagerTest.php
index 673b0fc738cbc..f70358691cde4 100644
--- a/tests/lib/Files/SetupManagerTest.php
+++ b/tests/lib/Files/SetupManagerTest.php
@@ -633,7 +633,7 @@ public function testSetupForProviderResetsUserProviderPaths(): void {
}
private function getAddMountCheckCallback(InvokedCount $invokedCount, $expectations): \Closure {
- return function (IMountPoint $actualMount) use ($invokedCount, $expectations) {
+ return function (IMountPoint $actualMount) use ($invokedCount, $expectations): void {
$expectedMount = $expectations[$invokedCount->numberOfInvocations()] ?? null;
$this->assertSame($expectedMount, $actualMount);
};
diff --git a/tests/lib/Files/Template/TemplateManagerTest.php b/tests/lib/Files/Template/TemplateManagerTest.php
index 7b3f0beff429d..431b032594c14 100644
--- a/tests/lib/Files/Template/TemplateManagerTest.php
+++ b/tests/lib/Files/Template/TemplateManagerTest.php
@@ -24,6 +24,8 @@
use OCP\IPreview;
use OCP\IServerContainer;
use OCP\IUser;
+use OCP\IUserManager;
+use OCP\IUserSession;
use OCP\L10N\IFactory;
use Psr\Log\NullLogger;
use Test\TestCase;
@@ -64,10 +66,10 @@ protected function setUp(): void {
$this->rootFolder = $this->createMock(IRootFolder::class);
$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user1');
- $userSession = $this->createMock(\OCP\IUserSession::class);
+ $userSession = $this->createMock(IUserSession::class);
$userSession->method('getUser')
->willReturn($user);
- $userManager = $this->createMock(\OCP\IUserManager::class);
+ $userManager = $this->createMock(IUserManager::class);
$previewManager = $this->createMock(IPreview::class);
$this->templateManager = new TemplateManager(
diff --git a/tests/lib/OCM/Listeners/LocalOCMDiscoveryTestEvent.php b/tests/lib/OCM/Listeners/LocalOCMDiscoveryTestEvent.php
index 7553d9f1b74b3..b2d0e7d09f671 100644
--- a/tests/lib/OCM/Listeners/LocalOCMDiscoveryTestEvent.php
+++ b/tests/lib/OCM/Listeners/LocalOCMDiscoveryTestEvent.php
@@ -10,6 +10,7 @@
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
+use OCP\OCM\Events\LocalOCMDiscoveryEvent;
/** @template-implements IEventListener<\OCP\OCM\Events\LocalOCMDiscoveryEvent> */
class LocalOCMDiscoveryTestEvent implements IEventListener {
@@ -18,7 +19,7 @@ public function __construct(
}
public function handle(Event $event): void {
- if (!($event instanceof \OCP\OCM\Events\LocalOCMDiscoveryEvent)) {
+ if (!($event instanceof LocalOCMDiscoveryEvent)) {
return;
}
diff --git a/tests/lib/OCM/Listeners/OCMEndpointRequestTestEvent.php b/tests/lib/OCM/Listeners/OCMEndpointRequestTestEvent.php
index f0b706fe39b79..bbe36a529fd57 100644
--- a/tests/lib/OCM/Listeners/OCMEndpointRequestTestEvent.php
+++ b/tests/lib/OCM/Listeners/OCMEndpointRequestTestEvent.php
@@ -12,6 +12,8 @@
use OCP\AppFramework\Http\Response;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
+use OCP\OCM\Enum\ParamType;
+use OCP\OCM\Events\OCMEndpointRequestEvent;
/** @template-implements IEventListener<\OCP\OCM\Events\OCMEndpointRequestEvent> */
class OCMEndpointRequestTestEvent implements IEventListener {
@@ -20,7 +22,7 @@ public function __construct(
}
public function handle(Event $event): void {
- if (!($event instanceof \OCP\OCM\Events\OCMEndpointRequestEvent)) {
+ if (!($event instanceof OCMEndpointRequestEvent)) {
return;
}
@@ -36,11 +38,11 @@ public function handle(Event $event): void {
'args' => $event->getArgs(),
'totalArgs' => $event->getArgsCount(),
'typedArgs' => $event->getArgs(
- \OCP\OCM\Enum\ParamType::STRING,
- \OCP\OCM\Enum\ParamType::STRING,
- \OCP\OCM\Enum\ParamType::INT,
- \OCP\OCM\Enum\ParamType::BOOL,
- \OCP\OCM\Enum\ParamType::INT
+ ParamType::STRING,
+ ParamType::STRING,
+ ParamType::INT,
+ ParamType::BOOL,
+ ParamType::INT
)
]
));
diff --git a/tests/lib/Preview/PostscriptTest.php b/tests/lib/Preview/PostscriptTest.php
index 5fb7abc5201ca..e5cc15ee7f4c5 100644
--- a/tests/lib/Preview/PostscriptTest.php
+++ b/tests/lib/Preview/PostscriptTest.php
@@ -10,6 +10,7 @@
use OC\BinaryFinder;
use OC\Preview\Postscript;
+use OCP\Server;
#[\PHPUnit\Framework\Attributes\Group('DB')]
#[\PHPUnit\Framework\Attributes\RequiresPhpExtension('imagick')]
@@ -19,7 +20,7 @@ protected function setUp(): void {
if (\Imagick::queryFormats('EPS') === false || \Imagick::queryFormats('PS') === false) {
$this->markTestSkipped('Imagick does not support postscript.');
}
- if (\OCP\Server::get(BinaryFinder::class)->findBinaryPath('gs') === false) {
+ if (Server::get(BinaryFinder::class)->findBinaryPath('gs') === false) {
// Imagick forwards postscript rendering to Ghostscript but does not report this in queryFormats
$this->markTestSkipped('Ghostscript is not installed.');
}
diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php
index 551c1024e0bef..c40c05b3de773 100644
--- a/tests/lib/TestCase.php
+++ b/tests/lib/TestCase.php
@@ -23,6 +23,7 @@
use OC\Files\View;
use OC\Installer;
use OC\Updater;
+use OC\User\Session;
use OCP\Command\IBus;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\IRootFolder;
@@ -442,7 +443,7 @@ protected static function loginAsUser(string $user = ''): void {
*/
protected static function logout(): void {
Server::get(SetupManager::class)->tearDown();
- $userSession = Server::get(\OC\User\Session::class);
+ $userSession = Server::get(Session::class);
$userSession->getSession()->set('user_id', '');
// needed for fully logout
$userSession->setUser(null);