refactor: Apply second batch of comments

Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
Carl Schwan
2025-11-20 18:02:21 +01:00
committed by Carl Schwan
parent acda4ff072
commit 3979c493f9
43 changed files with 164 additions and 404 deletions
@@ -110,21 +110,16 @@ class SMBNotifyHandler implements INotifyHandler {
return $result;
}
private function mapNotifyType($smbType) {
switch ($smbType) {
case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED:
return IChange::ADDED;
case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED:
return IChange::REMOVED;
case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED:
case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM:
case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM:
case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM:
return IChange::MODIFIED;
case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW:
return IChange::RENAMED;
default:
return null;
}
/**
* @return IChange::ADDED|IChange::REMOVED|IChange::MODIFIED|IChange::RENAMED|null
*/
private function mapNotifyType($smbType): ?int {
return match ($smbType) {
\Icewind\SMB\INotifyHandler::NOTIFY_ADDED => IChange::ADDED,
\Icewind\SMB\INotifyHandler::NOTIFY_REMOVED => IChange::REMOVED,
\Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED, \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM, \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM, \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM => IChange::MODIFIED,
\Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW => IChange::RENAMED,
default => null,
};
}
}
+1 -3
View File
@@ -25,9 +25,7 @@ use Psr\Log\LoggerInterface;
* Shared mount points can be moved by the user
*/
class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint {
/**
* @var SharedStorage $storage
*/
/** @var ?SharedStorage $storage */
protected $storage = null;
/** @var IShare */
-5
View File
@@ -3560,11 +3560,6 @@
<code><![CDATA[self::getGlobalCache()->getStorageInfo($storageId)]]></code>
</NullableReturnStatement>
</file>
<file src="lib/private/Files/Cache/Updater.php">
<RedundantCondition>
<code><![CDATA[$this->cache instanceof Cache]]></code>
</RedundantCondition>
</file>
<file src="lib/private/Files/Cache/Wrapper/CacheWrapper.php">
<LessSpecificImplementedReturnType>
<code><![CDATA[array]]></code>
@@ -13,7 +13,7 @@ class Credentials implements ICredentials {
public function __construct(
private readonly string $uid,
private readonly string $loginName,
private readonly string $password,
private readonly ?string $password,
) {
}
@@ -28,7 +28,7 @@ class Credentials implements ICredentials {
}
#[Override]
public function getPassword(): string {
public function getPassword(): ?string {
return $this->password;
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ class Config {
protected string $configDir,
protected string $configFileName = 'config.php',
) {
$this->configFilePath = $this->configDir . $configFileName;
$this->configFilePath = $this->configDir . $this->configFileName;
$this->readData();
$this->isReadOnly = $this->getValue('config_is_read_only', false);
}
+5 -15
View File
@@ -28,30 +28,20 @@ class Util {
public const HEADER_ENCRYPTION_MODULE_KEY = 'oc_encryption_module';
/**
* block size will always be 8192 for a PHP stream
* Block size will always be 8192 for a PHP stream
* @see https://bugs.php.net/bug.php?id=21641
* @var integer
*/
protected $headerSize = 8192;
protected int $headerSize = 8192;
/**
* block size will always be 8192 for a PHP stream
* Block size will always be 8192 for a PHP stream
* @see https://bugs.php.net/bug.php?id=21641
* @var integer
*/
protected $blockSize = 8192;
protected int $blockSize = 8192;
/** @var array */
protected $ocHeaderKeys;
/** @var array paths excluded from encryption */
protected array $ocHeaderKeys;
protected array $excludedPaths = [];
/**
*
* @param View $rootView
* @param IConfig $config
*/
public function __construct(
protected View $rootView,
protected IUserManager $userManager,
+1 -6
View File
@@ -19,13 +19,8 @@ use OCP\Files\Search\ISearchQuery;
* Storage placeholder to represent a missing precondition, storage unavailable
*/
class FailedCache implements ICache {
/**
* FailedCache constructor.
*
* @param bool $visible
*/
public function __construct(
private $visible = true,
private readonly bool $visible = true,
) {
}
+8 -15
View File
@@ -13,6 +13,7 @@ use OC\Files\Storage\Storage;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\Storage\Wrapper\Jail;
use OC\Hooks\BasicEmitter;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Cache\IScanner;
use OCP\Files\ForbiddenException;
@@ -42,15 +43,11 @@ use Psr\Log\LoggerInterface;
*/
class Scanner extends BasicEmitter implements IScanner {
protected string $storageId;
/** @var Cache */
protected $cache;
/** @var boolean $cacheActive If true, perform cache operations, if false, do not affect cache */
protected ICache $cache;
/** @var bool $cacheActive Whether to perform cache operations */
protected bool $cacheActive;
/** @var bool $useTransactions whether to use transactions */
protected bool $useTransactions = true;
/** * @var ILockingProvider */
protected ILockingProvider $lockingProvider;
protected IDBConnection $connection;
public function __construct(
@@ -416,7 +413,9 @@ class Scanner extends BasicEmitter implements IScanner {
// for encrypted storages, we trigger a regular folder size calculation instead of using the calculated size
// to make sure we also updated the unencrypted-size where applicable
if ($this->storage->instanceOfStorage(Encryption::class)) {
$this->cache->calculateFolderSize($path);
/** @var Cache $cache */
$cache = $this->cache;
$cache->calculateFolderSize($path);
} else {
if ($this->cacheActive) {
$updatedData = [];
@@ -588,14 +587,8 @@ class Scanner extends BasicEmitter implements IScanner {
if ($this->cacheActive && $this->cache instanceof Cache) {
$this->cache->correctFolderSize($path, null, true);
}
} catch (StorageInvalidException $e) {
// skip unavailable storages
} catch (StorageNotAvailableException $e) {
// skip unavailable storages
} catch (ForbiddenException $e) {
// skip forbidden storages
} catch (LockedException $e) {
// skip unavailable storages
} catch (StorageInvalidException|StorageNotAvailableException|ForbiddenException|LockedException) {
// skip unavailable and forbidden storages
}
}
+23 -71
View File
@@ -13,41 +13,21 @@ use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\Storage\Storage;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Cache\IPropagator;
use OCP\Files\Cache\IScanner;
use OCP\Files\Cache\IUpdater;
use OCP\Files\Storage\IStorage;
use OCP\Server;
use Override;
use Psr\Log\LoggerInterface;
/**
* Update the cache and propagate changes
*
*/
class Updater implements IUpdater {
/**
* @var bool
*/
protected $enabled = true;
/**
* @var Propagator
*/
protected $propagator;
/**
* @var Scanner
*/
protected $scanner;
/**
* @var Cache
*/
protected $cache;
protected bool $enabled = true;
protected IPropagator $propagator;
protected IScanner $scanner;
protected ICache $cache;
private LoggerInterface $logger;
/**
* @param Storage $storage
*/
public function __construct(
protected Storage $storage,
) {
@@ -60,46 +40,32 @@ class Updater implements IUpdater {
/**
* Disable updating the cache through this updater
*/
public function disable() {
public function disable(): void {
$this->enabled = false;
}
/**
* Re-enable the updating of the cache through this updater
*/
public function enable() {
public function enable(): void {
$this->enabled = true;
}
/**
* Get the propagator for etags and mtime for the view the updater works on
*
* @return Propagator
*/
public function getPropagator() {
#[Override]
public function getPropagator(): IPropagator {
return $this->propagator;
}
/**
* Propagate etag and mtime changes for the parent folders of $path up to the root of the filesystem
*
* @param string $path the path of the file to propagate the changes for
* @param int|null $time the timestamp to set as mtime for the parent folders, if left out the current time is used
*/
public function propagate($path, $time = null) {
#[Override]
public function propagate(string $path, ?int $time = null): void {
if (Scanner::isPartialFile($path)) {
return;
}
$this->propagator->propagateChange($path, $time);
}
/**
* Update the cache for $path and update the size, etag and mtime of the parent folders
*
* @param string $path
* @param int $time
*/
public function update($path, $time = null, ?int $sizeDifference = null) {
#[Override]
public function update(string $path, ?int $time = null, ?int $sizeDifference = null): void {
if (!$this->enabled || Scanner::isPartialFile($path)) {
return;
}
@@ -126,12 +92,8 @@ class Updater implements IUpdater {
$this->propagator->propagateChange($path, $time, $sizeDifference ?? 0);
}
/**
* Remove $path from the cache and update the size, etag and mtime of the parent folders
*
* @param string $path
*/
public function remove($path) {
#[Override]
public function remove(string $path): void {
if (!$this->enabled || Scanner::isPartialFile($path)) {
return;
}
@@ -156,14 +118,8 @@ class Updater implements IUpdater {
}
}
/**
* Rename a file or folder in the cache.
*
* @param IStorage $sourceStorage
* @param string $source
* @param string $target
*/
public function renameFromStorage(IStorage $sourceStorage, $source, $target) {
#[Override]
public function renameFromStorage(IStorage $sourceStorage, string $source, string $target): void {
$this->copyOrRenameFromStorage($sourceStorage, $source, $target, function (ICache $sourceCache) use ($sourceStorage, $source, $target): void {
// Remove existing cache entry to no reuse the fileId.
if ($this->cache->inCache($target)) {
@@ -178,9 +134,7 @@ class Updater implements IUpdater {
});
}
/**
* Copy a file or folder in the cache.
*/
#[Override]
public function copyFromStorage(IStorage $sourceStorage, string $source, string $target): void {
$this->copyOrRenameFromStorage($sourceStorage, $source, $target, function (ICache $sourceCache, ICacheEntry $sourceInfo) use ($target): void {
$parent = dirname($target);
@@ -250,7 +204,7 @@ class Updater implements IUpdater {
$this->propagator->propagateChange($target, $time);
}
private function updateStorageMTimeOnly($internalPath) {
private function updateStorageMTimeOnly(string $internalPath): void {
$fileId = $this->cache->getId($internalPath);
if ($fileId !== -1) {
$mtime = $this->storage->filemtime($internalPath);
@@ -266,11 +220,9 @@ class Updater implements IUpdater {
}
/**
* update the storage_mtime of the direct parent in the cache to the mtime from the storage
*
* @param string $internalPath
* Update the storage_mtime of the direct parent in the cache to the mtime from the storage
*/
private function correctParentStorageMtime($internalPath) {
private function correctParentStorageMtime(string $internalPath): void {
$parentId = $this->cache->getParentId($internalPath);
$parent = dirname($internalPath);
if ($parentId != -1) {
+6 -15
View File
@@ -8,6 +8,7 @@
namespace OC\Files\Cache;
use OC\Files\Storage\Storage;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Cache\IScanner;
use OCP\Files\Cache\IWatcher;
@@ -17,22 +18,12 @@ use OCP\Files\Storage\IStorage;
* check the storage backends for updates and change the cache accordingly
*/
class Watcher implements IWatcher {
protected $watchPolicy = self::CHECK_ONCE;
protected $checkedPaths = [];
/**
* @var Cache $cache
*/
protected $cache;
/**
* @var IScanner $scanner ;
*/
protected $scanner;
protected int $watchPolicy = self::CHECK_ONCE;
protected array $checkedPaths = [];
protected ICache $cache;
protected IScanner $scanner;
/** @var callable[] */
protected $onUpdate = [];
protected array $onUpdate = [];
protected ?string $checkFilter = null;
@@ -280,7 +280,6 @@ class CacheJail extends CacheWrapper {
*
* Note that this should make sure the entries are removed from the source cache
*
* @param ICache $sourceCache
* @param string $sourcePath
* @param string $targetPath
*/
@@ -10,13 +10,9 @@ namespace OC\Files\Cache\Wrapper;
use OCP\Files\Cache\ICache;
class CachePermissionsMask extends CacheWrapper {
/**
* @param ICache $cache
* @param int $mask
*/
public function __construct(
$cache,
protected $mask,
ICache $cache,
protected readonly int $mask,
) {
parent::__construct($cache);
}
@@ -11,20 +11,11 @@ use OCP\Files\Mount\IMountPoint;
use OCP\IUser;
class LazyStorageMountInfo extends CachedMountInfo {
/**
* CachedMountInfo constructor.
*
* @param IUser $user
* @param IMountPoint $mount
*/
public function __construct(
IUser $user,
private IMountPoint $mount,
) {
$this->user = $user;
$this->rootId = 0;
$this->storageId = 0;
$this->mountPoint = '';
parent::__construct($user, 0, 0, '', '');
$this->key = '';
}
@@ -14,11 +14,6 @@ use OCP\Files\Config\IUserMountCache;
* Listen to hooks and update the mount cache as needed
*/
class UserMountCacheListener {
/**
* UserMountCacheListener constructor.
*
* @param IUserMountCache $userMountCache
*/
public function __construct(
private IUserMountCache $userMountCache,
) {
+1 -1
View File
@@ -43,7 +43,7 @@ class LockManager implements ILockManager {
if ($this->lockProviderClass) {
try {
$this->lockProvider = Server::get($this->lockProviderClass);
} catch (NotFoundExceptionInterface|ContainerExceptionInterface $e) {
} catch (NotFoundExceptionInterface|ContainerExceptionInterface) {
}
}
+21 -36
View File
@@ -11,63 +11,49 @@ use OC\Files\Filesystem;
use OC\Files\Storage\Storage;
use OC\Files\Storage\StorageFactory;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage\IStorage;
use OCP\Files\Storage\IStorageFactory;
use OCP\Server;
use Psr\Log\LoggerInterface;
class MountPoint implements IMountPoint {
/**
* @var Storage|null $storage
*/
/** @var IStorage|null $storage */
protected $storage = null;
protected $class;
protected $storageId;
protected $numericStorageId = null;
protected $rootId = null;
/** @var class-string<IStorage> */
protected string $class;
protected ?string $storageId = null;
protected ?int $numericStorageId = null;
protected ?int $rootId = null;
/**
* Configuration options for the storage backend
*
* @var array
*/
protected $arguments = [];
protected $mountPoint;
protected array $arguments = [];
protected string $mountPoint;
/**
* Mount specific options
*
* @var array
*/
protected $mountOptions = [];
/**
* @var StorageFactory $loader
*/
private $loader;
protected array $mountOptions = [];
private IStorageFactory $loader;
/**
* Specified whether the storage is invalid after failing to
* instantiate it.
*
* @var bool
*/
private $invalidStorage = false;
/** @var string */
protected $mountProvider;
private bool $invalidStorage = false;
protected string $mountProvider;
/**
* @param string|Storage $storage
* @param string $mountpoint
* @param IStorage|class-string<IStorage> $storage
* @param array $arguments (optional) configuration for the storage backend
* @param IStorageFactory $loader
* @param array $mountOptions mount specific options
* @param int|null $mountId
* @param string|null $mountProvider
* @param ?array $mountOptions mount specific options
* @param ?int $mountId
* @param ?string $mountProvider
* @throws \Exception
*/
public function __construct(
$storage,
string|IStorage $storage,
string $mountpoint,
?array $arguments = null,
?IStorageFactory $loader = null,
@@ -88,8 +74,7 @@ class MountPoint implements IMountPoint {
$this->mountOptions = $mountOptions;
}
$mountpoint = $this->formatPath($mountpoint);
$this->mountPoint = $mountpoint;
$this->mountPoint = $this->formatPath($mountpoint);
if ($storage instanceof Storage) {
$this->class = get_class($storage);
$this->storage = $this->loader->wrap($this, $storage);
@@ -140,6 +125,7 @@ class MountPoint implements IMountPoint {
$class = $this->class;
// prevent recursion by setting the storage before applying wrappers
$this->storage = new $class($this->arguments);
/** @psalm-suppress UndefinedInterfaceMethod This is a StorageFactory */
$this->storage = $this->loader->wrap($this, $this->storage);
} catch (\Exception $exception) {
$this->storage = null;
@@ -155,12 +141,11 @@ class MountPoint implements IMountPoint {
} else {
Server::get(LoggerInterface::class)->error('Storage backend ' . $this->class . ' not found', ['app' => 'core']);
$this->invalidStorage = true;
return;
}
}
/**
* @return Storage|null
* @return IStorage|null
*/
public function getStorage() {
if (is_null($this->storage)) {
+6 -11
View File
@@ -10,23 +10,20 @@ use OCP\Files\Notify\IChange;
class Change implements IChange {
/**
* Change constructor.
*
* @param int $type
* @param string $path
* @param IChange::ADDED|IChange::REMOVED|IChange::MODIFIED|IChange::RENAMED $type
*/
public function __construct(
private $type,
private $path,
private readonly int $type,
private readonly string $path,
) {
}
/**
* Get the type of the change
*
* @return int IChange::ADDED, IChange::REMOVED, IChange::MODIFIED or IChange::RENAMED
* @return IChange::ADDED|IChange::REMOVED|IChange::MODIFIED|IChange::RENAMED
*/
public function getType() {
public function getType(): int {
return $this->type;
}
@@ -34,10 +31,8 @@ class Change implements IChange {
* Get the path of the file that was changed relative to the root of the storage
*
* Note, for rename changes this path is the old path for the file
*
* @return mixed
*/
public function getPath() {
public function getPath(): string {
return $this->path;
}
}
+6 -11
View File
@@ -6,30 +6,25 @@
*/
namespace OC\Files\Notify;
use OCP\Files\Notify\IChange;
use OCP\Files\Notify\IRenameChange;
class RenameChange extends Change implements IRenameChange {
/**
* Change constructor.
*
* @param int $type
* @param string $path
* @param string $targetPath
* @param IChange::ADDED|IChange::REMOVED|IChange::MODIFIED|IChange::RENAMED $type
*/
public function __construct(
$type,
$path,
private $targetPath,
int $type,
string $path,
private readonly string $targetPath,
) {
parent::__construct($type, $path);
}
/**
* Get the new path of the renamed file relative to the storage root
*
* @return string
*/
public function getTargetPath() {
public function getTargetPath(): string {
return $this->targetPath;
}
}
@@ -14,9 +14,6 @@ use function is_resource;
* Object store that wraps a storage backend, mostly for testing purposes
*/
class StorageObjectStore implements IObjectStore {
/**
* @param IStorage $storage
*/
public function __construct(
private IStorage $storage,
) {
+6 -14
View File
@@ -28,8 +28,7 @@ use Psr\Http\Message\RequestInterface;
use Psr\Log\LoggerInterface;
class SwiftFactory {
/** @var Container|null */
private $container = null;
private ?Container $container = null;
public const DEFAULT_OPTIONS = [
'autocreate' => false,
@@ -48,10 +47,9 @@ class SwiftFactory {
/**
* Gets currently cached token id
*
* @return string
* @throws StorageAuthException
*/
public function getCachedTokenId() {
public function getCachedTokenId(): string {
if (!isset($this->params['cachedToken'])) {
throw new StorageAuthException('Unauthenticated ObjectStore connection');
}
@@ -95,10 +93,9 @@ class SwiftFactory {
}
/**
* @return OpenStack
* @throws StorageAuthException
*/
private function getClient() {
private function getClient(): OpenStack {
if (isset($this->params['bucket'])) {
$this->params['container'] = $this->params['bucket'];
}
@@ -143,12 +140,9 @@ class SwiftFactory {
}
/**
* @param IdentityV2Service|IdentityV3Service $authService
* @param string $cacheKey
* @return OpenStack
* @throws StorageAuthException
*/
private function auth($authService, string $cacheKey) {
private function auth(IdentityV2Service|IdentityV3Service $authService, string $cacheKey): OpenStack {
$this->params['identityService'] = $authService;
$this->params['authUrl'] = $this->params['url'];
@@ -212,11 +206,10 @@ class SwiftFactory {
}
/**
* @return \OpenStack\ObjectStore\v1\Models\Container
* @throws StorageAuthException
* @throws StorageNotAvailableException
*/
public function getContainer() {
public function getContainer(): Container {
if (is_null($this->container)) {
$this->container = $this->createContainer();
}
@@ -225,11 +218,10 @@ class SwiftFactory {
}
/**
* @return \OpenStack\ObjectStore\v1\Models\Container
* @throws StorageAuthException
* @throws StorageNotAvailableException
*/
private function createContainer() {
private function createContainer(): Container {
$client = $this->getClient();
$objectStoreService = $client->objectStoreV1();
-10
View File
@@ -12,16 +12,6 @@ use OCP\Files\Search\ISearchQuery;
use OCP\IUser;
class SearchQuery implements ISearchQuery {
/**
* SearchQuery constructor.
*
* @param ISearchOperator $searchOperation
* @param int $limit
* @param int $offset
* @param array $order
* @param ?IUser $user
* @param bool $limitToHome
*/
public function __construct(
private ISearchOperator $searchOperation,
private int $limit,
@@ -18,9 +18,6 @@ use OCP\Files\SimpleFS\ISimpleFile;
class NewSimpleFile implements ISimpleFile {
private ?File $file = null;
/**
* File constructor.
*/
public function __construct(
private Folder $parentFolder,
private string $name,
@@ -14,11 +14,6 @@ use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
class SimpleFolder implements ISimpleFolder {
/**
* Folder constructor.
*
* @param Folder $folder
*/
public function __construct(
private Folder $folder,
) {
+2 -3
View File
@@ -9,10 +9,9 @@ namespace OC\Files\Storage;
class CommonTest extends Common {
/**
* underlying local storage used for missing functions
* @var Local
* Underlying local storage used for missing functions
*/
private $storage;
private Local $storage;
public function __construct(array $parameters) {
$this->storage = new Local($parameters);
+2 -9
View File
@@ -22,15 +22,8 @@ use OCP\Server;
* Specialized version of Local storage for home directory usage
*/
class Home extends Local implements IHomeStorage {
/**
* @var string
*/
protected $id;
/**
* @var User $user
*/
protected $user;
protected string $id;
protected IUser $user;
/**
* Construct a Home storage instance
+4 -13
View File
@@ -48,26 +48,17 @@ class Scanner extends PublicEmitter {
/**
* Whether to use a DB transaction
*
* @var bool
*/
protected $useTransaction;
protected bool $useTransaction;
/**
* Number of entries scanned to commit
*
* @var int
*/
protected $entriesToCommit;
protected int $entriesToCommit = 0;
/**
* @param string $user
* @param IDBConnection|null $db
* @param IEventDispatcher $dispatcher
*/
public function __construct(
private $user,
protected $db,
private string $user,
protected ?IDBConnection $db,
private IEventDispatcher $dispatcher,
protected LoggerInterface $logger,
) {
+1 -1
View File
@@ -1959,7 +1959,7 @@ class View {
throw new InvalidPathException($l->t('Path contains invalid segments'));
}
// Short cut for read-only validation
// Shortcut for read-only validation
if ($readonly) {
$validator = Server::get(FilenameValidator::class);
if ($validator->isForbidden($fileName)) {
+6 -20
View File
@@ -7,35 +7,21 @@
namespace OC\GlobalScale;
use OCP\IConfig;
use Override;
class Config implements \OCP\GlobalScale\IConfig {
/**
* Config constructor.
*
* @param IConfig $config
*/
public function __construct(
private IConfig $config,
private readonly IConfig $config,
) {
}
/**
* check if global scale is enabled
*
* @since 12.0.1
* @return bool
*/
public function isGlobalScaleEnabled() {
#[Override]
public function isGlobalScaleEnabled(): bool {
return $this->config->getSystemValueBool('gs.enabled', false);
}
/**
* check if federation should only be used internally in a global scale setup
*
* @since 12.0.1
* @return bool
*/
public function onlyInternalFederation() {
#[Override]
public function onlyInternalFederation(): bool {
// if global scale is disabled federation works always globally
$gsEnabled = $this->isGlobalScaleEnabled();
if ($gsEnabled === false) {
+2 -4
View File
@@ -37,10 +37,8 @@ use OCP\Server;
class Group implements IGroup {
/** @var User[] */
private $users = [];
/** @var bool */
private $usersLoaded;
private array $users = [];
private bool $usersLoaded = false;
public function __construct(
private string $gid,
+4 -10
View File
@@ -45,19 +45,13 @@ use function is_string;
*/
class Manager extends PublicEmitter implements IGroupManager {
/** @var GroupInterface[] */
private $backends = [];
private array $backends = [];
/** @var array<string, IGroup> */
private $cachedGroups = [];
private array $cachedGroups = [];
/** @var array<string, list<string>> */
private $cachedUserGroups = [];
/** @var SubAdmin */
private $subAdmin = null;
private array $cachedUserGroups = [];
private ?SubAdmin $subAdmin = null;
private DisplayNameCache $displayNameCache;
private const MAX_GROUP_LENGTH = 255;
public function __construct(
@@ -39,9 +39,6 @@ class ClientService implements IClientService {
) {
}
/**
* @return Client
*/
public function newClient(): IClient {
$handler = new CurlHandler();
$stack = HandlerStack::create($handler);
+1 -4
View File
@@ -12,13 +12,10 @@ use OCP\Http\Client\IResponse;
use Psr\Http\Message\ResponseInterface;
class Response implements IResponse {
private ResponseInterface $response;
public function __construct(
ResponseInterface $response,
private ResponseInterface $response,
private bool $stream = false,
) {
$this->response = $response;
}
public function getBody() {
+2 -2
View File
@@ -9,8 +9,8 @@ declare(strict_types=1);
namespace OC\KnownUser;
class KnownUserService {
/** @var array */
protected $knownUsers = [];
/** @var array<string, array<string, bool>> $knownUsers */
protected array $knownUsers = [];
public function __construct(
protected KnownUserMapper $mapper,
+7 -12
View File
@@ -16,24 +16,19 @@ use Punic\Calendar;
use Symfony\Component\Translation\IdentityTranslator;
class L10N implements IL10N {
/** @var IdentityTranslator */
private $identityTranslator;
private ?IdentityTranslator $identityTranslator = null;
/** @var string[] */
private $translations = [];
private array $translations = [];
/**
* @param IFactory $factory
* @param string $app
* @param string $lang
* @param string $locale
* @param array $files
* @param string[] $files
*/
public function __construct(
protected IFactory $factory,
protected $app,
protected $lang,
protected $locale,
protected string $app,
protected string $lang,
protected ?string $locale,
array $files,
) {
foreach ($files as $languageFile) {
@@ -56,7 +51,7 @@ class L10N implements IL10N {
* @return string locale
*/
public function getLocaleCode(): string {
return $this->locale;
return $this->locale ?? '';
}
/**
+1 -4
View File
@@ -9,14 +9,11 @@ namespace OC\L10N;
class L10NString implements \JsonSerializable {
/**
* @param L10N $l10n
* @param string|string[] $text
* @param array $parameters
* @param int $count
*/
public function __construct(
protected L10N $l10n,
protected $text,
protected string|array $text,
protected array $parameters,
protected int $count = 1,
) {
+1 -1
View File
@@ -13,7 +13,7 @@ use OCP\IUser;
use OCP\L10N\ILanguageIterator;
class LanguageIterator implements ILanguageIterator {
private $i = 0;
private int $i = 0;
public function __construct(
private IUser $user,
+1 -3
View File
@@ -11,9 +11,7 @@ namespace OC\L10N;
use OCP\IL10N;
class LazyL10N implements IL10N {
/** @var IL10N */
private $l;
private ?IL10N $l = null;
public function __construct(
private \Closure $factory,
+1 -4
View File
@@ -13,11 +13,8 @@ use OCP\ICache;
* @template-implements \ArrayAccess<string,mixed>
*/
abstract class Cache implements \ArrayAccess, ICache {
/**
* @param string $prefix
*/
public function __construct(
protected $prefix = '',
protected string $prefix = '',
) {
}
+3 -13
View File
@@ -14,28 +14,18 @@ use OCP\IMemcacheTTL;
* Cache wrapper that logs the cache operation in a log file
*/
class LoggerWrapperCache extends Cache implements IMemcacheTTL {
/** @var Redis */
protected $wrappedCache;
/** @var string $prefix */
protected $prefix;
public function __construct(
Redis $wrappedCache,
protected Redis $wrappedCache,
private string $logFile,
) {
parent::__construct($wrappedCache->getPrefix());
$this->wrappedCache = $wrappedCache;
}
/**
* @return string Prefix used for caching purposes
*/
public function getPrefix() {
public function getPrefix(): string {
return $this->prefix;
}
protected function getNameSpace() {
protected function getNameSpace(): string {
return $this->prefix;
}
@@ -13,30 +13,25 @@ use OCP\Authentication\Exceptions\PasswordUnavailableException;
*/
interface ICredentials {
/**
* Get the user UID
* Get the user UID.
*
* @since 12
*
* @return string
* @since 12.0.0
*/
public function getUID();
public function getUID(): string;
/**
* Get the login name the users used to login
* Get the login name the users used to log in.
*
* @since 12
*
* @return string
* @since 12.0.0
*/
public function getLoginName();
public function getLoginName(): string;
/**
* Get the password
* Get the password.
*
* @since 12
* @since 12.0.0
*
* @return string|null
* @throws PasswordUnavailableException
*/
public function getPassword();
public function getPassword(): ?string;
}
+5 -9
View File
@@ -18,10 +18,9 @@ interface IUpdater {
/**
* Get the propagator for etags and mtime for the view the updater works on
*
* @return IPropagator
* @since 9.0.0
*/
public function getPropagator();
public function getPropagator(): IPropagator;
/**
* Propagate etag and mtime changes for the parent folders of $path up to the root of the filesystem
@@ -30,16 +29,13 @@ interface IUpdater {
* @param int|null $time the timestamp to set as mtime for the parent folders, if left out the current time is used
* @since 9.0.0
*/
public function propagate($path, $time = null);
public function propagate(string $path, ?int $time = null): void;
/**
* Update the cache for $path and update the size, etag and mtime of the parent folders
*
* @param string $path
* @param int $time
* @since 9.0.0
*/
public function update($path, $time = null, ?int $sizeDifference = null);
public function update(string $path, ?int $time = null, ?int $sizeDifference = null): void;
/**
* Remove $path from the cache and update the size, etag and mtime of the parent folders
@@ -47,7 +43,7 @@ interface IUpdater {
* @param string $path
* @since 9.0.0
*/
public function remove($path);
public function remove(string $path): void;
/**
* Rename a file or folder in the cache and update the size, etag and mtime of the parent folders
@@ -57,7 +53,7 @@ interface IUpdater {
* @param string $target
* @since 9.0.0
*/
public function renameFromStorage(IStorage $sourceStorage, $source, $target);
public function renameFromStorage(IStorage $sourceStorage, string $source, string $target): void;
/**
* Copy a file or folder in the cache and update the size, etag and mtime of the parent folders
+7 -6
View File
@@ -6,6 +6,8 @@
*/
namespace OCP\GlobalScale;
use OCP\AppFramework\Attribute\Consumable;
/**
* Interface IConfig
*
@@ -13,20 +15,19 @@ namespace OCP\GlobalScale;
*
* @since 12.0.1
*/
#[Consumable(since: '12.0.1')]
interface IConfig {
/**
* check if global scale is enabled
* Check if global scale is enabled.
*
* @since 12.0.1
* @return bool
*/
public function isGlobalScaleEnabled();
public function isGlobalScaleEnabled(): bool;
/**
* check if federation should only be used internally in a global scale setup
* Check if federation should only be used internally in a global scale setup.
*
* @since 12.0.1
* @return bool
*/
public function onlyInternalFederation();
public function onlyInternalFederation(): bool;
}
@@ -515,7 +515,7 @@ class LoginControllerTest extends TestCase {
$rememberme,
'/apps/files'
);
$loginResult = LoginResult::failure($loginData, LoginController::LOGIN_MSG_INVALIDPASSWORD);
$loginResult = LoginResult::failure(LoginController::LOGIN_MSG_INVALIDPASSWORD);
$loginChain->expects($this->once())
->method('process')
->with($this->equalTo($loginData))
@@ -553,7 +553,7 @@ class LoginControllerTest extends TestCase {
$password,
$rememberme,
);
$loginResult = LoginResult::success($loginData);
$loginResult = LoginResult::success();
$loginChain->expects($this->once())
->method('process')
->with($this->equalTo($loginData))
@@ -658,7 +658,7 @@ class LoginControllerTest extends TestCase {
$rememberme,
'/apps/mail'
);
$loginResult = LoginResult::success($loginData);
$loginResult = LoginResult::success();
$loginChain->expects($this->once())
->method('process')
->with($this->equalTo($loginData))
@@ -694,7 +694,7 @@ class LoginControllerTest extends TestCase {
$rememberme,
'/apps/files'
);
$loginResult = LoginResult::failure($loginData, LoginController::LOGIN_MSG_INVALIDPASSWORD);
$loginResult = LoginResult::failure(LoginController::LOGIN_MSG_INVALIDPASSWORD);
$loginChain->expects($this->once())
->method('process')
->with($this->equalTo($loginData))