From 93ba9f6571fe9e7494cae5e09d427ad1c6bcfe53 Mon Sep 17 00:00:00 2001 From: Douglas Reith Date: Thu, 3 May 2018 12:13:06 +0000 Subject: [PATCH 1/3] Add fully namespaced params, vars, and returns to quieten scrutinizer errors --- .../MongoDB/Migrations/AbstractMigration.php | 10 +++---- .../Migrations/Collection/Statistics.php | 6 ++-- .../Configuration/Configuration.php | 30 +++++++++---------- .../Tools/Console/Command/AbstractCommand.php | 18 +++++------ .../Tools/Console/Command/ExecuteCommand.php | 4 +-- .../Tools/Console/Command/GenerateCommand.php | 8 ++--- .../Tools/Console/Command/MigrateCommand.php | 4 +-- .../Tools/Console/Command/StatusCommand.php | 4 +-- .../Tools/Console/Command/VersionCommand.php | 4 +-- src/AntiMattr/MongoDB/Migrations/Version.php | 22 +++++++------- 10 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/AntiMattr/MongoDB/Migrations/AbstractMigration.php b/src/AntiMattr/MongoDB/Migrations/AbstractMigration.php index ace6c99..330bca3 100644 --- a/src/AntiMattr/MongoDB/Migrations/AbstractMigration.php +++ b/src/AntiMattr/MongoDB/Migrations/AbstractMigration.php @@ -23,17 +23,17 @@ 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 AntiMattr\MongoDB\Migrations\Version + * @var \AntiMattr\MongoDB\Migrations\Version */ protected $version; @@ -56,7 +56,7 @@ 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) { @@ -64,7 +64,7 @@ protected function analyze(Collection $collection) } /** - * @param Doctrine\MongoDB\Database + * @param \Doctrine\MongoDB\Database * @param string $filename */ protected function executeScript(Database $db, $filename) diff --git a/src/AntiMattr/MongoDB/Migrations/Collection/Statistics.php b/src/AntiMattr/MongoDB/Migrations/Collection/Statistics.php index e99d560..fa1272d 100644 --- a/src/AntiMattr/MongoDB/Migrations/Collection/Statistics.php +++ b/src/AntiMattr/MongoDB/Migrations/Collection/Statistics.php @@ -42,7 +42,7 @@ class Statistics ]; /** - * @var Doctrine\MongoDB\Collection + * @var \Doctrine\MongoDB\Collection */ private $collection; @@ -57,7 +57,7 @@ class Statistics private $after = []; /** - * @param Doctrine\MongoDB\Collection + * @param \Doctrine\MongoDB\Collection */ public function setCollection(Collection $collection) { @@ -65,7 +65,7 @@ public function setCollection(Collection $collection) } /** - * @return Doctrine\MongoDB\Collection + * @return \Doctrine\MongoDB\Collection */ public function getCollection() { diff --git a/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php b/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php index 8877a32..7a55158 100644 --- a/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php +++ b/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php @@ -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; @@ -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) { @@ -151,7 +151,7 @@ public function getAvailableVersions() } /** - * @return Doctrine\MongoDB\Collection + * @return \Doctrine\MongoDB\Collection */ public function getCollection() { @@ -165,7 +165,7 @@ public function getCollection() } /** - * @return Doctrine\MongoDB\Connection + * @return \Doctrine\MongoDB\Connection */ public function getConnection() { @@ -173,7 +173,7 @@ public function getConnection() } /** - * @return Doctrine\MongoDB\Database + * @return \Doctrine\MongoDB\Database */ public function getDatabase(): ?Database { @@ -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() { @@ -379,7 +379,7 @@ public function getNumberOfExecutedMigrations() } /** - * @return AntiMattr\MongoDB\Migrations\OutputWriter + * @return \AntiMattr\MongoDB\Migrations\OutputWriter */ public function getOutputWriter() { @@ -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 */ @@ -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 */ diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php index c17cf51..b3f98b9 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php @@ -25,7 +25,7 @@ abstract class AbstractCommand extends Command { /** - * @var AntiMattr\MongoDB\Migrations\Configuration\Configuration + * @var \AntiMattr\MongoDB\Migrations\Configuration\Configuration */ private $configuration; @@ -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) { @@ -58,7 +58,7 @@ protected function outputHeader(Configuration $configuration, OutputInterface $o } /** - * @param AntiMattr\MongoDB\Migrations\Configuration\Configuration + * @param \AntiMattr\MongoDB\Migrations\Configuration\Configuration */ public function setMigrationConfiguration(Configuration $config) { @@ -66,10 +66,10 @@ public function setMigrationConfiguration(Configuration $config) } /** - * @param Symfony\Component\Console\Output\InputInterface $input - * @param Symfony\Component\Console\Output\OutputInterface $output + * @param \Symfony\Component\Console\Output\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) { @@ -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) { diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/ExecuteCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/ExecuteCommand.php index 121aeac..a4bdb75 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/ExecuteCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/ExecuteCommand.php @@ -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) { diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/GenerateCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/GenerateCommand.php index 0d0558a..67d423b 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/GenerateCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/GenerateCommand.php @@ -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) { @@ -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 diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/MigrateCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/MigrateCommand.php index 8212ab2..6c13c3d 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/MigrateCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/MigrateCommand.php @@ -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) { diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php index 312fa6a..ef0abf9 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php @@ -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) { diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/VersionCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/VersionCommand.php index f7134e9..50c77d7 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/VersionCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/VersionCommand.php @@ -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 diff --git a/src/AntiMattr/MongoDB/Migrations/Version.php b/src/AntiMattr/MongoDB/Migrations/Version.php index b48ae06..df94840 100644 --- a/src/AntiMattr/MongoDB/Migrations/Version.php +++ b/src/AntiMattr/MongoDB/Migrations/Version.php @@ -36,22 +36,22 @@ class Version private $class; /** - * @var AntiMattr\MongoDB\Migrations\Configuration\Configuration + * @var \AntiMattr\MongoDB\Migrations\Configuration\Configuration */ private $configuration; /** - * @var Doctrine\MongoDB\Connection + * @var \Doctrine\MongoDB\Connection */ private $connection; /** - * @var AntiMattr\MongoDB\Migrations\AbstractMigration + * @var \AntiMattr\MongoDB\Migrations\AbstractMigration */ protected $migration; /** - * @var AntiMattr\MongoDB\Migrations\OutputWriter + * @var \AntiMattr\MongoDB\Migrations\OutputWriter */ private $outputWriter; @@ -63,7 +63,7 @@ class Version private $version; /** - * @var AntiMattr\MongoDB\Migrations\Collection\Statistics[] + * @var \AntiMattr\MongoDB\Migrations\Collection\Statistics[] */ private $statistics = []; @@ -89,7 +89,7 @@ public function __construct(Configuration $configuration, $version, $class) } /** - * @return AntiMattr\MongoDB\Migrations\Configuration\Configuration $configuration + * @return \AntiMattr\MongoDB\Migrations\Configuration\Configuration $configuration */ public function getConfiguration() { @@ -111,7 +111,7 @@ public function getExecutionState() } /** - * @return AntiMattr\MongoDB\Migrations\AbstractMigration + * @return \AntiMattr\MongoDB\Migrations\AbstractMigration */ public function getMigration() { @@ -145,7 +145,7 @@ public function getVersion() } /** - * @param Doctrine\MongoDB\Collection + * @param \Doctrine\MongoDB\Collection */ public function analyze(Collection $collection) { @@ -244,7 +244,7 @@ public function execute($direction, $replay = false) } /** - * @param Doctrine\MongoDB\Database + * @param \Doctrine\MongoDB\Database * @param string $file * * @return array @@ -374,7 +374,7 @@ public function __toString() } /** - * @return AntiMattr\MongoDB\Migrations\AbstractMigration + * @return \AntiMattr\MongoDB\Migrations\AbstractMigration */ protected function createMigration() { @@ -390,7 +390,7 @@ protected function createMongoTimestamp() } /** - * @return AntiMattr\MongoDB\Migrations\Collection\Statistics + * @return \AntiMattr\MongoDB\Migrations\Collection\Statistics */ protected function createStatistics() { From 18c028041e5a89226ba6c076c88a1a5d5d213df5 Mon Sep 17 00:00:00 2001 From: Douglas Reith Date: Thu, 3 May 2018 12:27:57 +0000 Subject: [PATCH 2/3] Apply scrutinizer recommendations, fix return type --- .../MongoDB/Migrations/Configuration/Configuration.php | 8 ++++---- .../Migrations/Tools/Console/Command/AbstractCommand.php | 2 +- .../Migrations/Tools/Console/Command/StatusCommand.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php b/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php index 7a55158..e901c28 100644 --- a/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php +++ b/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php @@ -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(); @@ -329,7 +329,7 @@ public function getMigratedTimestamp($version) // Convert to normalised timestamp $ts = new Timestamp($returnVersion['t']); - return (string) $ts; + return $ts->getTimestamp(); } /** @@ -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(); } diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php index b3f98b9..7355d2d 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php @@ -66,7 +66,7 @@ public function setMigrationConfiguration(Configuration $config) } /** - * @param \Symfony\Component\Console\Output\InputInterface $input + * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * * @return \AntiMattr\MongoDB\Migrations\Configuration\Configuration diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php index ef0abf9..f0167d2 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php @@ -146,7 +146,7 @@ public function execute(InputInterface $input, OutputInterface $output) } $executedUnavailableMigrations = $configuration->getUnavailableMigratedVersions(); - if ($executedUnavailableMigrations) { + if (!empty($executedUnavailableMigrations)) { $output->writeln("\n == Previously Executed Unavailable Migration Versions\n"); foreach ($executedUnavailableMigrations as $executedUnavailableMigration) { $output->writeln( From cc4367e335553f68577858254776d3660f59e512 Mon Sep 17 00:00:00 2001 From: Douglas Reith Date: Thu, 3 May 2018 12:29:58 +0000 Subject: [PATCH 3/3] Remove unused variable and fix doc comment --- src/AntiMattr/MongoDB/Migrations/Migration.php | 2 +- src/AntiMattr/MongoDB/Migrations/Version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AntiMattr/MongoDB/Migrations/Migration.php b/src/AntiMattr/MongoDB/Migrations/Migration.php index 4d9c26e..bbc3687 100644 --- a/src/AntiMattr/MongoDB/Migrations/Migration.php +++ b/src/AntiMattr/MongoDB/Migrations/Migration.php @@ -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(); } diff --git a/src/AntiMattr/MongoDB/Migrations/Version.php b/src/AntiMattr/MongoDB/Migrations/Version.php index df94840..630aae2 100644 --- a/src/AntiMattr/MongoDB/Migrations/Version.php +++ b/src/AntiMattr/MongoDB/Migrations/Version.php @@ -167,7 +167,7 @@ public function analyze(Collection $collection) } /** - * Execute this migration version up or down and and return the SQL. + * Execute this migration version up or down * * @param string $direction The direction to execute the migration * @param bool $replay If the migration is being replayed