Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper types to Doctrine\DBAL\Tools namespace. #3570

Merged
merged 1 commit into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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