From c01129947e9fecd26f10ef588cc0940ff187dc83 Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Mon, 12 Jun 2023 19:20:14 +0330 Subject: [PATCH] Uses PHP8's constructor property promotion. in core/Command and /TwoFactorAuth classes. Signed-off-by: Faraz Samapoor --- core/Command/Check.php | 5 +---- core/Command/Status.php | 11 ++++------- core/Command/TwoFactorAuth/Cleanup.php | 6 +----- core/Command/TwoFactorAuth/Disable.php | 9 ++++----- core/Command/TwoFactorAuth/Enable.php | 9 ++++----- core/Command/TwoFactorAuth/Enforce.php | 6 +----- core/Command/TwoFactorAuth/State.php | 10 ++++------ core/Command/Upgrade.php | 13 +++++-------- 8 files changed, 24 insertions(+), 45 deletions(-) diff --git a/core/Command/Check.php b/core/Command/Check.php index 18c45323f37..529cb541f6d 100644 --- a/core/Command/Check.php +++ b/core/Command/Check.php @@ -29,11 +29,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Check extends Base { - private SystemConfig $config; - - public function __construct(SystemConfig $config) { + public function __construct(private SystemConfig $config) { parent::__construct(); - $this->config = $config; } protected function configure() { diff --git a/core/Command/Status.php b/core/Command/Status.php index c59dac557a8..57b831c7eaa 100644 --- a/core/Command/Status.php +++ b/core/Command/Status.php @@ -33,14 +33,11 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Status extends Base { - private IConfig $config; - private Defaults $themingDefaults; - - public function __construct(IConfig $config, Defaults $themingDefaults) { + public function __construct( + private IConfig $config, + private Defaults $themingDefaults, + ) { parent::__construct('status'); - - $this->config = $config; - $this->themingDefaults = $themingDefaults; } protected function configure() { diff --git a/core/Command/TwoFactorAuth/Cleanup.php b/core/Command/TwoFactorAuth/Cleanup.php index 7d3fc3c33f7..125a7b01f4a 100644 --- a/core/Command/TwoFactorAuth/Cleanup.php +++ b/core/Command/TwoFactorAuth/Cleanup.php @@ -32,12 +32,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Cleanup extends Base { - private IRegistry $registry; - - public function __construct(IRegistry $registry) { + public function __construct(private IRegistry $registry) { parent::__construct(); - - $this->registry = $registry; } protected function configure() { diff --git a/core/Command/TwoFactorAuth/Disable.php b/core/Command/TwoFactorAuth/Disable.php index 54e4b138a0a..1de4d711e0e 100644 --- a/core/Command/TwoFactorAuth/Disable.php +++ b/core/Command/TwoFactorAuth/Disable.php @@ -29,12 +29,11 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Disable extends Base { - private ProviderManager $manager; - - public function __construct(ProviderManager $manager, IUserManager $userManager) { + public function __construct( + private ProviderManager $manager, + protected IUserManager $userManager, + ) { parent::__construct('twofactorauth:disable'); - $this->manager = $manager; - $this->userManager = $userManager; } protected function configure() { diff --git a/core/Command/TwoFactorAuth/Enable.php b/core/Command/TwoFactorAuth/Enable.php index 67c1778399d..38d6894b462 100644 --- a/core/Command/TwoFactorAuth/Enable.php +++ b/core/Command/TwoFactorAuth/Enable.php @@ -29,12 +29,11 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Enable extends Base { - private ProviderManager $manager; - - public function __construct(ProviderManager $manager, IUserManager $userManager) { + public function __construct( + private ProviderManager $manager, + protected IUserManager $userManager, + ) { parent::__construct('twofactorauth:enable'); - $this->manager = $manager; - $this->userManager = $userManager; } protected function configure() { diff --git a/core/Command/TwoFactorAuth/Enforce.php b/core/Command/TwoFactorAuth/Enforce.php index d8fa41e2e95..b2a05a531fb 100644 --- a/core/Command/TwoFactorAuth/Enforce.php +++ b/core/Command/TwoFactorAuth/Enforce.php @@ -35,12 +35,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Enforce extends Command { - private MandatoryTwoFactor $mandatoryTwoFactor; - - public function __construct(MandatoryTwoFactor $mandatoryTwoFactor) { + public function __construct(private MandatoryTwoFactor $mandatoryTwoFactor) { parent::__construct(); - - $this->mandatoryTwoFactor = $mandatoryTwoFactor; } protected function configure() { diff --git a/core/Command/TwoFactorAuth/State.php b/core/Command/TwoFactorAuth/State.php index 4694c76b408..d4e930b7c9d 100644 --- a/core/Command/TwoFactorAuth/State.php +++ b/core/Command/TwoFactorAuth/State.php @@ -33,13 +33,11 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class State extends Base { - private IRegistry $registry; - - public function __construct(IRegistry $registry, IUserManager $userManager) { + public function __construct( + private IRegistry $registry, + protected IUserManager $userManager, + ) { parent::__construct('twofactorauth:state'); - - $this->registry = $registry; - $this->userManager = $userManager; } protected function configure() { diff --git a/core/Command/Upgrade.php b/core/Command/Upgrade.php index e929dc22bc8..078f994d051 100644 --- a/core/Command/Upgrade.php +++ b/core/Command/Upgrade.php @@ -62,15 +62,12 @@ class Upgrade extends Command { public const ERROR_INVALID_ARGUMENTS = 4; public const ERROR_FAILURE = 5; - private IConfig $config; - private LoggerInterface $logger; - private Installer $installer; - - public function __construct(IConfig $config, LoggerInterface $logger, Installer $installer) { + public function __construct( + private IConfig $config, + private LoggerInterface $logger, + private Installer $installer, + ) { parent::__construct(); - $this->config = $config; - $this->logger = $logger; - $this->installer = $installer; } protected function configure() {