Skip to content

Commit

Permalink
Fix phpcs and psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Sep 30, 2024
1 parent 0629a5e commit 46a3443
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
23 changes: 14 additions & 9 deletions src/Db/Adapter/PhinxAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -491,19 +492,21 @@ 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;
}

/**
* @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;
}
Expand All @@ -519,19 +522,21 @@ 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;
}

/**
* @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;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Migration/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
14 changes: 7 additions & 7 deletions src/Migration/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Manager
protected ?Environment $environment;

/**
* @var \Phinx\Migration\MigrationInterface[]|null
* @var \Migrations\MigrationInterface[]|null
*/
protected ?array $migrations = null;

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -857,12 +857,12 @@ function ($phpFile) {
}

$io->verbose("Constructing <info>$class</info>.");
/** @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);
Expand Down
2 changes: 0 additions & 2 deletions src/MigrationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/Shim/MigrationAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions tests/TestCase/Migration/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 46a3443

Please sign in to comment.