Skip to content

Fix/cleanup scrutinizer issues #37

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

Merged
merged 4 commits into from
May 6, 2018
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
24 changes: 5 additions & 19 deletions src/AntiMattr/MongoDB/Migrations/AbstractMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,24 @@
abstract class AbstractMigration
{
/**
* @var AntiMattr\MongoDB\Migrations\Configuration\Configuration
* @var \AntiMattr\MongoDB\Migrations\Configuration\Configuration
*/
private $configuration;

/**
* @var AntiMattr\MongoDB\Migrations\OutputWriter
* @var \AntiMattr\MongoDB\Migrations\OutputWriter
*/
private $outputWriter;

/**
* @var Doctrine\MongoDB\Connection
*/
protected $connection;

/**
* @var Doctrine\MongoDB\Database
*/
protected $db;

/**
* @var AntiMattr\MongoDB\Migrations\Version
* @var \AntiMattr\MongoDB\Migrations\Version
*/
protected $version;

public function __construct(Version $version)
{
$this->configuration = $version->getConfiguration();
$this->outputWriter = $this->configuration->getOutputWriter();
$this->connection = $this->configuration->getConnection();
$this->connection = $this->connection->selectDatabase(
$this->configuration->getMigrationsDatabaseName()
);
$this->version = $version;
}

Expand All @@ -70,15 +56,15 @@ abstract public function up(Database $db);
abstract public function down(Database $db);

/**
* @param Doctrine\MongoDB\Collection
* @param \Doctrine\MongoDB\Collection
*/
protected function analyze(Collection $collection)
{
$this->version->analyze($collection);
}

/**
* @param Doctrine\MongoDB\Database
* @param \Doctrine\MongoDB\Database
* @param string $filename
*/
protected function executeScript(Database $db, $filename)
Expand Down
6 changes: 3 additions & 3 deletions src/AntiMattr/MongoDB/Migrations/Collection/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Statistics
];

/**
* @var Doctrine\MongoDB\Collection
* @var \Doctrine\MongoDB\Collection
*/
private $collection;

Expand All @@ -57,15 +57,15 @@ class Statistics
private $after = [];

/**
* @param Doctrine\MongoDB\Collection
* @param \Doctrine\MongoDB\Collection
*/
public function setCollection(Collection $collection)
{
$this->collection = $collection;
}

/**
* @return Doctrine\MongoDB\Collection
* @return \Doctrine\MongoDB\Collection
*/
public function getCollection()
{
Expand Down
38 changes: 19 additions & 19 deletions src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@
class Configuration
{
/**
* @var Doctrine\MongoDB\Collection
* @var \Doctrine\MongoDB\Collection
*/
private $collection;

/**
* @var Doctrine\MongoDB\Connection
* @var \Doctrine\MongoDB\Connection
*/
private $connection;

/**
* @var Doctrine\MongoDB\Database
* @var \Doctrine\MongoDB\Database
*/
private $database;

/**
* @var Doctrine\MongoDB\Connection
* @var \Doctrine\MongoDB\Connection
*/
private $migrationsDatabase;

Expand Down Expand Up @@ -94,18 +94,18 @@ class Configuration
private $name;

/**
* @var AntiMattr\MongoDB\Migrations\Version[]
* @var \AntiMattr\MongoDB\Migrations\Version[]
*/
protected $migrations = [];

/**
* @var AntiMattr\MongoDB\Migrations\OutputWriter
* @var \AntiMattr\MongoDB\Migrations\OutputWriter
*/
private $outputWriter;

/**
* @param Doctrine\MongoDB\Connection $connection
* @param AntiMattr\MongoDB\Migrations\OutputWriter $outputWriter
* @param \Doctrine\MongoDB\Connection $connection
* @param \AntiMattr\MongoDB\Migrations\OutputWriter $outputWriter
*/
public function __construct(Connection $connection, OutputWriter $outputWriter = null)
{
Expand Down Expand Up @@ -151,7 +151,7 @@ public function getAvailableVersions()
}

/**
* @return Doctrine\MongoDB\Collection
* @return \Doctrine\MongoDB\Collection
*/
public function getCollection()
{
Expand All @@ -165,15 +165,15 @@ public function getCollection()
}

/**
* @return Doctrine\MongoDB\Connection
* @return \Doctrine\MongoDB\Connection
*/
public function getConnection()
{
return $this->connection;
}

/**
* @return Doctrine\MongoDB\Database
* @return \Doctrine\MongoDB\Database
*/
public function getDatabase(): ?Database
{
Expand Down Expand Up @@ -281,7 +281,7 @@ public function getMigrationsScriptDirectory()
/**
* Returns all migrated versions from the versions collection, in an array.
*
* @return AntiMattr\MongoDB\Migrations\Version[]
* @return \AntiMattr\MongoDB\Migrations\Version[]
*/
public function getMigratedVersions()
{
Expand All @@ -301,12 +301,12 @@ public function getMigratedVersions()
*
* @param string $version
*
* @return string
* @return int
*
* @throws AntiMattr\MongoDB\Migrations\Exception\UnknownVersionException Throws exception if migration version does not exist
* @throws DomainException If more than one version exists
*/
public function getMigratedTimestamp($version)
public function getMigratedTimestamp($version): int
{
$this->createMigrationCollection();

Expand All @@ -329,7 +329,7 @@ public function getMigratedTimestamp($version)
// Convert to normalised timestamp
$ts = new Timestamp($returnVersion['t']);

return (string) $ts;
return $ts->getTimestamp();
}

/**
Expand Down Expand Up @@ -379,7 +379,7 @@ public function getNumberOfExecutedMigrations()
}

/**
* @return AntiMattr\MongoDB\Migrations\OutputWriter
* @return \AntiMattr\MongoDB\Migrations\OutputWriter
*/
public function getOutputWriter()
{
Expand Down Expand Up @@ -468,7 +468,7 @@ public function registerMigrationsFromDirectory($path)
*
* @param string $version The version string in the format YYYYMMDDHHMMSS
*
* @return AntiMattr\MongoDB\Migrations\Version
* @return \AntiMattr\MongoDB\Migrations\Version
*
* @throws AntiMattr\MongoDB\Migrations\Exception\UnknownVersionException Throws exception if migration version does not exist
*/
Expand Down Expand Up @@ -496,7 +496,7 @@ public function hasVersion($version)
/**
* Check if a version has been migrated or not yet.
*
* @param AntiMattr\MongoDB\Migrations\Version $version
* @param \AntiMattr\MongoDB\Migrations\Version $version
*
* @return bool
*/
Expand All @@ -517,7 +517,7 @@ public function getCurrentVersion()
$this->createMigrationCollection();

$migratedVersions = [];
if ($this->migrations) {
if (!empty($this->migrations)) {
foreach ($this->migrations as $migration) {
$migratedVersions[] = $migration->getVersion();
}
Expand Down
2 changes: 1 addition & 1 deletion src/AntiMattr/MongoDB/Migrations/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function migrate($to = null)

$time = 0;
foreach ($migrationsToExecute as $version) {
$versionSql = $version->execute($direction);
$version->execute($direction);
$time += $version->getTime();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
abstract class AbstractCommand extends Command
{
/**
* @var AntiMattr\MongoDB\Migrations\Configuration\Configuration
* @var \AntiMattr\MongoDB\Migrations\Configuration\Configuration
*/
private $configuration;

Expand All @@ -43,8 +43,8 @@ protected function configure()
}

/**
* @param AntiMattr\MongoDB\Migrations\Configuration\Configuration
* @param Symfony\Component\Console\Output\OutputInterface
* @param \AntiMattr\MongoDB\Migrations\Configuration\Configuration $configuration
* @param \Symfony\Component\Console\Output\OutputInterface $output
*/
protected function outputHeader(Configuration $configuration, OutputInterface $output)
{
Expand All @@ -58,18 +58,18 @@ protected function outputHeader(Configuration $configuration, OutputInterface $o
}

/**
* @param AntiMattr\MongoDB\Migrations\Configuration\Configuration
* @param \AntiMattr\MongoDB\Migrations\Configuration\Configuration
*/
public function setMigrationConfiguration(Configuration $config)
{
$this->configuration = $config;
}

/**
* @param Symfony\Component\Console\Output\InputInterface $input
* @param Symfony\Component\Console\Output\OutputInterface $output
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return AntiMattr\MongoDB\Migrations\Configuration\Configuration
* @return \AntiMattr\MongoDB\Migrations\Configuration\Configuration
*/
protected function getMigrationConfiguration(InputInterface $input, OutputInterface $output)
{
Expand Down Expand Up @@ -112,9 +112,9 @@ protected function getMigrationConfiguration(InputInterface $input, OutputInterf
}

/**
* @params array $params
* @param array $params
*
* @return Doctrine\MongoDB\Connection
* @return \Doctrine\MongoDB\Connection
*/
protected function createConnection($params)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ protected function configure()
}

/**
* @param Symfony\Component\Console\Input\InputInterface
* @param Symfony\Component\Console\Output\OutputInterface
* @param \Symfony\Component\Console\Input\InputInterface
* @param \Symfony\Component\Console\Output\OutputInterface
*/
public function execute(InputInterface $input, OutputInterface $output)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ protected function configure()
}

/**
* @param Symfony\Component\Console\Input\InputInterface
* @param Symfony\Component\Console\Output\OutputInterface
* @param \Symfony\Component\Console\Input\InputInterface
* @param \Symfony\Component\Console\Output\OutputInterface
*/
public function execute(InputInterface $input, OutputInterface $output)
{
Expand All @@ -93,8 +93,8 @@ public function execute(InputInterface $input, OutputInterface $output)
}

/**
* @param AntiMattr\MongoDB\Migrations\Configuration\Configuration
* @param Symfony\Component\Console\Input\InputInterface
* @param \AntiMattr\MongoDB\Migrations\Configuration\Configuration
* @param \Symfony\Component\Console\Input\InputInterface
* @param string $version
* @param string $up
* @param string $down
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ protected function configure()
}

/**
* @param Symfony\Component\Console\Input\InputInterface
* @param Symfony\Component\Console\Output\OutputInterface
* @param \Symfony\Component\Console\Input\InputInterface
* @param \Symfony\Component\Console\Output\OutputInterface
*/
public function execute(InputInterface $input, OutputInterface $output)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ protected function configure()
}

/**
* @param Symfony\Component\Console\Input\InputInterface
* @param Symfony\Component\Console\Output\OutputInterface
* @param \Symfony\Component\Console\Input\InputInterface
* @param \Symfony\Component\Console\Output\OutputInterface
*/
public function execute(InputInterface $input, OutputInterface $output)
{
Expand Down Expand Up @@ -146,7 +146,7 @@ public function execute(InputInterface $input, OutputInterface $output)
}

$executedUnavailableMigrations = $configuration->getUnavailableMigratedVersions();
if ($executedUnavailableMigrations) {
if (!empty($executedUnavailableMigrations)) {
$output->writeln("\n <info>==</info> Previously Executed Unavailable Migration Versions\n");
foreach ($executedUnavailableMigrations as $executedUnavailableMigration) {
$output->writeln(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ protected function configure()
}

/**
* @param Symfony\Component\Console\Input\InputInterface
* @param Symfony\Component\Console\Output\OutputInterface
* @param \Symfony\Component\Console\Input\InputInterface
* @param \Symfony\Component\Console\Output\OutputInterface
*
* @throws AntiMattr\MongoDB\Migrations\Exception\UnknownVersionException Throws exception if migration version does not exist
* @throws InvalidArgumentException
Expand Down
Loading