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) {