From e2c979026095976e36804f033b23f421b744f1d5 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 23 Aug 2023 22:43:39 +0200 Subject: [PATCH] Support Symfony 7 by adding return types conditionally --- .../Console/Command/CommandCompatibility.php | 35 +++++++++++++++++++ .../Console/Command/ReservedWordsCommand.php | 12 +++---- src/Tools/Console/Command/RunSqlCommand.php | 12 +++---- 3 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 src/Tools/Console/Command/CommandCompatibility.php diff --git a/src/Tools/Console/Command/CommandCompatibility.php b/src/Tools/Console/Command/CommandCompatibility.php new file mode 100644 index 00000000000..562b5ce4550 --- /dev/null +++ b/src/Tools/Console/Command/CommandCompatibility.php @@ -0,0 +1,35 @@ +hasReturnType()) { + /** @internal */ + trait CommandCompatibility + { + protected function execute(InputInterface $input, OutputInterface $output): int + { + return $this->doExecute($input, $output); + } + } +} else { + /** @internal */ + trait CommandCompatibility + { + /** + * {@inheritDoc} + * + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + return $this->doExecute($input, $output); + } + } +} diff --git a/src/Tools/Console/Command/ReservedWordsCommand.php b/src/Tools/Console/Command/ReservedWordsCommand.php index 1d10d4f0ca3..e6331546678 100644 --- a/src/Tools/Console/Command/ReservedWordsCommand.php +++ b/src/Tools/Console/Command/ReservedWordsCommand.php @@ -34,6 +34,8 @@ /** @deprecated Use database documentation instead. */ class ReservedWordsCommand extends Command { + use CommandCompatibility; + /** @var array */ private array $keywordLists; @@ -136,14 +138,8 @@ protected function configure() EOT); } - /** - * {@inheritDoc} - * - * @return int - * - * @throws Exception - */ - protected function execute(InputInterface $input, OutputInterface $output) + /** @throws Exception */ + private function doExecute(InputInterface $input, OutputInterface $output): int { $output->writeln( 'The dbal:reserved-words command is deprecated.' diff --git a/src/Tools/Console/Command/RunSqlCommand.php b/src/Tools/Console/Command/RunSqlCommand.php index 874b4193f94..4e5681e2728 100644 --- a/src/Tools/Console/Command/RunSqlCommand.php +++ b/src/Tools/Console/Command/RunSqlCommand.php @@ -26,6 +26,8 @@ */ class RunSqlCommand extends Command { + use CommandCompatibility; + private ConnectionProvider $connectionProvider; public function __construct(ConnectionProvider $connectionProvider) @@ -55,14 +57,8 @@ protected function configure() EOT); } - /** - * {@inheritDoc} - * - * @return int - * - * @throws Exception - */ - protected function execute(InputInterface $input, OutputInterface $output) + /** @throws Exception */ + private function doExecute(InputInterface $input, OutputInterface $output): int { $conn = $this->getConnection($input); $io = new SymfonyStyle($input, $output);