Skip to content

Commit

Permalink
Add spacing around string concat operator
Browse files Browse the repository at this point in the history
  • Loading branch information
redthor committed Apr 3, 2018
1 parent 2dae57b commit 5b6844f
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 39 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $config = PhpCsFixer\Config::create()
'@PSR2' => true,
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
])
->setFinder($finder)
;
Expand Down
2 changes: 1 addition & 1 deletion src/AntiMattr/MongoDB/Migrations/AbstractMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function warnIf($condition, $message = '')
$message = (strlen($message)) ? $message : 'Unknown Reason';

if (true === $condition) {
$this->outputWriter->write(' <warning>Warning during '.$this->version->getExecutionState().': '.$message.'</warning>');
$this->outputWriter->write(' <warning>Warning during ' . $this->version->getExecutionState() . ': ' . $message . '</warning>');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('<question>'.str_repeat(' ', strlen($name)).'</question>');
$output->writeln('<question>'.$name.'</question>');
$output->writeln('<question>'.str_repeat(' ', strlen($name)).'</question>');
$name = str_repeat(' ', 20) . $name . str_repeat(' ', 20);
$output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>');
$output->writeln('<question>' . $name . '</question>');
$output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>');
$output->writeln('');
}

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? '<error>'.$numExecutedUnavailableMigrations.'</error>' : 0,
'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations > 0 ? '<error>' . $numExecutedUnavailableMigrations . '</error>' : 0,
'Available Migrations' => $configMap['num_available_migrations'],
'New Migrations' => $numNewMigrations > 0 ? '<question>'.$numNewMigrations.'</question>' : 0,
'New Migrations' => $numNewMigrations > 0 ? '<question>' . $numNewMigrations . '</question>' : 0,
];

foreach ($info as $name => $value) {
Expand Down Expand Up @@ -133,7 +133,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$versionTxt = sprintf('<comment>%s</comment>', $version->getVersion());
$desc = $version->getMigration()->getDescription();
if (strlen($desc) > 80) {
$desc = substr($desc, 0, 78).'...';
$desc = substr($desc, 0, 78) . '...';
}

$rows[] = [$versionTxt, $status, $desc];
Expand Down
28 changes: 14 additions & 14 deletions src/AntiMattr/MongoDB/Migrations/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(' <info>++</info> migrating <comment>%s</comment>', $this->version)."\n");
$this->outputWriter->write("\n" . sprintf(' <info>++</info> migrating <comment>%s</comment>', $this->version) . "\n");
} else {
$this->outputWriter->write("\n".sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->version)."\n");
$this->outputWriter->write("\n" . sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->version) . "\n");
}

$this->state = self::STATE_EXEC;
Expand All @@ -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);
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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();

Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions tests/AntiMattr/Tests/MongoDB/Migrations/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 5b6844f

Please sign in to comment.