From 40b7838503403f9140ec966b202568d21b58683d Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Wed, 29 May 2019 23:13:09 -0500 Subject: [PATCH] Add proper types to Doctrine\DBAL\Tools namespace. --- .../Console/Command/ReservedWordsCommand.php | 11 +++-------- .../Tools/Console/Command/RunSqlCommand.php | 2 +- .../DBAL/Tools/Console/ConsoleRunner.php | 17 +++++------------ .../Tools/Console/Helper/ConnectionHelper.php | 4 +--- lib/Doctrine/DBAL/Tools/Dumper.php | 11 +++-------- 5 files changed, 13 insertions(+), 32 deletions(-) diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index 6e42f31931d..9c5ba8c79cd 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -30,7 +30,7 @@ class ReservedWordsCommand extends Command { - /** @var string[] */ + /** @var array */ private $keywordListClasses = [ 'db2' => DB2Keywords::class, 'mysql' => MySQLKeywords::class, @@ -48,13 +48,8 @@ class ReservedWordsCommand extends Command /** * If you want to add or replace a keywords list use this command. - * - * @param string $name - * @param string $class - * - * @return void */ - public function setKeywordListClass($name, $class) + public function setKeywordListClass(string $name, string $class) : void { $this->keywordListClasses[$name] = $class; } @@ -62,7 +57,7 @@ public function setKeywordListClass($name, $class) /** * {@inheritdoc} */ - protected function configure() + protected function configure() : void { $this ->setName('dbal:reserved-words') diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php index 4e6ab9cd275..b6e27a1c972 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -26,7 +26,7 @@ class RunSqlCommand extends Command /** * {@inheritdoc} */ - protected function configure() + protected function configure() : void { $this ->setName('dbal:run-sql') diff --git a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php index 32a00549c77..a7a1e987e68 100644 --- a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php @@ -20,10 +20,8 @@ class ConsoleRunner { /** * Create a Symfony Console HelperSet - * - * @return HelperSet */ - public static function createHelperSet(Connection $connection) + public static function createHelperSet(Connection $connection) : HelperSet { return new HelperSet([ 'db' => new ConnectionHelper($connection), @@ -33,11 +31,9 @@ public static function createHelperSet(Connection $connection) /** * Runs console with the given helperset. * - * @param Command[] $commands - * - * @return void + * @param array $commands */ - public static function run(HelperSet $helperSet, $commands = []) + public static function run(HelperSet $helperSet, array $commands = []) : void { $cli = new Application('Doctrine Command Line Interface', Versions::getVersion('doctrine/dbal')); @@ -50,10 +46,7 @@ public static function run(HelperSet $helperSet, $commands = []) $cli->run(); } - /** - * @return void - */ - public static function addCommands(Application $cli) + public static function addCommands(Application $cli) : void { $cli->addCommands([ new RunSqlCommand(), @@ -64,7 +57,7 @@ public static function addCommands(Application $cli) /** * Prints the instructions to create a configuration file */ - public static function printCliConfigTemplate() + public static function printCliConfigTemplate() : void { echo <<<'HELP' You are missing a "cli-config.php" or "config/cli-config.php" file in your diff --git a/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php b/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php index 836bd8d8568..971ee5629dc 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php +++ b/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php @@ -29,10 +29,8 @@ public function __construct(Connection $connection) /** * Retrieves the Doctrine database Connection. - * - * @return Connection */ - public function getConnection() + public function getConnection() : Connection { return $this->_connection; } diff --git a/lib/Doctrine/DBAL/Tools/Dumper.php b/lib/Doctrine/DBAL/Tools/Dumper.php index 36f44555414..aae049972e2 100644 --- a/lib/Doctrine/DBAL/Tools/Dumper.php +++ b/lib/Doctrine/DBAL/Tools/Dumper.php @@ -59,7 +59,7 @@ public static function dump($var, int $maxDepth = 2) : string { $html = ini_get('html_errors'); - if ($html !== true) { + if ($html !== '1') { ini_set('html_errors', '1'); } @@ -142,11 +142,9 @@ public static function export($var, int $maxDepth) * Fill the $return variable with class attributes * Based on obj2array function from {@see https://secure.php.net/manual/en/function.get-object-vars.php#47075} * - * @param object $var - * * @return mixed */ - private static function fillReturnWithClassAttributes($var, stdClass $return, int $maxDepth) + private static function fillReturnWithClassAttributes(object $var, stdClass $return, int $maxDepth) { $clone = (array) $var; @@ -162,10 +160,7 @@ private static function fillReturnWithClassAttributes($var, stdClass $return, in return $return; } - /** - * @param object $object - */ - private static function getClass($object) : string + private static function getClass(object $object) : string { $class = get_class($object);