Skip to content

Commit

Permalink
cs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mmasiukevich committed Aug 16, 2020
1 parent f008030 commit 0ac1855
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/Sql/Migration/Migration.php
Expand Up @@ -29,7 +29,6 @@ abstract class Migration

final public function __construct()
{

}

final protected function add(string $query, array $params = []): void
Expand All @@ -41,4 +40,4 @@ final protected function add(string $query, array $params = []): void
abstract protected function up(): void;

abstract protected function down(): void;
}
}
12 changes: 6 additions & 6 deletions src/Sql/Migration/SqlMigrationLoader.php
Expand Up @@ -42,14 +42,14 @@ public function __construct(string $directory)
public function load(): Promise
{
return call(
function(): \Generator
function (): \Generator
{
$migrations = [];

/** @var \SplFileInfo[] $supportedFiles */
$supportedFiles = yield from $this->loadFiles();

foreach($supportedFiles as $file)
foreach ($supportedFiles as $file)
{
/**
* @psalm-suppress UnresolvableInclude
Expand All @@ -66,7 +66,7 @@ function(): \Generator

$migration = new $class;

if(($migration instanceof Migration) === false)
if (($migration instanceof Migration) === false)
{
throw new \RuntimeException(
\sprintf('Migration must extend `%s` class', Migration::class)
Expand All @@ -91,14 +91,14 @@ function(): \Generator
private function loadFiles(): Promise
{
return call(
function(): \Generator
function (): \Generator
{
/** @var string[] $files */
$files = yield scandir($this->directory);

return \array_filter(
\array_map(
function(string $fileName): ?\SplFileInfo
function (string $fileName): ?\SplFileInfo
{
return \strpos($fileName, 'Version') !== false
? new \SplFileInfo($this->directory . '/' . $fileName)
Expand All @@ -110,4 +110,4 @@ function(string $fileName): ?\SplFileInfo
}
);
}
}
}
12 changes: 5 additions & 7 deletions src/Sql/Migration/SqlMigrationProcessor.php
Expand Up @@ -78,7 +78,7 @@ private function process(string $direction): Promise
{
/** @psalm-suppress InvalidArgument */
return $this->storage->transactional(
function(QueryExecutor $queryExecutor) use ($direction): \Generator
function (QueryExecutor $queryExecutor) use ($direction): \Generator
{
/** @var Migration[] $migrations */
$migrations = yield from $this->migrationsLoader->load();
Expand All @@ -91,7 +91,7 @@ function(QueryExecutor $queryExecutor) use ($direction): \Generator
* @var string $version
* @var Migration $migration
*/
foreach($migrations as $version => $migration)
foreach ($migrations as $version => $migration)
{
/**
* @psalm-suppress InvalidScalarArgument
Expand All @@ -104,7 +104,7 @@ function(QueryExecutor $queryExecutor) use ($direction): \Generator
);

/** Миграция была добавлена ранее */
if($resultSet->affectedRows() === 0)
if ($resultSet->affectedRows() === 0)
{
$this->logger->debug('Skip "{version}" migration', ['version' => $version]);

Expand All @@ -119,7 +119,7 @@ function(QueryExecutor $queryExecutor) use ($direction): \Generator
/** @var array $parameters */
$parameters = readReflectionPropertyValue($migration, 'params');

foreach($queries as $query)
foreach ($queries as $query)
{
/** @psalm-suppress MixedArgument */
yield $queryExecutor->execute($query, $parameters[\sha1($query)] ?? []);
Expand All @@ -128,6 +128,4 @@ function(QueryExecutor $queryExecutor) use ($direction): \Generator
}
);
}


}
}

0 comments on commit 0ac1855

Please sign in to comment.