From b4d0b35a1d6e1d5c3687f4360b38136f5cff8f04 Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Mon, 24 Jul 2023 13:38:19 +0200 Subject: [PATCH] Small code improvements based on review feedback [MAILPOET-5416] --- mailpoet/lib/Migrator/Repository.php | 6 +++--- mailpoet/lib/Migrator/Runner.php | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/mailpoet/lib/Migrator/Repository.php b/mailpoet/lib/Migrator/Repository.php index 56fba6f718..4e66196979 100644 --- a/mailpoet/lib/Migrator/Repository.php +++ b/mailpoet/lib/Migrator/Repository.php @@ -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); diff --git a/mailpoet/lib/Migrator/Runner.php b/mailpoet/lib/Migrator/Runner.php index c4b772ad9e..1d34e366f7 100644 --- a/mailpoet/lib/Migrator/Runner.php +++ b/mailpoet/lib/Migrator/Runner.php @@ -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) {