diff options
author | Kate <26026535+provokateurin@users.noreply.github.com> | 2024-10-22 12:47:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-22 12:47:45 +0200 |
commit | 070adc1131fcd5476e4a93ebf28be6f409c5a992 (patch) | |
tree | 1e8e2238a22d544c370f1ac804426ed675c5eacf /apps/files_external | |
parent | 582af10e0be1b22ebde0429b756f62107d8e8083 (diff) | |
parent | e8426996f59ab6dbf0c94adee8f410cbd572b11a (diff) | |
download | nextcloud-server-070adc1131fcd5476e4a93ebf28be6f409c5a992.tar.gz nextcloud-server-070adc1131fcd5476e4a93ebf28be6f409c5a992.zip |
Merge pull request #48790 from nextcloud/refactor/apps/constructor-property-promotion
Diffstat (limited to 'apps/files_external')
39 files changed, 152 insertions, 325 deletions
diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index 4ba0e40ce46..761fc97b7aa 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -47,6 +47,7 @@ use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\AppFramework\QueryException; use OCP\Files\Config\IMountProviderCollection; use OCP\Group\Events\GroupDeletedEvent; use OCP\User\Events\UserDeletedEvent; @@ -62,7 +63,7 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide /** * Application constructor. * - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ public function __construct(array $urlParams = []) { parent::__construct(self::APP_ID, $urlParams); diff --git a/apps/files_external/lib/BackgroundJob/CredentialsCleanup.php b/apps/files_external/lib/BackgroundJob/CredentialsCleanup.php index 6d86c2f347b..90a5ae17ab2 100644 --- a/apps/files_external/lib/BackgroundJob/CredentialsCleanup.php +++ b/apps/files_external/lib/BackgroundJob/CredentialsCleanup.php @@ -18,22 +18,14 @@ use OCP\IUserManager; use OCP\Security\ICredentialsManager; class CredentialsCleanup extends TimedJob { - private $credentialsManager; - private $userGlobalStoragesService; - private $userManager; - public function __construct( ITimeFactory $time, - ICredentialsManager $credentialsManager, - UserGlobalStoragesService $userGlobalStoragesService, - IUserManager $userManager, + private ICredentialsManager $credentialsManager, + private UserGlobalStoragesService $userGlobalStoragesService, + private IUserManager $userManager, ) { parent::__construct($time); - $this->credentialsManager = $credentialsManager; - $this->userGlobalStoragesService = $userGlobalStoragesService; - $this->userManager = $userManager; - // run every day $this->setInterval(24 * 60 * 60); $this->setTimeSensitivity(self::TIME_INSENSITIVE); diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php index be435d4de2f..c84fbb19102 100644 --- a/apps/files_external/lib/Config/ConfigAdapter.php +++ b/apps/files_external/lib/Config/ConfigAdapter.php @@ -15,7 +15,9 @@ use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\MountConfig; use OCA\Files_External\Service\UserGlobalStoragesService; use OCA\Files_External\Service\UserStoragesService; +use OCP\AppFramework\QueryException; use OCP\Files\Config\IMountProvider; +use OCP\Files\Mount\IMountPoint; use OCP\Files\ObjectStore\IObjectStore; use OCP\Files\Storage\IConstructableStorage; use OCP\Files\Storage\IStorage; @@ -40,7 +42,7 @@ class ConfigAdapter implements IMountProvider { /** * Process storage ready for mounting * - * @throws \OCP\AppFramework\QueryException + * @throws QueryException */ private function prepareStorageConfig(StorageConfig &$storage, IUser $user): void { foreach ($storage->getBackendOptions() as $option => $value) { @@ -82,7 +84,7 @@ class ConfigAdapter implements IMountProvider { /** * Get all mountpoints applicable for the user * - * @return \OCP\Files\Mount\IMountPoint[] + * @return IMountPoint[] */ public function getMountsForUser(IUser $user, IStorageFactory $loader) { $this->userStoragesService->setUser($user); diff --git a/apps/files_external/lib/Config/ExternalMountPoint.php b/apps/files_external/lib/Config/ExternalMountPoint.php index fea1976780e..0dc2eab5120 100644 --- a/apps/files_external/lib/Config/ExternalMountPoint.php +++ b/apps/files_external/lib/Config/ExternalMountPoint.php @@ -11,11 +11,15 @@ use OCA\Files_External\Lib\StorageConfig; class ExternalMountPoint extends MountPoint { - /** @var StorageConfig */ - protected $storageConfig; - - public function __construct(StorageConfig $storageConfig, $storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) { - $this->storageConfig = $storageConfig; + public function __construct( + protected StorageConfig $storageConfig, + $storage, + $mountpoint, + $arguments = null, + $loader = null, + $mountOptions = null, + $mountId = null, + ) { parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId, ConfigAdapter::class); } diff --git a/apps/files_external/lib/Config/UserContext.php b/apps/files_external/lib/Config/UserContext.php index 5d9d2910ea2..6fe679c60b2 100644 --- a/apps/files_external/lib/Config/UserContext.php +++ b/apps/files_external/lib/Config/UserContext.php @@ -14,26 +14,15 @@ use OCP\Share\IManager as ShareManager; class UserContext { - /** @var IUserSession */ - private $session; - - /** @var ShareManager */ - private $shareManager; - - /** @var IRequest */ - private $request; - /** @var string */ private $userId; - /** @var IUserManager */ - private $userManager; - - public function __construct(IUserSession $session, ShareManager $manager, IRequest $request, IUserManager $userManager) { - $this->session = $session; - $this->shareManager = $manager; - $this->request = $request; - $this->userManager = $userManager; + public function __construct( + private IUserSession $session, + private ShareManager $shareManager, + private IRequest $request, + private IUserManager $userManager, + ) { } public function getSession(): IUserSession { @@ -48,7 +37,7 @@ class UserContext { if ($this->userId !== null) { return $this->userId; } - if ($this->session && $this->session->getUser() !== null) { + if ($this->session->getUser() !== null) { return $this->session->getUser()->getUID(); } try { diff --git a/apps/files_external/lib/Controller/AjaxController.php b/apps/files_external/lib/Controller/AjaxController.php index dab7e092f00..dfc5947ed77 100644 --- a/apps/files_external/lib/Controller/AjaxController.php +++ b/apps/files_external/lib/Controller/AjaxController.php @@ -16,15 +16,6 @@ use OCP\IRequest; use OCP\IUserSession; class AjaxController extends Controller { - /** @var RSA */ - private $rsaMechanism; - /** @var GlobalAuth */ - private $globalAuth; - /** @var IUserSession */ - private $userSession; - /** @var IGroupManager */ - private $groupManager; - /** * @param string $appName * @param IRequest $request @@ -33,17 +24,15 @@ class AjaxController extends Controller { * @param IUserSession $userSession * @param IGroupManager $groupManager */ - public function __construct($appName, + public function __construct( + $appName, IRequest $request, - RSA $rsaMechanism, - GlobalAuth $globalAuth, - IUserSession $userSession, - IGroupManager $groupManager) { + private RSA $rsaMechanism, + private GlobalAuth $globalAuth, + private IUserSession $userSession, + private IGroupManager $groupManager, + ) { parent::__construct($appName, $request); - $this->rsaMechanism = $rsaMechanism; - $this->globalAuth = $globalAuth; - $this->userSession = $userSession; - $this->groupManager = $groupManager; } /** diff --git a/apps/files_external/lib/Controller/ApiController.php b/apps/files_external/lib/Controller/ApiController.php index cb8d8cbb0ff..5a7eddf1540 100644 --- a/apps/files_external/lib/Controller/ApiController.php +++ b/apps/files_external/lib/Controller/ApiController.php @@ -25,18 +25,13 @@ use OCP\IRequest; */ class ApiController extends OCSController { - private UserGlobalStoragesService $userGlobalStoragesService; - private UserStoragesService $userStoragesService; - public function __construct( string $appName, IRequest $request, - UserGlobalStoragesService $userGlobalStorageService, - UserStoragesService $userStorageService, + private UserGlobalStoragesService $userGlobalStoragesService, + private UserStoragesService $userStoragesService, ) { parent::__construct($appName, $request); - $this->userGlobalStoragesService = $userGlobalStorageService; - $this->userStoragesService = $userStorageService; } /** diff --git a/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php b/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php index f11dab2785f..ee23c28b993 100644 --- a/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php +++ b/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php @@ -21,12 +21,10 @@ class GlobalAuth extends AuthMechanism { public const CREDENTIALS_IDENTIFIER = 'password::global'; private const PWD_PLACEHOLDER = '************************'; - /** @var ICredentialsManager */ - protected $credentialsManager; - - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { - $this->credentialsManager = $credentialsManager; - + public function __construct( + IL10N $l, + protected ICredentialsManager $credentialsManager, + ) { $this ->setIdentifier('password::global') ->setVisibility(BackendService::VISIBILITY_DEFAULT) diff --git a/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php b/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php index 5c36f843307..176e1877d94 100644 --- a/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php +++ b/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php @@ -28,31 +28,14 @@ use OCP\User\Events\UserLoggedInEvent; class LoginCredentials extends AuthMechanism { public const CREDENTIALS_IDENTIFIER = 'password::logincredentials/credentials'; - /** @var ISession */ - protected $session; - - /** @var ICredentialsManager */ - protected $credentialsManager; - - /** @var CredentialsStore */ - private $credentialsStore; - - /** @var ILDAPProviderFactory */ - private $ldapFactory; - public function __construct( IL10N $l, - ISession $session, - ICredentialsManager $credentialsManager, - CredentialsStore $credentialsStore, + protected ISession $session, + protected ICredentialsManager $credentialsManager, + private CredentialsStore $credentialsStore, IEventDispatcher $eventDispatcher, - ILDAPProviderFactory $ldapFactory, + private ILDAPProviderFactory $ldapFactory, ) { - $this->session = $session; - $this->credentialsManager = $credentialsManager; - $this->credentialsStore = $credentialsStore; - $this->ldapFactory = $ldapFactory; - $this ->setIdentifier('password::logincredentials') ->setScheme(self::SCHEME_PASSWORD) diff --git a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php index 314ab82385e..ced43ebf357 100644 --- a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php +++ b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php @@ -22,12 +22,10 @@ use OCP\IUser; */ class SessionCredentials extends AuthMechanism { - /** @var CredentialsStore */ - private $credentialsStore; - - public function __construct(IL10N $l, CredentialsStore $credentialsStore) { - $this->credentialsStore = $credentialsStore; - + public function __construct( + IL10N $l, + private CredentialsStore $credentialsStore, + ) { $this->setIdentifier('password::sessioncredentials') ->setScheme(self::SCHEME_PASSWORD) ->setText($l->t('Log-in credentials, save in session')) diff --git a/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php b/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php index 84f2c698f07..cb7165261ac 100644 --- a/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php +++ b/apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php @@ -23,12 +23,10 @@ use OCP\Security\ICredentialsManager; class UserGlobalAuth extends AuthMechanism { private const CREDENTIALS_IDENTIFIER = 'password::global'; - /** @var ICredentialsManager */ - protected $credentialsManager; - - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { - $this->credentialsManager = $credentialsManager; - + public function __construct( + IL10N $l, + protected ICredentialsManager $credentialsManager, + ) { $this ->setIdentifier('password::global::user') ->setVisibility(BackendService::VISIBILITY_DEFAULT) diff --git a/apps/files_external/lib/Lib/Auth/Password/UserProvided.php b/apps/files_external/lib/Lib/Auth/Password/UserProvided.php index a7c51d7353a..7f937cf14c1 100644 --- a/apps/files_external/lib/Lib/Auth/Password/UserProvided.php +++ b/apps/files_external/lib/Lib/Auth/Password/UserProvided.php @@ -22,12 +22,10 @@ use OCP\Security\ICredentialsManager; class UserProvided extends AuthMechanism implements IUserProvided { public const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/'; - /** @var ICredentialsManager */ - protected $credentialsManager; - - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { - $this->credentialsManager = $credentialsManager; - + public function __construct( + IL10N $l, + protected ICredentialsManager $credentialsManager, + ) { $this ->setIdentifier('password::userprovided') ->setVisibility(BackendService::VISIBILITY_ADMIN) diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php index 9b47cf72bb7..2371ce0a219 100644 --- a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php +++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php @@ -19,12 +19,10 @@ use phpseclib\Crypt\RSA as RSACrypt; */ class RSA extends AuthMechanism { - /** @var IConfig */ - private $config; - - public function __construct(IL10N $l, IConfig $config) { - $this->config = $config; - + public function __construct( + IL10N $l, + private IConfig $config, + ) { $this ->setIdentifier('publickey::rsa') ->setScheme(self::SCHEME_PUBLICKEY) diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php index ab770d25d09..8c2e2f3d6ec 100644 --- a/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php +++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php @@ -18,12 +18,10 @@ use phpseclib\Crypt\RSA as RSACrypt; */ class RSAPrivateKey extends AuthMechanism { - /** @var IConfig */ - private $config; - - public function __construct(IL10N $l, IConfig $config) { - $this->config = $config; - + public function __construct( + IL10N $l, + private IConfig $config, + ) { $this ->setIdentifier('publickey::rsa_private') ->setScheme(self::SCHEME_PUBLICKEY) diff --git a/apps/files_external/lib/Lib/Auth/SMB/KerberosApacheAuth.php b/apps/files_external/lib/Lib/Auth/SMB/KerberosApacheAuth.php index 7a6ecb08ae5..26671110294 100644 --- a/apps/files_external/lib/Lib/Auth/SMB/KerberosApacheAuth.php +++ b/apps/files_external/lib/Lib/Auth/SMB/KerberosApacheAuth.php @@ -13,10 +13,10 @@ use OCP\Authentication\LoginCredentials\IStore; use OCP\IL10N; class KerberosApacheAuth extends AuthMechanism { - /** @var IStore */ - private $credentialsStore; - - public function __construct(IL10N $l, IStore $credentialsStore) { + public function __construct( + IL10N $l, + private IStore $credentialsStore, + ) { $realm = new DefinitionParameter('default_realm', 'Default realm'); $realm ->setType(DefinitionParameter::VALUE_TEXT) @@ -27,7 +27,6 @@ class KerberosApacheAuth extends AuthMechanism { ->setScheme(self::SCHEME_SMB) ->setText($l->t('Kerberos ticket Apache mode')) ->addParameter($realm); - $this->credentialsStore = $credentialsStore; } public function getCredentialsStore(): IStore { diff --git a/apps/files_external/lib/Lib/Backend/InvalidBackend.php b/apps/files_external/lib/Lib/Backend/InvalidBackend.php index 22d0287244a..6082d46bd67 100644 --- a/apps/files_external/lib/Lib/Backend/InvalidBackend.php +++ b/apps/files_external/lib/Lib/Backend/InvalidBackend.php @@ -16,21 +16,19 @@ use OCP\IUser; */ class InvalidBackend extends Backend { - /** @var string Invalid backend id */ - private $invalidId; - /** * Constructs a new InvalidBackend with the id of the invalid backend * for display purposes * * @param string $invalidId id of the backend that did not exist */ - public function __construct($invalidId) { - $this->invalidId = $invalidId; + public function __construct( + private $invalidId, + ) { $this - ->setIdentifier($invalidId) + ->setIdentifier($this->invalidId) ->setStorageClass('\OC\Files\Storage\FailedStorage') - ->setText('Unknown storage backend ' . $invalidId); + ->setText('Unknown storage backend ' . $this->invalidId); } /** diff --git a/apps/files_external/lib/Lib/DefinitionParameter.php b/apps/files_external/lib/Lib/DefinitionParameter.php index 584fee1e498..1e611edd1ed 100644 --- a/apps/files_external/lib/Lib/DefinitionParameter.php +++ b/apps/files_external/lib/Lib/DefinitionParameter.php @@ -25,12 +25,6 @@ class DefinitionParameter implements \JsonSerializable { public const FLAG_OPTIONAL = 1; public const FLAG_USER_PROVIDED = 2; - /** @var string name of parameter */ - private string $name; - - /** @var string human-readable parameter text */ - private string $text; - /** @var string human-readable parameter tooltip */ private string $tooltip = ''; @@ -40,18 +34,16 @@ class DefinitionParameter implements \JsonSerializable { /** @var int flags, see self::FLAG_* constants */ private int $flags = self::FLAG_NONE; - /** @var mixed */ - private $defaultValue; - /** * @param string $name parameter name * @param string $text parameter description * @param mixed $defaultValue default value */ - public function __construct(string $name, string $text, $defaultValue = null) { - $this->name = $name; - $this->text = $text; - $this->defaultValue = $defaultValue; + public function __construct( + private string $name, + private string $text, + private $defaultValue = null, + ) { } /** diff --git a/apps/files_external/lib/Lib/MissingDependency.php b/apps/files_external/lib/Lib/MissingDependency.php index 9f48a523861..5c2c6880f23 100644 --- a/apps/files_external/lib/Lib/MissingDependency.php +++ b/apps/files_external/lib/Lib/MissingDependency.php @@ -11,17 +11,15 @@ namespace OCA\Files_External\Lib; */ class MissingDependency { - /** @var string */ - private $dependency; - /** @var string|null Custom message */ private $message = null; /** * @param string $dependency */ - public function __construct($dependency) { - $this->dependency = $dependency; + public function __construct( + private $dependency, + ) { } public function getDependency(): string { diff --git a/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php b/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php index 153cae1bd38..deaf005e2c6 100644 --- a/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php +++ b/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php @@ -12,11 +12,6 @@ use OCP\Files\Notify\INotifyHandler; class SMBNotifyHandler implements INotifyHandler { /** - * @var \Icewind\SMB\INotifyHandler - */ - private $shareNotifyHandler; - - /** * @var string */ private $root; @@ -29,8 +24,10 @@ class SMBNotifyHandler implements INotifyHandler { * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler * @param string $root */ - public function __construct(\Icewind\SMB\INotifyHandler $shareNotifyHandler, $root) { - $this->shareNotifyHandler = $shareNotifyHandler; + public function __construct( + private \Icewind\SMB\INotifyHandler $shareNotifyHandler, + $root, + ) { $this->root = str_replace('\\', '/', $root); } diff --git a/apps/files_external/lib/Lib/PersonalMount.php b/apps/files_external/lib/Lib/PersonalMount.php index 610807bc7a2..01daddd7e2a 100644 --- a/apps/files_external/lib/Lib/PersonalMount.php +++ b/apps/files_external/lib/Lib/PersonalMount.php @@ -10,30 +10,27 @@ use OC\Files\Mount\MoveableMount; use OCA\Files_External\Config\ExternalMountPoint; use OCA\Files_External\Service\UserStoragesService; use OCP\Files\Storage\IStorage; +use OCP\Files\Storage\IStorageFactory; /** * Person mount points can be moved by the user */ class PersonalMount extends ExternalMountPoint implements MoveableMount { - /** @var UserStoragesService */ - protected $storagesService; - - /** @var int id of the external storage (mount) (not the numeric id of the resulting storage!) */ - protected $numericExternalStorageId; - /** * @param UserStoragesService $storagesService * @param int $storageId * @param IStorage $storage * @param string $mountpoint * @param array $arguments (optional) configuration for the storage backend - * @param \OCP\Files\Storage\IStorageFactory $loader + * @param IStorageFactory $loader * @param array $mountOptions mount specific options + * @param int $externalStorageId */ public function __construct( - UserStoragesService $storagesService, + protected UserStoragesService $storagesService, StorageConfig $storageConfig, - $externalStorageId, + /** @var int id of the external storage (mount) (not the numeric id of the resulting storage!) */ + protected $numericExternalStorageId, $storage, $mountpoint, $arguments = null, @@ -42,8 +39,6 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount { $mountId = null, ) { parent::__construct($storageConfig, $storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId); - $this->storagesService = $storagesService; - $this->numericExternalStorageId = $externalStorageId; } /** diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index 985d51dccd8..70b62e56474 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -17,7 +17,10 @@ use OC\Files\ObjectStore\SwiftFactory; use OC\Files\Storage\Common; use OCP\Cache\CappedMemoryCache; use OCP\Files\IMimeTypeDetector; +use OCP\Files\StorageAuthException; use OCP\Files\StorageBadConfigException; +use OCP\Files\StorageNotAvailableException; +use OCP\ICache; use OpenStack\Common\Error\BadResponseError; use OpenStack\ObjectStore\v1\Models\Container; use OpenStack\ObjectStore\v1\Models\StorageObject; @@ -55,7 +58,7 @@ class Swift extends Common { * \OpenCloud\OpenStack\ObjectStorage\Resource\DataObject for existing * paths and path to false for not existing paths. * - * @var \OCP\ICache + * @var ICache */ private $objectCache; @@ -81,8 +84,8 @@ class Swift extends Common { * * @return StorageObject|false object * or false if the object did not exist - * @throws \OCP\Files\StorageAuthException - * @throws \OCP\Files\StorageNotAvailableException + * @throws StorageAuthException + * @throws StorageNotAvailableException */ private function fetchObject(string $path): StorageObject|false { $cached = $this->objectCache->get($path); @@ -112,8 +115,8 @@ class Swift extends Common { * Returns whether the given path exists. * * @return bool true if the object exist, false otherwise - * @throws \OCP\Files\StorageAuthException - * @throws \OCP\Files\StorageNotAvailableException + * @throws StorageAuthException + * @throws StorageNotAvailableException */ private function doesObjectExist(string $path): bool { return $this->fetchObject($path) !== false; @@ -534,8 +537,8 @@ class Swift extends Common { * Returns the initialized object store container. * * @return Container - * @throws \OCP\Files\StorageAuthException - * @throws \OCP\Files\StorageNotAvailableException + * @throws StorageAuthException + * @throws StorageNotAvailableException */ public function getContainer(): Container { if (is_null($this->container)) { diff --git a/apps/files_external/lib/Listener/GroupDeletedListener.php b/apps/files_external/lib/Listener/GroupDeletedListener.php index aced4961e38..244b3b2371f 100644 --- a/apps/files_external/lib/Listener/GroupDeletedListener.php +++ b/apps/files_external/lib/Listener/GroupDeletedListener.php @@ -15,11 +15,9 @@ use OCP\Group\Events\GroupDeletedEvent; /** @template-implements IEventListener<GroupDeletedEvent> */ class GroupDeletedListener implements IEventListener { - /** @var DBConfigService */ - private $config; - - public function __construct(DBConfigService $config) { - $this->config = $config; + public function __construct( + private DBConfigService $config, + ) { } public function handle(Event $event): void { diff --git a/apps/files_external/lib/Listener/StorePasswordListener.php b/apps/files_external/lib/Listener/StorePasswordListener.php index 52da5450f49..8580176b014 100644 --- a/apps/files_external/lib/Listener/StorePasswordListener.php +++ b/apps/files_external/lib/Listener/StorePasswordListener.php @@ -17,11 +17,9 @@ use OCP\User\Events\UserLoggedInEvent; /** @template-implements IEventListener<PasswordUpdatedEvent|UserLoggedInEvent> */ class StorePasswordListener implements IEventListener { - /** @var ICredentialsManager */ - private $credentialsManager; - - public function __construct(ICredentialsManager $credentialsManager) { - $this->credentialsManager = $credentialsManager; + public function __construct( + private ICredentialsManager $credentialsManager, + ) { } public function handle(Event $event): void { diff --git a/apps/files_external/lib/Listener/UserDeletedListener.php b/apps/files_external/lib/Listener/UserDeletedListener.php index 24139350ae9..337fd12f311 100644 --- a/apps/files_external/lib/Listener/UserDeletedListener.php +++ b/apps/files_external/lib/Listener/UserDeletedListener.php @@ -15,11 +15,9 @@ use OCP\User\Events\UserDeletedEvent; /** @template-implements IEventListener<UserDeletedEvent> */ class UserDeletedListener implements IEventListener { - /** @var DBConfigService */ - private $config; - - public function __construct(DBConfigService $config) { - $this->config = $config; + public function __construct( + private DBConfigService $config, + ) { } public function handle(Event $event): void { diff --git a/apps/files_external/lib/Migration/Version1015Date20211104103506.php b/apps/files_external/lib/Migration/Version1015Date20211104103506.php index 0cd8ffdf275..6027c795cdf 100644 --- a/apps/files_external/lib/Migration/Version1015Date20211104103506.php +++ b/apps/files_external/lib/Migration/Version1015Date20211104103506.php @@ -20,14 +20,10 @@ use Psr\Log\LoggerInterface; class Version1015Date20211104103506 extends SimpleMigrationStep { - /** @var IDBConnection */ - private $connection; - /** @var LoggerInterface */ - private $logger; - - public function __construct(IDBConnection $connection, LoggerInterface $logger) { - $this->connection = $connection; - $this->logger = $logger; + public function __construct( + private IDBConnection $connection, + private LoggerInterface $logger, + ) { } public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { @@ -64,7 +60,7 @@ class Version1015Date20211104103506 extends SimpleMigrationStep { /** * @throws Exception - * @return \OCP\DB\IResult|int + * @return IResult|int */ private function getS3Mounts() { $qb = $this->connection->getQueryBuilder(); diff --git a/apps/files_external/lib/MountConfig.php b/apps/files_external/lib/MountConfig.php index 744bdcacef3..ca14275ab13 100644 --- a/apps/files_external/lib/MountConfig.php +++ b/apps/files_external/lib/MountConfig.php @@ -6,6 +6,7 @@ */ namespace OCA\Files_External; +use OC\Files\Storage\Common; use OCA\Files_External\Config\IConfigHandler; use OCA\Files_External\Config\UserContext; use OCA\Files_External\Lib\Backend\Backend; @@ -13,6 +14,7 @@ use OCA\Files_External\Service\BackendService; use OCA\Files_External\Service\GlobalStoragesService; use OCA\Files_External\Service\UserGlobalStoragesService; use OCA\Files_External\Service\UserStoragesService; +use OCP\AppFramework\QueryException; use OCP\Files\StorageNotAvailableException; use OCP\IL10N; use OCP\Util; @@ -33,28 +35,18 @@ class MountConfig { // whether to skip backend test (for unit tests, as this static class is not mockable) public static $skipTest = false; - /** @var UserGlobalStoragesService */ - private $userGlobalStorageService; - /** @var UserStoragesService */ - private $userStorageService; - /** @var GlobalStoragesService */ - private $globalStorageService; - public function __construct( - UserGlobalStoragesService $userGlobalStorageService, - UserStoragesService $userStorageService, - GlobalStoragesService $globalStorageService, + private UserGlobalStoragesService $userGlobalStorageService, + private UserStoragesService $userStorageService, + private GlobalStoragesService $globalStorageService, ) { - $this->userGlobalStorageService = $userGlobalStorageService; - $this->userStorageService = $userStorageService; - $this->globalStorageService = $globalStorageService; } /** * @param mixed $input * @param string|null $userId * @return mixed - * @throws \OCP\AppFramework\QueryException + * @throws QueryException * @since 16.0.0 */ public static function substitutePlaceholdersInConfig($input, ?string $userId = null) { @@ -93,7 +85,7 @@ class MountConfig { } if (class_exists($class)) { try { - /** @var \OC\Files\Storage\Common $storage */ + /** @var Common $storage */ $storage = new $class($options); try { diff --git a/apps/files_external/lib/Service/BackendService.php b/apps/files_external/lib/Service/BackendService.php index a72179a3373..e37a0ab4649 100644 --- a/apps/files_external/lib/Service/BackendService.php +++ b/apps/files_external/lib/Service/BackendService.php @@ -32,9 +32,6 @@ class BackendService { /** Priority constants for PriorityTrait */ public const PRIORITY_DEFAULT = 100; - /** @var IConfig */ - protected $config; - /** @var bool */ private $userMountingAllowed = true; @@ -62,10 +59,8 @@ class BackendService { * @param IConfig $config */ public function __construct( - IConfig $config, + protected IConfig $config, ) { - $this->config = $config; - // Load config values if ($this->config->getAppValue('files_external', 'allow_user_mounting', 'yes') !== 'yes') { $this->userMountingAllowed = false; diff --git a/apps/files_external/lib/Service/StoragesService.php b/apps/files_external/lib/Service/StoragesService.php index 12bf074a095..88b9cf78ec3 100644 --- a/apps/files_external/lib/Service/StoragesService.php +++ b/apps/files_external/lib/Service/StoragesService.php @@ -27,37 +27,18 @@ use Psr\Log\LoggerInterface; */ abstract class StoragesService { - /** @var BackendService */ - protected $backendService; - - /** - * @var DBConfigService - */ - protected $dbConfig; - - /** - * @var IUserMountCache - */ - protected $userMountCache; - - protected IEventDispatcher $eventDispatcher; - /** * @param BackendService $backendService - * @param DBConfigService $dbConfigService + * @param DBConfigService $dbConfig * @param IUserMountCache $userMountCache * @param IEventDispatcher $eventDispatcher */ public function __construct( - BackendService $backendService, - DBConfigService $dbConfigService, - IUserMountCache $userMountCache, - IEventDispatcher $eventDispatcher, + protected BackendService $backendService, + protected DBConfigService $dbConfig, + protected IUserMountCache $userMountCache, + protected IEventDispatcher $eventDispatcher, ) { - $this->backendService = $backendService; - $this->dbConfig = $dbConfigService; - $this->userMountCache = $userMountCache; - $this->eventDispatcher = $eventDispatcher; } protected function readDBConfig() { diff --git a/apps/files_external/lib/Service/UserGlobalStoragesService.php b/apps/files_external/lib/Service/UserGlobalStoragesService.php index 6fc37ea99b3..01bc91ef3ff 100644 --- a/apps/files_external/lib/Service/UserGlobalStoragesService.php +++ b/apps/files_external/lib/Service/UserGlobalStoragesService.php @@ -20,9 +20,6 @@ use OCP\IUserSession; class UserGlobalStoragesService extends GlobalStoragesService { use UserTrait; - /** @var IGroupManager */ - protected $groupManager; - /** * @param BackendService $backendService * @param DBConfigService $dbConfig @@ -35,13 +32,12 @@ class UserGlobalStoragesService extends GlobalStoragesService { BackendService $backendService, DBConfigService $dbConfig, IUserSession $userSession, - IGroupManager $groupManager, + protected IGroupManager $groupManager, IUserMountCache $userMountCache, IEventDispatcher $eventDispatcher, ) { parent::__construct($backendService, $dbConfig, $userMountCache, $eventDispatcher); $this->userSession = $userSession; - $this->groupManager = $groupManager; } /** diff --git a/apps/files_external/lib/Settings/Admin.php b/apps/files_external/lib/Settings/Admin.php index 41f2c43b5f1..8476e87f3c6 100644 --- a/apps/files_external/lib/Settings/Admin.php +++ b/apps/files_external/lib/Settings/Admin.php @@ -15,28 +15,12 @@ use OCP\Settings\ISettings; class Admin implements ISettings { - /** @var IManager */ - private $encryptionManager; - - /** @var GlobalStoragesService */ - private $globalStoragesService; - - /** @var BackendService */ - private $backendService; - - /** @var GlobalAuth */ - private $globalAuth; - public function __construct( - IManager $encryptionManager, - GlobalStoragesService $globalStoragesService, - BackendService $backendService, - GlobalAuth $globalAuth, + private IManager $encryptionManager, + private GlobalStoragesService $globalStoragesService, + private BackendService $backendService, + private GlobalAuth $globalAuth, ) { - $this->encryptionManager = $encryptionManager; - $this->globalStoragesService = $globalStoragesService; - $this->backendService = $backendService; - $this->globalAuth = $globalAuth; } /** diff --git a/apps/files_external/lib/Settings/Personal.php b/apps/files_external/lib/Settings/Personal.php index 186b2638e1f..f691c14270e 100644 --- a/apps/files_external/lib/Settings/Personal.php +++ b/apps/files_external/lib/Settings/Personal.php @@ -16,33 +16,13 @@ use OCP\Settings\ISettings; class Personal implements ISettings { - /** @var IManager */ - private $encryptionManager; - - /** @var UserGlobalStoragesService */ - private $userGlobalStoragesService; - - /** @var BackendService */ - private $backendService; - - /** @var GlobalAuth */ - private $globalAuth; - - /** @var IUserSession */ - private $userSession; - public function __construct( - IManager $encryptionManager, - UserGlobalStoragesService $userGlobalStoragesService, - BackendService $backendService, - GlobalAuth $globalAuth, - IUserSession $userSession, + private IManager $encryptionManager, + private UserGlobalStoragesService $userGlobalStoragesService, + private BackendService $backendService, + private GlobalAuth $globalAuth, + private IUserSession $userSession, ) { - $this->encryptionManager = $encryptionManager; - $this->userGlobalStoragesService = $userGlobalStoragesService; - $this->backendService = $backendService; - $this->globalAuth = $globalAuth; - $this->userSession = $userSession; } /** diff --git a/apps/files_external/lib/Settings/PersonalSection.php b/apps/files_external/lib/Settings/PersonalSection.php index f72ef95ad7f..df494edce27 100644 --- a/apps/files_external/lib/Settings/PersonalSection.php +++ b/apps/files_external/lib/Settings/PersonalSection.php @@ -12,25 +12,13 @@ use OCP\IURLGenerator; use OCP\IUserSession; class PersonalSection extends Section { - /** @var IUserSession */ - private $userSession; - - /** @var UserGlobalStoragesService */ - private $userGlobalStoragesService; - - /** @var BackendService */ - private $backendService; - public function __construct( IURLGenerator $url, IL10N $l, - IUserSession $userSession, - UserGlobalStoragesService $userGlobalStoragesService, - BackendService $backendService, + private IUserSession $userSession, + private UserGlobalStoragesService $userGlobalStoragesService, + private BackendService $backendService, ) { parent::__construct($url, $l); - $this->userSession = $userSession; - $this->userGlobalStoragesService = $userGlobalStoragesService; - $this->backendService = $backendService; } } diff --git a/apps/files_external/lib/Settings/Section.php b/apps/files_external/lib/Settings/Section.php index 9bf5c092e57..8bc0814bb67 100644 --- a/apps/files_external/lib/Settings/Section.php +++ b/apps/files_external/lib/Settings/Section.php @@ -10,18 +10,14 @@ use OCP\IURLGenerator; use OCP\Settings\IIconSection; class Section implements IIconSection { - /** @var IL10N */ - private $l; - /** @var IURLGenerator */ - private $url; - /** * @param IURLGenerator $url * @param IL10N $l */ - public function __construct(IURLGenerator $url, IL10N $l) { - $this->url = $url; - $this->l = $l; + public function __construct( + private IURLGenerator $url, + private IL10N $l, + ) { } /** diff --git a/apps/files_external/tests/Auth/Password/GlobalAuth.php b/apps/files_external/tests/Auth/Password/GlobalAuth.php index aa28083e09e..998db198b53 100644 --- a/apps/files_external/tests/Auth/Password/GlobalAuth.php +++ b/apps/files_external/tests/Auth/Password/GlobalAuth.php @@ -15,12 +15,12 @@ use Test\TestCase; class GlobalAuthTest extends TestCase { /** - * @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject + * @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ private $l10n; /** - * @var \OCP\Security\ICredentialsManager|\PHPUnit\Framework\MockObject\MockObject + * @var ICredentialsManager|\PHPUnit\Framework\MockObject\MockObject */ private $credentialsManager; diff --git a/apps/files_external/tests/Command/ApplicableTest.php b/apps/files_external/tests/Command/ApplicableTest.php index 223b02706e5..8854e4ad485 100644 --- a/apps/files_external/tests/Command/ApplicableTest.php +++ b/apps/files_external/tests/Command/ApplicableTest.php @@ -12,9 +12,9 @@ use OCP\IUserManager; class ApplicableTest extends CommandTest { private function getInstance($storageService) { - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */ + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */ $userManager = $this->createMock(IUserManager::class); - /** @var \OCP\IGroupManager|\PHPUnit\Framework\MockObject\MockObject $groupManager */ + /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject $groupManager */ $groupManager = $this->createMock(IGroupManager::class); $userManager->expects($this->any()) diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php index 59907b07d6a..e7644d8e523 100644 --- a/apps/files_external/tests/Service/BackendServiceTest.php +++ b/apps/files_external/tests/Service/BackendServiceTest.php @@ -16,7 +16,7 @@ use OCP\IConfig; class BackendServiceTest extends \Test\TestCase { - /** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ protected $config; protected function setUp(): void { diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php index a4e823ab6f0..797d4382ae9 100644 --- a/apps/files_external/tests/Service/StoragesServiceTest.php +++ b/apps/files_external/tests/Service/StoragesServiceTest.php @@ -76,7 +76,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { protected static $hookCalls; /** - * @var \PHPUnit\Framework\MockObject\MockObject|\OCP\Files\Config\IUserMountCache + * @var \PHPUnit\Framework\MockObject\MockObject|IUserMountCache */ protected $mountCache; diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php index 7aef65cebee..571664b32c8 100644 --- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php @@ -23,7 +23,7 @@ use Test\Traits\UserTrait; class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { use UserTrait; - /** @var \OCP\IGroupManager|\PHPUnit\Framework\MockObject\MockObject groupManager */ + /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject groupManager */ protected $groupManager; /** @@ -48,7 +48,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { $this->globalStoragesService = $this->service; $this->user = new User(self::USER_ID, null, \OC::$server->get(IEventDispatcher::class)); - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */ + /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */ $userSession = $this->createMock(IUserSession::class); $userSession ->expects($this->any()) diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php index 4a4404839a4..7bf101ebfc4 100644 --- a/apps/files_external/tests/Service/UserStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php @@ -41,7 +41,7 @@ class UserStoragesServiceTest extends StoragesServiceTest { $this->createUser($this->userId, $this->userId); $this->user = \OC::$server->getUserManager()->get($this->userId); - /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */ + /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */ $userSession = $this->createMock(IUserSession::class); $userSession ->expects($this->any()) |