From b5cbba7fc153494339a52dc1c1633fbfbe1e9fd1 Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Mon, 12 Jun 2023 18:07:03 +0330 Subject: [PATCH 1/5] Uses PHP8's constructor property promotion in core/Command/Db classes. Signed-off-by: Faraz Samapoor --- core/Command/Db/AddMissingColumns.php | 11 ++++------- core/Command/Db/AddMissingIndices.php | 11 ++++------- core/Command/Db/AddMissingPrimaryKeys.php | 11 ++++------- core/Command/Db/ConvertFilecacheBigInt.php | 5 +---- core/Command/Db/ConvertMysqlToMB4.php | 17 ++++------------- core/Command/Db/ConvertType.php | 9 ++++----- core/Command/Db/Migrations/ExecuteCommand.php | 11 ++++------- core/Command/Db/Migrations/MigrateCommand.php | 5 +---- core/Command/Db/Migrations/StatusCommand.php | 5 +---- 9 files changed, 27 insertions(+), 58 deletions(-) diff --git a/core/Command/Db/AddMissingColumns.php b/core/Command/Db/AddMissingColumns.php index acc05c3b7ff..8e6f439e0c4 100644 --- a/core/Command/Db/AddMissingColumns.php +++ b/core/Command/Db/AddMissingColumns.php @@ -45,14 +45,11 @@ use Symfony\Component\EventDispatcher\GenericEvent; * @package OC\Core\Command\Db */ class AddMissingColumns extends Command { - private Connection $connection; - private EventDispatcherInterface $dispatcher; - - public function __construct(Connection $connection, EventDispatcherInterface $dispatcher) { + public function __construct( + private Connection $connection, + private EventDispatcherInterface $dispatcher, + ) { parent::__construct(); - - $this->connection = $connection; - $this->dispatcher = $dispatcher; } protected function configure() { diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index b317f44b499..4f8e0c45a35 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -53,14 +53,11 @@ use Symfony\Component\EventDispatcher\GenericEvent; * @package OC\Core\Command\Db */ class AddMissingIndices extends Command { - private Connection $connection; - private EventDispatcherInterface $dispatcher; - - public function __construct(Connection $connection, EventDispatcherInterface $dispatcher) { + public function __construct( + private Connection $connection, + private EventDispatcherInterface $dispatcher, + ) { parent::__construct(); - - $this->connection = $connection; - $this->dispatcher = $dispatcher; } protected function configure() { diff --git a/core/Command/Db/AddMissingPrimaryKeys.php b/core/Command/Db/AddMissingPrimaryKeys.php index 8262cf37e77..a11be78ccfc 100644 --- a/core/Command/Db/AddMissingPrimaryKeys.php +++ b/core/Command/Db/AddMissingPrimaryKeys.php @@ -45,14 +45,11 @@ use Symfony\Component\EventDispatcher\GenericEvent; * @package OC\Core\Command\Db */ class AddMissingPrimaryKeys extends Command { - private Connection $connection; - private EventDispatcherInterface $dispatcher; - - public function __construct(Connection $connection, EventDispatcherInterface $dispatcher) { + public function __construct( + private Connection $connection, + private EventDispatcherInterface $dispatcher, + ) { parent::__construct(); - - $this->connection = $connection; - $this->dispatcher = $dispatcher; } protected function configure() { diff --git a/core/Command/Db/ConvertFilecacheBigInt.php b/core/Command/Db/ConvertFilecacheBigInt.php index 9d77ac9a5a0..afa53326124 100644 --- a/core/Command/Db/ConvertFilecacheBigInt.php +++ b/core/Command/Db/ConvertFilecacheBigInt.php @@ -42,10 +42,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; class ConvertFilecacheBigInt extends Command { - private Connection $connection; - - public function __construct(Connection $connection) { - $this->connection = $connection; + public function __construct(private Connection $connection) { parent::__construct(); } diff --git a/core/Command/Db/ConvertMysqlToMB4.php b/core/Command/Db/ConvertMysqlToMB4.php index 19a9532d910..a66fb46fc51 100644 --- a/core/Command/Db/ConvertMysqlToMB4.php +++ b/core/Command/Db/ConvertMysqlToMB4.php @@ -37,21 +37,12 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class ConvertMysqlToMB4 extends Command { - private IConfig $config; - private IDBConnection $connection; - private IURLGenerator $urlGenerator; - private LoggerInterface $logger; - public function __construct( - IConfig $config, - IDBConnection $connection, - IURLGenerator $urlGenerator, - LoggerInterface $logger + private IConfig $config, + private IDBConnection $connection, + private IURLGenerator $urlGenerator, + private LoggerInterface $logger, ) { - $this->config = $config; - $this->connection = $connection; - $this->urlGenerator = $urlGenerator; - $this->logger = $logger; parent::__construct(); } diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index f7638e3024f..9098f7cdd80 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -56,13 +56,12 @@ use function preg_match; use function preg_quote; class ConvertType extends Command implements CompletionAwareInterface { - protected IConfig $config; - protected ConnectionFactory $connectionFactory; protected array $columnTypes; - public function __construct(IConfig $config, ConnectionFactory $connectionFactory) { - $this->config = $config; - $this->connectionFactory = $connectionFactory; + public function __construct( + protected IConfig $config, + protected ConnectionFactory $connectionFactory, + ) { parent::__construct(); } diff --git a/core/Command/Db/Migrations/ExecuteCommand.php b/core/Command/Db/Migrations/ExecuteCommand.php index e87e133fa31..c75b575ab6c 100644 --- a/core/Command/Db/Migrations/ExecuteCommand.php +++ b/core/Command/Db/Migrations/ExecuteCommand.php @@ -35,13 +35,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class ExecuteCommand extends Command implements CompletionAwareInterface { - private Connection $connection; - private IConfig $config; - - public function __construct(Connection $connection, IConfig $config) { - $this->connection = $connection; - $this->config = $config; - + public function __construct( + private Connection $connection, + private IConfig $config, + ) { parent::__construct(); } diff --git a/core/Command/Db/Migrations/MigrateCommand.php b/core/Command/Db/Migrations/MigrateCommand.php index f0f35716997..b438da00541 100644 --- a/core/Command/Db/Migrations/MigrateCommand.php +++ b/core/Command/Db/Migrations/MigrateCommand.php @@ -33,10 +33,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class MigrateCommand extends Command implements CompletionAwareInterface { - private Connection $connection; - - public function __construct(Connection $connection) { - $this->connection = $connection; + public function __construct(private Connection $connection) { parent::__construct(); } diff --git a/core/Command/Db/Migrations/StatusCommand.php b/core/Command/Db/Migrations/StatusCommand.php index 725ee075215..c360299270f 100644 --- a/core/Command/Db/Migrations/StatusCommand.php +++ b/core/Command/Db/Migrations/StatusCommand.php @@ -34,10 +34,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class StatusCommand extends Command implements CompletionAwareInterface { - private Connection $connection; - - public function __construct(Connection $connection) { - $this->connection = $connection; + public function __construct(private Connection $connection) { parent::__construct(); } From f1a19a10fceb7de383a437da987e90618fdacc4a Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Tue, 13 Jun 2023 10:43:59 +0330 Subject: [PATCH 2/5] Update core/Command/Db/Migrations/StatusCommand.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com> Signed-off-by: Faraz Samapoor --- core/Command/Db/Migrations/StatusCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Command/Db/Migrations/StatusCommand.php b/core/Command/Db/Migrations/StatusCommand.php index c360299270f..52bc51a169f 100644 --- a/core/Command/Db/Migrations/StatusCommand.php +++ b/core/Command/Db/Migrations/StatusCommand.php @@ -34,7 +34,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class StatusCommand extends Command implements CompletionAwareInterface { - public function __construct(private Connection $connection) { + public function __construct( + private Connection $connection, + ) { parent::__construct(); } From d34cafc58c699f258b3ec80ff10e3b6e8080cbdd Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Tue, 13 Jun 2023 10:44:12 +0330 Subject: [PATCH 3/5] Update core/Command/Db/Migrations/MigrateCommand.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com> Signed-off-by: Faraz Samapoor --- core/Command/Db/Migrations/MigrateCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Command/Db/Migrations/MigrateCommand.php b/core/Command/Db/Migrations/MigrateCommand.php index b438da00541..3e11b32665a 100644 --- a/core/Command/Db/Migrations/MigrateCommand.php +++ b/core/Command/Db/Migrations/MigrateCommand.php @@ -33,7 +33,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class MigrateCommand extends Command implements CompletionAwareInterface { - public function __construct(private Connection $connection) { + public function __construct( + private Connection $connection, + ) { parent::__construct(); } From 73d7c45ae10b878ca3449b112eca93c244f3a83d Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Tue, 13 Jun 2023 10:45:35 +0330 Subject: [PATCH 4/5] Update core/Command/Db/ConvertFilecacheBigInt.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com> Signed-off-by: Faraz Samapoor --- core/Command/Db/ConvertFilecacheBigInt.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Command/Db/ConvertFilecacheBigInt.php b/core/Command/Db/ConvertFilecacheBigInt.php index afa53326124..e10382c6fbb 100644 --- a/core/Command/Db/ConvertFilecacheBigInt.php +++ b/core/Command/Db/ConvertFilecacheBigInt.php @@ -42,7 +42,9 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; class ConvertFilecacheBigInt extends Command { - public function __construct(private Connection $connection) { + public function __construct( + private Connection $connection, + ) { parent::__construct(); } From 1e8ec53b8cd2c0d56eec14b915133b07b538995e Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Tue, 13 Jun 2023 11:03:25 +0330 Subject: [PATCH 5/5] Update core/Command/Db/ConvertType.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com> Signed-off-by: Faraz Samapoor --- core/Command/Db/ConvertType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index 9098f7cdd80..e95a6f47c1f 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -56,7 +56,7 @@ use function preg_match; use function preg_quote; class ConvertType extends Command implements CompletionAwareInterface { - protected array $columnTypes; + protected array $columnTypes = []; public function __construct( protected IConfig $config,