Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary calls #221

Merged
merged 4 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/Command/DownCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
use Throwable;
use Yiisoft\Db\Migration\Informer\ConsoleMigrationInformer;
use Yiisoft\Db\Migration\Migrator;
use Yiisoft\Db\Migration\Runner\DownRunner;
use Yiisoft\Db\Migration\Service\MigrationService;
Expand All @@ -38,11 +37,8 @@ final class DownCommand extends Command
public function __construct(
private DownRunner $downRunner,
private MigrationService $migrationService,
private Migrator $migrator,
ConsoleMigrationInformer $informer
private Migrator $migrator
) {
$this->migrator->setInformer($informer);

parent::__construct();
}

Expand Down
8 changes: 6 additions & 2 deletions src/Command/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Yiisoft\Db\Migration\Migrator;
use Yiisoft\Db\Migration\Service\MigrationService;

use function count;
Expand All @@ -36,8 +37,10 @@
#[AsCommand('migrate:new', 'Displays not yet applied migrations.')]
final class NewCommand extends Command
{
public function __construct(private MigrationService $migrationService)
{
public function __construct(
private MigrationService $migrationService,
private Migrator $migrator
) {
parent::__construct();
}

Expand All @@ -53,6 +56,7 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$this->migrator->setIO($io);
$this->migrationService->setIO($io);

/** @psalm-var string[] $paths */
Expand Down
4 changes: 0 additions & 4 deletions src/Command/RedoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
use Throwable;
use Yiisoft\Db\Migration\Informer\ConsoleMigrationInformer;
use Yiisoft\Db\Migration\Migrator;
use Yiisoft\Db\Migration\Runner\DownRunner;
use Yiisoft\Db\Migration\Runner\UpdateRunner;
Expand Down Expand Up @@ -42,12 +41,9 @@ final class RedoCommand extends Command
public function __construct(
private MigrationService $migrationService,
private Migrator $migrator,
ConsoleMigrationInformer $informer,
private DownRunner $downRunner,
private UpdateRunner $updateRunner
) {
$this->migrator->setInformer($informer);

parent::__construct();
}

Expand Down
6 changes: 2 additions & 4 deletions src/Command/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
use Throwable;
use Yiisoft\Db\Migration\Informer\ConsoleMigrationInformer;
use Yiisoft\Db\Migration\Migrator;
use Yiisoft\Db\Migration\Runner\UpdateRunner;
use Yiisoft\Db\Migration\Service\MigrationService;
Expand Down Expand Up @@ -44,8 +43,7 @@ final class UpdateCommand extends Command
public function __construct(
private UpdateRunner $updateRunner,
private MigrationService $migrationService,
private Migrator $migrator,
ConsoleMigrationInformer $informer
private Migrator $migrator
) {
parent::__construct();
}
Expand All @@ -61,7 +59,7 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

$this->migrator->setIO($io);
$this->migrationService->setIO($io);
$this->updateRunner->setIO($io);

Expand Down
5 changes: 0 additions & 5 deletions src/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ public function __construct(
) {
}

public function setInformer(MigrationInformerInterface $informer): void
{
$this->informer = $informer;
}

public function setIO(?SymfonyStyle $io): void
{
$this->informer->setIO($io);
Expand Down
1 change: 0 additions & 1 deletion src/Service/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function __construct(
public function setIO(?SymfonyStyle $io): void
{
$this->io = $io;
$this->migrator->setIO($io);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions tests/Support/Helper/ContainerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,19 @@ public static function get(ContainerInterface $container, string $id, ContainerC
$container->get(UpdateRunner::class),
$container->get(MigrationService::class),
$container->get(Migrator::class),
$container->get(ConsoleMigrationInformer::class),
);

case DownCommand::class:
return new DownCommand(
$container->get(DownRunner::class),
$container->get(MigrationService::class),
$container->get(Migrator::class),
$container->get(ConsoleMigrationInformer::class),
);

case NewCommand::class:
return new NewCommand(
$container->get(MigrationService::class),
$container->get(Migrator::class),
);

case HistoryCommand::class:
Expand All @@ -105,7 +104,6 @@ public static function get(ContainerInterface $container, string $id, ContainerC
return new RedoCommand(
$container->get(MigrationService::class),
$container->get(Migrator::class),
$container->get(ConsoleMigrationInformer::class),
$container->get(DownRunner::class),
$container->get(UpdateRunner::class),
);
Expand Down