diff --git a/src/Db/Adapter/PhinxAdapter.php b/src/Db/Adapter/PhinxAdapter.php index f3cf451d..492ca369 100644 --- a/src/Db/Adapter/PhinxAdapter.php +++ b/src/Db/Adapter/PhinxAdapter.php @@ -33,6 +33,7 @@ use Migrations\Db\Table\ForeignKey; use Migrations\Db\Table\Index; use Migrations\Db\Table\Table; +use Migrations\Shim\MigrationAdapter; use Phinx\Db\Action\Action as PhinxAction; use Phinx\Db\Action\AddColumn as PhinxAddColumn; use Phinx\Db\Action\AddForeignKey as PhinxAddForeignKey; @@ -52,7 +53,7 @@ use Phinx\Db\Table\ForeignKey as PhinxForeignKey; use Phinx\Db\Table\Index as PhinxIndex; use Phinx\Db\Table\Table as PhinxTable; -use Phinx\Migration\MigrationInterface; +use Phinx\Migration\MigrationInterface as PhinxMigrationInterface; use Phinx\Util\Literal as PhinxLiteral; use RuntimeException; use Symfony\Component\Console\Input\InputInterface; @@ -491,9 +492,10 @@ public function getVersionLog(): array /** * @inheritDoc */ - public function migrated(MigrationInterface $migration, string $direction, string $startTime, string $endTime): PhinxAdapterInterface + public function migrated(PhinxMigrationInterface $migration, string $direction, string $startTime, string $endTime): PhinxAdapterInterface { - $this->adapter->migrated($migration, $direction, $startTime, $endTime); + $wrapped = new MigrationAdapter($migration, $migration->getVersion()); + $this->adapter->migrated($wrapped, $direction, $startTime, $endTime); return $this; } @@ -501,9 +503,10 @@ public function migrated(MigrationInterface $migration, string $direction, strin /** * @inheritDoc */ - public function toggleBreakpoint(MigrationInterface $migration): PhinxAdapterInterface + public function toggleBreakpoint(PhinxMigrationInterface $migration): PhinxAdapterInterface { - $this->adapter->toggleBreakpoint($migration); + $wrapped = new MigrationAdapter($migration, $migration->getVersion()); + $this->adapter->toggleBreakpoint($wrapped); return $this; } @@ -519,9 +522,10 @@ public function resetAllBreakpoints(): int /** * @inheritDoc */ - public function setBreakpoint(MigrationInterface $migration): PhinxAdapterInterface + public function setBreakpoint(PhinxMigrationInterface $migration): PhinxAdapterInterface { - $this->adapter->setBreakpoint($migration); + $wrapped = new MigrationAdapter($migration, $migration->getVersion()); + $this->adapter->setBreakpoint($wrapped); return $this; } @@ -529,9 +533,10 @@ public function setBreakpoint(MigrationInterface $migration): PhinxAdapterInterf /** * @inheritDoc */ - public function unsetBreakpoint(MigrationInterface $migration): PhinxAdapterInterface + public function unsetBreakpoint(PhinxMigrationInterface $migration): PhinxAdapterInterface { - $this->adapter->unsetBreakpoint($migration); + $wrapped = new MigrationAdapter($migration, $migration->getVersion()); + $this->adapter->unsetBreakpoint($wrapped); return $this; } diff --git a/src/Migration/Environment.php b/src/Migration/Environment.php index 0c1ff6a7..28d72572 100644 --- a/src/Migration/Environment.php +++ b/src/Migration/Environment.php @@ -12,9 +12,8 @@ use Cake\Datasource\ConnectionManager; use Migrations\Db\Adapter\AdapterFactory; use Migrations\Db\Adapter\AdapterInterface; -use Migrations\Db\Adapter\PhinxAdapter; -use Migrations\SeedInterface; use Migrations\MigrationInterface; +use Migrations\SeedInterface; use Migrations\Shim\MigrationAdapter; use RuntimeException; diff --git a/src/Migration/Manager.php b/src/Migration/Manager.php index b18591df..59872621 100644 --- a/src/Migration/Manager.php +++ b/src/Migration/Manager.php @@ -46,7 +46,7 @@ class Manager protected ?Environment $environment; /** - * @var \Phinx\Migration\MigrationInterface[]|null + * @var \Migrations\MigrationInterface[]|null */ protected ?array $migrations = null; @@ -254,16 +254,16 @@ public function markMigrated(int $version, string $path): bool } $migrationFile = $migrationFile[0]; - /** @var class-string<\Phinx\Migration\MigrationInterface> $className */ + /** @var class-string<\Phinx\Migration\MigrationInterface|\Migrations\MigrationInterface> $className */ $className = $this->getMigrationClassName($migrationFile); require_once $migrationFile; - /** @var \Migrations\MigrationInterface $migration */ if (is_subclass_of($className, PhinxMigrationInterface::class)) { $migration = new MigrationAdapter($className, $version); } else { $migration = new $className($version); } + /** @var \Migrations\MigrationInterface $migration */ $config = $this->getConfig(); $migration->setConfig($config); @@ -448,7 +448,7 @@ public function migrate(?int $version = null, bool $fake = false): void /** * Execute a migration against the specified environment. * - * @param \Phinx\Migration\MigrationInterface $migration Migration + * @param \Migrations\MigrationInterface $migration Migration * @param string $direction Direction * @param bool $fake flag that if true, we just record running the migration, but not actually do the migration * @return void @@ -512,7 +512,7 @@ public function executeSeed(SeedInterface $seed): void /** * Print Migration Status * - * @param \Phinx\Migration\MigrationInterface $migration Migration + * @param \Migrations\MigrationInterface $migration Migration * @param string $status Status of the migration * @param string|null $duration Duration the migration took the be executed * @return void @@ -813,7 +813,7 @@ function ($phpFile) { // filter the files to only get the ones that match our naming scheme $fileNames = []; - /** @var \Migration\MigrationInterface[] $versions */ + /** @var \Migrations\MigrationInterface[] $versions */ $versions = []; $io = $this->getIo(); @@ -857,12 +857,12 @@ function ($phpFile) { } $io->verbose("Constructing $class."); - /** @var \Migrations\MigrationInterface $migration */ if (is_subclass_of($class, PhinxMigrationInterface::class)) { $migration = new MigrationAdapter($class, $version); } else { $migration = new $class($version); } + /** @var \Migrations\MigrationInterface $migration */ $config = $this->getConfig(); $migration->setConfig($config); $migration->setIo($io); diff --git a/src/MigrationInterface.php b/src/MigrationInterface.php index 289a1065..7b6153f9 100644 --- a/src/MigrationInterface.php +++ b/src/MigrationInterface.php @@ -17,8 +17,6 @@ use Migrations\Config\ConfigInterface; use Migrations\Db\Adapter\AdapterInterface; use Migrations\Db\Table; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; /** * Migration interface. diff --git a/src/Shim/MigrationAdapter.php b/src/Shim/MigrationAdapter.php index 4452efae..6cc13236 100644 --- a/src/Shim/MigrationAdapter.php +++ b/src/Shim/MigrationAdapter.php @@ -64,7 +64,6 @@ class MigrationAdapter implements MigrationInterface * * @param string|object $migrationClass The phinx migration to adapt * @param int $version The migration version - * @param \Cake\Console\ConsoleIo $io The io */ public function __construct( string|object $migrationClass, diff --git a/tests/TestCase/Migration/ManagerTest.php b/tests/TestCase/Migration/ManagerTest.php index ad654b15..58393ef7 100644 --- a/tests/TestCase/Migration/ManagerTest.php +++ b/tests/TestCase/Migration/ManagerTest.php @@ -13,12 +13,10 @@ use Migrations\Db\Adapter\AdapterInterface; use Migrations\Migration\Environment; use Migrations\Migration\Manager; -use Migrations\Shim\OutputAdapter; use Phinx\Console\Command\AbstractCommand; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use RuntimeException; -use Symfony\Component\Console\Input\InputInterface; class ManagerTest extends TestCase {