Small code improvements based on review feedback

[MAILPOET-5416]
This commit is contained in:
Rostislav Wolny
2023-07-24 13:38:19 +02:00
committed by Aschepikov
parent 5605259159
commit b4d0b35a1d
2 changed files with 4 additions and 5 deletions

View File

@@ -33,9 +33,9 @@ class Repository {
throw MigratorException::templateFileReadFailed($templateFile);
}
$name = $this->generateName($level);
$classDeclaration = str_replace('{level}', $level, 'class {level}MigrationTemplate ');
$migration = str_replace($classDeclaration, "class $name ", $template);
$path = $this->migrationsDir . "/$level" . "/$name.php";
$migration = str_replace('{level}', $level, 'class {level}MigrationTemplate ');
$migration = str_replace($migration, "class $name ", $template);
$path = "$this->migrationsDir/$level/$name.php";
$result = @file_put_contents($path, $migration);
if (!$result) {
throw MigratorException::migrationFileWriteFailed($path);

View File

@@ -29,10 +29,9 @@ class Runner {
$className = $this->getClassName($name, $level);
try {
/** @var DbMigration|AppMigration $migration */
$migration = new $className($this->container);
$this->store->startMigration($name);
// PHPStan does not recognize that $migration is instance of DbMigration or AppMigration
/** @phpstan-ignore-next-line */
$migration->run();
$this->store->completeMigration($name);
} catch (Throwable $e) {