Small code improvements based on review feedback
[MAILPOET-5416]
This commit is contained in:
committed by
Aschepikov
parent
5605259159
commit
b4d0b35a1d
@@ -33,9 +33,9 @@ class Repository {
|
|||||||
throw MigratorException::templateFileReadFailed($templateFile);
|
throw MigratorException::templateFileReadFailed($templateFile);
|
||||||
}
|
}
|
||||||
$name = $this->generateName($level);
|
$name = $this->generateName($level);
|
||||||
$classDeclaration = str_replace('{level}', $level, 'class {level}MigrationTemplate ');
|
$migration = str_replace('{level}', $level, 'class {level}MigrationTemplate ');
|
||||||
$migration = str_replace($classDeclaration, "class $name ", $template);
|
$migration = str_replace($migration, "class $name ", $template);
|
||||||
$path = $this->migrationsDir . "/$level" . "/$name.php";
|
$path = "$this->migrationsDir/$level/$name.php";
|
||||||
$result = @file_put_contents($path, $migration);
|
$result = @file_put_contents($path, $migration);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw MigratorException::migrationFileWriteFailed($path);
|
throw MigratorException::migrationFileWriteFailed($path);
|
||||||
|
@@ -29,10 +29,9 @@ class Runner {
|
|||||||
$className = $this->getClassName($name, $level);
|
$className = $this->getClassName($name, $level);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
/** @var DbMigration|AppMigration $migration */
|
||||||
$migration = new $className($this->container);
|
$migration = new $className($this->container);
|
||||||
$this->store->startMigration($name);
|
$this->store->startMigration($name);
|
||||||
// PHPStan does not recognize that $migration is instance of DbMigration or AppMigration
|
|
||||||
/** @phpstan-ignore-next-line */
|
|
||||||
$migration->run();
|
$migration->run();
|
||||||
$this->store->completeMigration($name);
|
$this->store->completeMigration($name);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
|
Reference in New Issue
Block a user