diff --git a/.php_cs.dist b/.php_cs.dist index 040725a..7e030f1 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -9,6 +9,7 @@ $config = PhpCsFixer\Config::create() '@PSR2' => true, '@Symfony' => true, 'array_syntax' => ['syntax' => 'short'], + 'concat_space' => ['spacing' => 'one'], ]) ->setFinder($finder) ; diff --git a/src/AntiMattr/MongoDB/Migrations/AbstractMigration.php b/src/AntiMattr/MongoDB/Migrations/AbstractMigration.php index e8b1d17..4d8359b 100644 --- a/src/AntiMattr/MongoDB/Migrations/AbstractMigration.php +++ b/src/AntiMattr/MongoDB/Migrations/AbstractMigration.php @@ -118,7 +118,7 @@ public function warnIf($condition, $message = '') $message = (strlen($message)) ? $message : 'Unknown Reason'; if (true === $condition) { - $this->outputWriter->write(' Warning during '.$this->version->getExecutionState().': '.$message.''); + $this->outputWriter->write(' Warning during ' . $this->version->getExecutionState() . ': ' . $message . ''); } } diff --git a/src/AntiMattr/MongoDB/Migrations/Configuration/AbstractFileConfiguration.php b/src/AntiMattr/MongoDB/Migrations/Configuration/AbstractFileConfiguration.php index 46e4bf2..d878a63 100644 --- a/src/AntiMattr/MongoDB/Migrations/Configuration/AbstractFileConfiguration.php +++ b/src/AntiMattr/MongoDB/Migrations/Configuration/AbstractFileConfiguration.php @@ -44,7 +44,7 @@ public function load($file) if ($this->loaded) { throw new ConfigurationFileAlreadyLoadedException('Migrations configuration file already loaded'); } - if (file_exists($path = getcwd().'/'.$file)) { + if (file_exists($path = getcwd() . '/' . $file)) { $file = $path; } $this->file = $file; @@ -54,7 +54,7 @@ public function load($file) protected function getDirectoryRelativeToFile($file, $input) { - $path = realpath(dirname($file).'/'.$input); + $path = realpath(dirname($file) . '/' . $input); if (false !== $path) { $directory = $path; } else { diff --git a/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php b/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php index a525826..c62ed47 100644 --- a/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php +++ b/src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php @@ -443,14 +443,14 @@ public function registerMigrationsFromDirectory($path) { $path = realpath($path); $path = rtrim($path, '/'); - $files = glob($path.'/Version*.php'); + $files = glob($path . '/Version*.php'); $versions = []; if ($files) { foreach ($files as $file) { require_once $file; $info = pathinfo($file); $version = substr($info['filename'], 7); - $class = $this->migrationsNamespace.'\\'.$info['filename']; + $class = $this->migrationsNamespace . '\\' . $info['filename']; $versions[] = $this->registerMigration($version, $class); } } diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php index d9b1502..c17cf51 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/AbstractCommand.php @@ -50,10 +50,10 @@ protected function outputHeader(Configuration $configuration, OutputInterface $o { $name = $configuration->getName(); $name = $name ? $name : 'AntiMattr Database Migrations'; - $name = str_repeat(' ', 20).$name.str_repeat(' ', 20); - $output->writeln(''.str_repeat(' ', strlen($name)).''); - $output->writeln(''.$name.''); - $output->writeln(''.str_repeat(' ', strlen($name)).''); + $name = str_repeat(' ', 20) . $name . str_repeat(' ', 20); + $output->writeln('' . str_repeat(' ', strlen($name)) . ''); + $output->writeln('' . $name . ''); + $output->writeln('' . str_repeat(' ', strlen($name)) . ''); $output->writeln(''); } @@ -120,15 +120,15 @@ protected function createConnection($params) { $credentials = ''; if (isset($params['password'])) { - $credentials = ':'.$params['password']; + $credentials = ':' . $params['password']; } if (isset($params['user'])) { - $credentials = $params['user'].$credentials.'@'; + $credentials = $params['user'] . $credentials . '@'; } $database = ''; if (isset($params['dbname'])) { - $database = '/'.$params['dbname']; + $database = '/' . $params['dbname']; } $server = sprintf( diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/GenerateCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/GenerateCommand.php index 6952ac2..0d0558a 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/GenerateCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/GenerateCommand.php @@ -114,8 +114,8 @@ protected function generateMigration(Configuration $configuration, InputInterfac $replacements = [ $configuration->getMigrationsNamespace(), $version, - $up ? ' '.implode("\n ", explode("\n", $up)) : null, - $down ? ' '.implode("\n ", explode("\n", $down)) : null, + $up ? ' ' . implode("\n ", explode("\n", $up)) : null, + $down ? ' ' . implode("\n ", explode("\n", $down)) : null, ]; $code = str_replace($placeHolders, $replacements, self::$_template); diff --git a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php index c6bee6c..312fa6a 100644 --- a/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php +++ b/src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/StatusCommand.php @@ -100,9 +100,9 @@ public function execute(InputInterface $input, OutputInterface $output) 'Current Version' => $currentVersionFormatted, 'Latest Version' => $latestVersionFormatted, 'Executed Migrations' => $configMap['num_executed_migrations'], - 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations > 0 ? ''.$numExecutedUnavailableMigrations.'' : 0, + 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations > 0 ? '' . $numExecutedUnavailableMigrations . '' : 0, 'Available Migrations' => $configMap['num_available_migrations'], - 'New Migrations' => $numNewMigrations > 0 ? ''.$numNewMigrations.'' : 0, + 'New Migrations' => $numNewMigrations > 0 ? '' . $numNewMigrations . '' : 0, ]; foreach ($info as $name => $value) { @@ -133,7 +133,7 @@ public function execute(InputInterface $input, OutputInterface $output) $versionTxt = sprintf('%s', $version->getVersion()); $desc = $version->getMigration()->getDescription(); if (strlen($desc) > 80) { - $desc = substr($desc, 0, 78).'...'; + $desc = substr($desc, 0, 78) . '...'; } $rows[] = [$versionTxt, $status, $desc]; diff --git a/src/AntiMattr/MongoDB/Migrations/Version.php b/src/AntiMattr/MongoDB/Migrations/Version.php index 6c87085..5ac9402 100644 --- a/src/AntiMattr/MongoDB/Migrations/Version.php +++ b/src/AntiMattr/MongoDB/Migrations/Version.php @@ -187,12 +187,12 @@ public function execute($direction, $replay = false) $this->state = self::STATE_PRE; - $this->migration->{'pre'.ucfirst($direction)}($this->db); + $this->migration->{'pre' . ucfirst($direction)}($this->db); if ('up' === $direction) { - $this->outputWriter->write("\n".sprintf(' ++ migrating %s', $this->version)."\n"); + $this->outputWriter->write("\n" . sprintf(' ++ migrating %s', $this->version) . "\n"); } else { - $this->outputWriter->write("\n".sprintf(' -- reverting %s', $this->version)."\n"); + $this->outputWriter->write("\n" . sprintf(' -- reverting %s', $this->version) . "\n"); } $this->state = self::STATE_EXEC; @@ -210,7 +210,7 @@ public function execute($direction, $replay = false) $this->summarizeStatistics(); $this->state = self::STATE_POST; - $this->migration->{'post'.ucfirst($direction)}($this->db); + $this->migration->{'post' . ucfirst($direction)}($this->db); $end = microtime(true); $this->time = round($end - $start, 2); @@ -260,7 +260,7 @@ public function executeScript(Database $db, $file) throw new \RuntimeException('Missing Configuration for migrations script directory'); } - $path = realpath($scripts.'/'.$file); + $path = realpath($scripts . '/' . $file); if (!file_exists($path)) { throw new \InvalidArgumentException(sprintf('Could not execute %s. File does not exist.', $path)); } @@ -337,12 +337,12 @@ private function summarizeStatistics() $this->outputWriter->write(sprintf("\n Collection %s\n", $key)); $line = ' '; - $line .= 'metric '.str_repeat(' ', 16 - strlen('metric')); - $line .= 'before '.str_repeat(' ', 20 - strlen('before')); - $line .= 'after '.str_repeat(' ', 20 - strlen('after')); - $line .= 'difference '.str_repeat(' ', 20 - strlen('difference')); + $line .= 'metric ' . str_repeat(' ', 16 - strlen('metric')); + $line .= 'before ' . str_repeat(' ', 20 - strlen('before')); + $line .= 'after ' . str_repeat(' ', 20 - strlen('after')); + $line .= 'difference ' . str_repeat(' ', 20 - strlen('difference')); - $this->outputWriter->write($line."\n ".str_repeat('=', 80)); + $this->outputWriter->write($line . "\n " . str_repeat('=', 80)); $before = $statistic->getBefore(); $after = $statistic->getAfter(); @@ -351,10 +351,10 @@ private function summarizeStatistics() $valueAfter = isset($after[$metric]) ? $after[$metric] : 0; $difference = $valueAfter - $valueBefore; - $nameMessage = $metric.str_repeat(' ', 16 - strlen($metric)); - $beforeMessage = $valueBefore.str_repeat(' ', 20 - strlen($valueBefore)); - $afterMessage = $valueAfter.str_repeat(' ', 20 - strlen($valueAfter)); - $differenceMessage = $difference.str_repeat(' ', 20 - strlen($difference)); + $nameMessage = $metric . str_repeat(' ', 16 - strlen($metric)); + $beforeMessage = $valueBefore . str_repeat(' ', 20 - strlen($valueBefore)); + $afterMessage = $valueAfter . str_repeat(' ', 20 - strlen($valueAfter)); + $differenceMessage = $difference . str_repeat(' ', 20 - strlen($difference)); $line = sprintf( ' %s %s %s %s', diff --git a/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/ConfigurationTest.php b/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/ConfigurationTest.php index 93c1b9d..e847c4f 100644 --- a/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/ConfigurationTest.php +++ b/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/ConfigurationTest.php @@ -49,7 +49,7 @@ public function testGetCurrentVersion() { $this->prepareValidConfiguration(); - $directory = dirname(__DIR__).'/Resources/Migrations/'; + $directory = dirname(__DIR__) . '/Resources/Migrations/'; $this->configuration->registerMigrationsFromDirectory($directory); $collection = $this->buildMock('Doctrine\MongoDB\Collection'); @@ -178,7 +178,7 @@ public function testRegisterMigrationsFromDirectory() $this->configuration->setMigrationsNamespace('Example\Migrations\TestAntiMattr\MongoDB'); $this->assertFalse($this->configuration->hasVersion('20140822185742')); - $directory = dirname(__DIR__).'/Resources/Migrations/'; + $directory = dirname(__DIR__) . '/Resources/Migrations/'; $this->configuration->registerMigrationsFromDirectory($directory); $this->assertEquals(3, count($this->configuration->getMigrations())); @@ -274,7 +274,7 @@ public function testValidate() private function prepareValidConfiguration() { - $directory = dirname(__DIR__).'/Resources/Migrations/'; + $directory = dirname(__DIR__) . '/Resources/Migrations/'; $this->configuration->setMigrationsDatabaseName('test_antimattr_migrations'); $this->configuration->setMigrationsDirectory($directory); $this->configuration->setMigrationsNamespace('Example\Migrations\TestAntiMattr\MongoDB'); diff --git a/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/XmlConfigurationTest.php b/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/XmlConfigurationTest.php index 473adb7..0a227b4 100644 --- a/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/XmlConfigurationTest.php +++ b/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/XmlConfigurationTest.php @@ -10,7 +10,7 @@ public function loadConfiguration() { $connection = $this->getConnection(); $config = new XmlConfiguration($connection); - $config->load(dirname(__DIR__).'/Resources/fixtures/config.xml'); + $config->load(dirname(__DIR__) . '/Resources/fixtures/config.xml'); return $config; } diff --git a/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/YamlConfigurationTest.php b/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/YamlConfigurationTest.php index 461bae5..c327f71 100644 --- a/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/YamlConfigurationTest.php +++ b/tests/AntiMattr/Tests/MongoDB/Migrations/Configuration/YamlConfigurationTest.php @@ -10,7 +10,7 @@ public function loadConfiguration() { $connection = $this->getConnection(); $config = new YamlConfiguration($connection); - $config->load(dirname(__DIR__).'/Resources/fixtures/config.yml'); + $config->load(dirname(__DIR__) . '/Resources/fixtures/config.yml'); return $config; } diff --git a/tests/AntiMattr/Tests/MongoDB/Migrations/Tools/Console/Command/StatusCommandTest.php b/tests/AntiMattr/Tests/MongoDB/Migrations/Tools/Console/Command/StatusCommandTest.php index 1100057..94fc8c7 100644 --- a/tests/AntiMattr/Tests/MongoDB/Migrations/Tools/Console/Command/StatusCommandTest.php +++ b/tests/AntiMattr/Tests/MongoDB/Migrations/Tools/Console/Command/StatusCommandTest.php @@ -489,6 +489,6 @@ public function getMigrationConfiguration(InputInterface $input, OutputInterface */ protected function writeInfoLine(OutputInterface $output, $name, $value) { - $output->writeln($name.'::'.$value); + $output->writeln($name . '::' . $value); } } diff --git a/tests/AntiMattr/Tests/MongoDB/Migrations/VersionTest.php b/tests/AntiMattr/Tests/MongoDB/Migrations/VersionTest.php index f6f0100..106f085 100644 --- a/tests/AntiMattr/Tests/MongoDB/Migrations/VersionTest.php +++ b/tests/AntiMattr/Tests/MongoDB/Migrations/VersionTest.php @@ -278,13 +278,13 @@ public function testExecuteThrowsSkipException($direction) public function testExecute($direction) { $this->migration->expects($this->once()) - ->method('pre'.$direction); + ->method('pre' . $direction); $this->migration->expects($this->once()) ->method($direction); $this->migration->expects($this->once()) - ->method('post'.$direction); + ->method('post' . $direction); $collection = $this->buildMock('Doctrine\MongoDB\Collection'); $this->configuration->expects($this->once())