Skip to content

Commit

Permalink
Merge pull request doctrine#3570 from jwage/tools-types
Browse files Browse the repository at this point in the history
Add proper types to Doctrine\DBAL\Tools namespace.
  • Loading branch information
morozov committed May 31, 2019
2 parents f065fd5 + 40b7838 commit 43b2149
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 32 deletions.
11 changes: 3 additions & 8 deletions lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class ReservedWordsCommand extends Command
{
/** @var string[] */
/** @var array<string, string> */
private $keywordListClasses = [
'db2' => DB2Keywords::class,
'mysql' => MySQLKeywords::class,
Expand All @@ -48,21 +48,16 @@ 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;
}

/**
* {@inheritdoc}
*/
protected function configure()
protected function configure() : void
{
$this
->setName('dbal:reserved-words')
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RunSqlCommand extends Command
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure() : void
{
$this
->setName('dbal:run-sql')
Expand Down
17 changes: 5 additions & 12 deletions lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -33,11 +31,9 @@ public static function createHelperSet(Connection $connection)
/**
* Runs console with the given helperset.
*
* @param Command[] $commands
*
* @return void
* @param array<int, Command> $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'));

Expand All @@ -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(),
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 3 additions & 8 deletions lib/Doctrine/DBAL/Tools/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down Expand Up @@ -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;

Expand All @@ -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);

Expand Down

0 comments on commit 43b2149

Please sign in to comment.