aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-10-18 12:04:22 +0200
committerprovokateurin <kate@provokateurin.de>2024-10-21 12:37:59 +0200
commit381077028adf388a7081cf42026570c6be47b198 (patch)
treec0f8e9b6caea80d6b55d6fdcc9188ba57197fa0f /apps/encryption/lib
parent4d8d11d2f79da348644e0902e78a2f000498cd52 (diff)
downloadnextcloud-server-381077028adf388a7081cf42026570c6be47b198.tar.gz
nextcloud-server-381077028adf388a7081cf42026570c6be47b198.zip
refactor(apps): Use constructor property promotion when possible
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'apps/encryption/lib')
-rw-r--r--apps/encryption/lib/Controller/RecoveryController.php28
-rw-r--r--apps/encryption/lib/Controller/SettingsController.php53
-rw-r--r--apps/encryption/lib/Controller/StatusController.php23
-rw-r--r--apps/encryption/lib/Crypto/DecryptAll.php30
-rw-r--r--apps/encryption/lib/Crypto/EncryptAll.php66
-rw-r--r--apps/encryption/lib/Migration/SetMasterKeyStatus.php9
-rw-r--r--apps/encryption/lib/Recovery.php39
-rw-r--r--apps/encryption/lib/Services/PassphraseService.php5
-rw-r--r--apps/encryption/lib/Session.php8
-rw-r--r--apps/encryption/lib/Settings/Personal.php20
-rw-r--r--apps/encryption/lib/Util.php3
11 files changed, 65 insertions, 219 deletions
diff --git a/apps/encryption/lib/Controller/RecoveryController.php b/apps/encryption/lib/Controller/RecoveryController.php
index 66011fe2439..d75406e6319 100644
--- a/apps/encryption/lib/Controller/RecoveryController.php
+++ b/apps/encryption/lib/Controller/RecoveryController.php
@@ -18,34 +18,20 @@ use OCP\IRequest;
class RecoveryController extends Controller {
/**
- * @var IConfig
- */
- private $config;
- /**
- * @var IL10N
- */
- private $l;
- /**
- * @var Recovery
- */
- private $recovery;
-
- /**
* @param string $AppName
* @param IRequest $request
* @param IConfig $config
- * @param IL10N $l10n
+ * @param IL10N $l
* @param Recovery $recovery
*/
- public function __construct($AppName,
+ public function __construct(
+ $AppName,
IRequest $request,
- IConfig $config,
- IL10N $l10n,
- Recovery $recovery) {
+ private IConfig $config,
+ private IL10N $l,
+ private Recovery $recovery,
+ ) {
parent::__construct($AppName, $request);
- $this->config = $config;
- $this->l = $l10n;
- $this->recovery = $recovery;
}
/**
diff --git a/apps/encryption/lib/Controller/SettingsController.php b/apps/encryption/lib/Controller/SettingsController.php
index df896e52fa5..8548ea51c04 100644
--- a/apps/encryption/lib/Controller/SettingsController.php
+++ b/apps/encryption/lib/Controller/SettingsController.php
@@ -24,34 +24,10 @@ use OCP\IUserSession;
class SettingsController extends Controller {
- /** @var IL10N */
- private $l;
-
- /** @var IUserManager */
- private $userManager;
-
- /** @var IUserSession */
- private $userSession;
-
- /** @var KeyManager */
- private $keyManager;
-
- /** @var Crypt */
- private $crypt;
-
- /** @var Session */
- private $session;
-
- /** @var ISession */
- private $ocSession;
-
- /** @var Util */
- private $util;
-
/**
* @param string $AppName
* @param IRequest $request
- * @param IL10N $l10n
+ * @param IL10N $l
* @param IUserManager $userManager
* @param IUserSession $userSession
* @param KeyManager $keyManager
@@ -60,26 +36,19 @@ class SettingsController extends Controller {
* @param ISession $ocSession
* @param Util $util
*/
- public function __construct($AppName,
+ public function __construct(
+ $AppName,
IRequest $request,
- IL10N $l10n,
- IUserManager $userManager,
- IUserSession $userSession,
- KeyManager $keyManager,
- Crypt $crypt,
- Session $session,
- ISession $ocSession,
- Util $util,
+ private IL10N $l,
+ private IUserManager $userManager,
+ private IUserSession $userSession,
+ private KeyManager $keyManager,
+ private Crypt $crypt,
+ private Session $session,
+ private ISession $ocSession,
+ private Util $util,
) {
parent::__construct($AppName, $request);
- $this->l = $l10n;
- $this->userSession = $userSession;
- $this->userManager = $userManager;
- $this->keyManager = $keyManager;
- $this->crypt = $crypt;
- $this->session = $session;
- $this->ocSession = $ocSession;
- $this->util = $util;
}
diff --git a/apps/encryption/lib/Controller/StatusController.php b/apps/encryption/lib/Controller/StatusController.php
index 5c6a950d0a3..341ad6bc49f 100644
--- a/apps/encryption/lib/Controller/StatusController.php
+++ b/apps/encryption/lib/Controller/StatusController.php
@@ -17,32 +17,21 @@ use OCP\IRequest;
class StatusController extends Controller {
- /** @var IL10N */
- private $l;
-
- /** @var Session */
- private $session;
-
- /** @var IManager */
- private $encryptionManager;
-
/**
* @param string $AppName
* @param IRequest $request
- * @param IL10N $l10n
+ * @param IL10N $l
* @param Session $session
* @param IManager $encryptionManager
*/
- public function __construct($AppName,
+ public function __construct(
+ $AppName,
IRequest $request,
- IL10N $l10n,
- Session $session,
- IManager $encryptionManager,
+ private IL10N $l,
+ private Session $session,
+ private IManager $encryptionManager,
) {
parent::__construct($AppName, $request);
- $this->l = $l10n;
- $this->session = $session;
- $this->encryptionManager = $encryptionManager;
}
/**
diff --git a/apps/encryption/lib/Crypto/DecryptAll.php b/apps/encryption/lib/Crypto/DecryptAll.php
index c336f2d92a2..362f43b8672 100644
--- a/apps/encryption/lib/Crypto/DecryptAll.php
+++ b/apps/encryption/lib/Crypto/DecryptAll.php
@@ -19,21 +19,6 @@ use Symfony\Component\Console\Question\Question;
class DecryptAll {
- /** @var Util */
- protected $util;
-
- /** @var QuestionHelper */
- protected $questionHelper;
-
- /** @var Crypt */
- protected $crypt;
-
- /** @var KeyManager */
- protected $keyManager;
-
- /** @var Session */
- protected $session;
-
/**
* @param Util $util
* @param KeyManager $keyManager
@@ -42,17 +27,12 @@ class DecryptAll {
* @param QuestionHelper $questionHelper
*/
public function __construct(
- Util $util,
- KeyManager $keyManager,
- Crypt $crypt,
- Session $session,
- QuestionHelper $questionHelper,
+ protected Util $util,
+ protected KeyManager $keyManager,
+ protected Crypt $crypt,
+ protected Session $session,
+ protected QuestionHelper $questionHelper,
) {
- $this->util = $util;
- $this->keyManager = $keyManager;
- $this->crypt = $crypt;
- $this->session = $session;
- $this->questionHelper = $questionHelper;
}
/**
diff --git a/apps/encryption/lib/Crypto/EncryptAll.php b/apps/encryption/lib/Crypto/EncryptAll.php
index e9db5034baa..6dfa36e6e3d 100644
--- a/apps/encryption/lib/Crypto/EncryptAll.php
+++ b/apps/encryption/lib/Crypto/EncryptAll.php
@@ -29,72 +29,28 @@ use Symfony\Component\Console\Question\ConfirmationQuestion;
class EncryptAll {
- /** @var Setup */
- protected $userSetup;
-
- /** @var IUserManager */
- protected $userManager;
-
- /** @var View */
- protected $rootView;
-
- /** @var KeyManager */
- protected $keyManager;
-
- /** @var Util */
- protected $util;
-
/** @var array */
protected $userPasswords;
- /** @var IConfig */
- protected $config;
-
- /** @var IMailer */
- protected $mailer;
-
- /** @var IL10N */
- protected $l;
-
- /** @var IFactory */
- protected $l10nFactory;
-
- /** @var QuestionHelper */
- protected $questionHelper;
-
/** @var OutputInterface */
protected $output;
/** @var InputInterface */
protected $input;
- /** @var ISecureRandom */
- protected $secureRandom;
-
public function __construct(
- Setup $userSetup,
- IUserManager $userManager,
- View $rootView,
- KeyManager $keyManager,
- Util $util,
- IConfig $config,
- IMailer $mailer,
- IL10N $l,
- IFactory $l10nFactory,
- QuestionHelper $questionHelper,
- ISecureRandom $secureRandom,
+ protected Setup $userSetup,
+ protected IUserManager $userManager,
+ protected View $rootView,
+ protected KeyManager $keyManager,
+ protected Util $util,
+ protected IConfig $config,
+ protected IMailer $mailer,
+ protected IL10N $l,
+ protected IFactory $l10nFactory,
+ protected QuestionHelper $questionHelper,
+ protected ISecureRandom $secureRandom,
) {
- $this->userSetup = $userSetup;
- $this->userManager = $userManager;
- $this->rootView = $rootView;
- $this->keyManager = $keyManager;
- $this->util = $util;
- $this->config = $config;
- $this->mailer = $mailer;
- $this->l = $l;
- $this->l10nFactory = $l10nFactory;
- $this->questionHelper = $questionHelper;
- $this->secureRandom = $secureRandom;
// store one time passwords for the users
$this->userPasswords = [];
}
diff --git a/apps/encryption/lib/Migration/SetMasterKeyStatus.php b/apps/encryption/lib/Migration/SetMasterKeyStatus.php
index 56dcd15dae4..96194351296 100644
--- a/apps/encryption/lib/Migration/SetMasterKeyStatus.php
+++ b/apps/encryption/lib/Migration/SetMasterKeyStatus.php
@@ -17,12 +17,9 @@ use OCP\Migration\IRepairStep;
class SetMasterKeyStatus implements IRepairStep {
- /** @var IConfig */
- private $config;
-
-
- public function __construct(IConfig $config) {
- $this->config = $config;
+ public function __construct(
+ private IConfig $config,
+ ) {
}
/**
diff --git a/apps/encryption/lib/Recovery.php b/apps/encryption/lib/Recovery.php
index 3990067f19b..38e78f5e822 100644
--- a/apps/encryption/lib/Recovery.php
+++ b/apps/encryption/lib/Recovery.php
@@ -20,26 +20,6 @@ class Recovery {
* @var null|IUser
*/
protected $user;
- /**
- * @var Crypt
- */
- protected $crypt;
- /**
- * @var KeyManager
- */
- private $keyManager;
- /**
- * @var IConfig
- */
- private $config;
- /**
- * @var View
- */
- private $view;
- /**
- * @var IFile
- */
- private $file;
/**
* @param IUserSession $userSession
@@ -49,18 +29,15 @@ class Recovery {
* @param IFile $file
* @param View $view
*/
- public function __construct(IUserSession $userSession,
- Crypt $crypt,
- KeyManager $keyManager,
- IConfig $config,
- IFile $file,
- View $view) {
+ public function __construct(
+ IUserSession $userSession,
+ protected Crypt $crypt,
+ private KeyManager $keyManager,
+ private IConfig $config,
+ private IFile $file,
+ private View $view,
+ ) {
$this->user = ($userSession->isLoggedIn()) ? $userSession->getUser() : null;
- $this->crypt = $crypt;
- $this->keyManager = $keyManager;
- $this->config = $config;
- $this->view = $view;
- $this->file = $file;
}
/**
diff --git a/apps/encryption/lib/Services/PassphraseService.php b/apps/encryption/lib/Services/PassphraseService.php
index 4b3e83375f5..0786cd3399a 100644
--- a/apps/encryption/lib/Services/PassphraseService.php
+++ b/apps/encryption/lib/Services/PassphraseService.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace OCA\Encryption\Services;
+use OC\Files\Filesystem;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Recovery;
@@ -78,7 +79,7 @@ class PassphraseService {
}
$this->logger->error('Encryption could not update users encryption password');
-
+
// NOTE: Session does not need to be updated as the
// private key has not changed, only the passphrase
// used to decrypt it has changed
@@ -137,6 +138,6 @@ class PassphraseService {
* Init mount points for given user
*/
private function initMountPoints(IUser $user): void {
- \OC\Files\Filesystem::initMountPoints($user);
+ Filesystem::initMountPoints($user);
}
}
diff --git a/apps/encryption/lib/Session.php b/apps/encryption/lib/Session.php
index 4b759618eb2..e2731d9611d 100644
--- a/apps/encryption/lib/Session.php
+++ b/apps/encryption/lib/Session.php
@@ -12,9 +12,6 @@ use OCP\ISession;
class Session {
- /** @var ISession */
- protected $session;
-
public const NOT_INITIALIZED = '0';
public const INIT_EXECUTED = '1';
public const INIT_SUCCESSFUL = '2';
@@ -22,8 +19,9 @@ class Session {
/**
* @param ISession $session
*/
- public function __construct(ISession $session) {
- $this->session = $session;
+ public function __construct(
+ protected ISession $session,
+ ) {
}
/**
diff --git a/apps/encryption/lib/Settings/Personal.php b/apps/encryption/lib/Settings/Personal.php
index b544ea1dc3e..63e50ccc078 100644
--- a/apps/encryption/lib/Settings/Personal.php
+++ b/apps/encryption/lib/Settings/Personal.php
@@ -14,20 +14,12 @@ use OCP\Settings\ISettings;
class Personal implements ISettings {
- /** @var IConfig */
- private $config;
- /** @var Session */
- private $session;
- /** @var Util */
- private $util;
- /** @var IUserSession */
- private $userSession;
-
- public function __construct(IConfig $config, Session $session, Util $util, IUserSession $userSession) {
- $this->config = $config;
- $this->session = $session;
- $this->util = $util;
- $this->userSession = $userSession;
+ public function __construct(
+ private IConfig $config,
+ private Session $session,
+ private Util $util,
+ private IUserSession $userSession,
+ ) {
}
/**
diff --git a/apps/encryption/lib/Util.php b/apps/encryption/lib/Util.php
index 61656ddcda3..26d04220733 100644
--- a/apps/encryption/lib/Util.php
+++ b/apps/encryption/lib/Util.php
@@ -7,6 +7,7 @@
*/
namespace OCA\Encryption;
+use OC\Files\Storage\Storage;
use OC\Files\View;
use OCA\Encryption\Crypto\Crypt;
use OCP\IConfig;
@@ -131,7 +132,7 @@ class Util {
* get storage of path
*
* @param string $path
- * @return \OC\Files\Storage\Storage|null
+ * @return Storage|null
*/
public function getStorage($path) {
return $this->files->getMount($path)->getStorage();