From b01d36e776994ae207c97f1ee541c6adc01311ac Mon Sep 17 00:00:00 2001 From: David Maicher Date: Tue, 12 May 2020 20:37:52 +0200 Subject: [PATCH] cs fixes --- .../DBAL/Tools/Console/Command/ReservedWordsCommand.php | 5 +++-- lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php | 4 ++-- lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index f23ca697ce1..5d19cb5e40b 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -28,12 +28,13 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use const E_USER_DEPRECATED; use function array_keys; use function assert; use function count; use function implode; +use function is_string; use function trigger_error; +use const E_USER_DEPRECATED; class ReservedWordsCommand extends Command { @@ -200,8 +201,8 @@ protected function execute(InputInterface $input, OutputInterface $output) private function getConnection(InputInterface $input) : Connection { - /** @var string|null $connectionName */ $connectionName = $input->getOption('connection'); + assert(is_string($connectionName) || $connectionName === null); if ($this->connectionProvider === null) { if ($connectionName !== null) { diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php index a429d98183a..37c3c8973ca 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -13,12 +13,12 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use const E_USER_DEPRECATED; use function assert; use function is_numeric; use function is_string; use function stripos; use function trigger_error; +use const E_USER_DEPRECATED; /** * Task for executing arbitrary SQL that can come from a file or directly from @@ -92,8 +92,8 @@ protected function execute(InputInterface $input, OutputInterface $output) private function getConnection(InputInterface $input) : Connection { - /** @var string|null $connectionName */ $connectionName = $input->getOption('connection'); + assert(is_string($connectionName) || $connectionName === null); if ($this->connectionProvider === null) { if ($connectionName !== null) { diff --git a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php index c4eb276b796..e3389cc9e4f 100644 --- a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php @@ -12,9 +12,10 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\HelperSet; use TypeError; -use const E_USER_DEPRECATED; +use function assert; use function sprintf; use function trigger_error; +use const E_USER_DEPRECATED; /** * Handles running the Console Tools inside Symfony Console context. @@ -49,8 +50,8 @@ public static function run($helperSetOrConnectionProvider, $commands = []) $cli->setCatchExceptions(true); - /** @var ConnectionProvider|null $connectionProvider */ $connectionProvider = null; + assert($connectionProvider instanceof ConnectionProvider || $connectionProvider === null); if ($helperSetOrConnectionProvider instanceof HelperSet) { @trigger_error(sprintf('Passing an instance of "%s" as the first argument is deprecated. Pass an instance of "%s" instead.', HelperSet::class, ConnectionProvider::class), E_USER_DEPRECATED); $connectionProvider = null;