Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/DependencyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public function freeze(): void
$this->frozen = true;
}

public function unfreeze(): void
{
$this->frozen = false;
}

private function assertNotFrozen(): void
{
if ($this->frozen) {
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/CurrentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function configure(): void
parent::configure();
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$aliasResolver = $this->getDependencyFactory()->getVersionAliasResolver();

Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/DiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function configure(): void
}

/** @throws InvalidOptionUsage */
protected function execute(
protected function doExecute(
InputInterface $input,
OutputInterface $output,
): int {
Expand Down
11 changes: 11 additions & 0 deletions src/Tools/Console/Command/DoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
$dependencyFactory->freeze();
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
try {
return $this->doExecute($input, $output);
} finally {
$this->dependencyFactory?->unfreeze();
}
}

abstract protected function doExecute(InputInterface $input, OutputInterface $output): int;

protected function getDependencyFactory(): DependencyFactory
{
if ($this->dependencyFactory === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/DumpSchemaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function configure(): void
}

/** @throws SchemaDumpRequiresNoMigrations */
public function execute(
Copy link
Author

@nikophil nikophil Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this method was public

not sure this was made on purpose, but this change might be a small BC break in this case, if someone was using directly DumpSchemaCommand::execute() from outside. Should I handle this?

public function doExecute(
InputInterface $input,
OutputInterface $output,
): int {
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/ExecuteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected function configure(): void
parent::configure();
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$migratorConfigurationFactory = $this->getDependencyFactory()->getConsoleInputMigratorConfigurationFactory();
$migratorConfiguration = $migratorConfigurationFactory->getMigratorConfiguration($input);
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function configure(): void
parent::configure();
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$migrationGenerator = $this->getDependencyFactory()->getMigrationGenerator();

Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/LatestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function configure(): void
parent::configure();
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$aliasResolver = $this->getDependencyFactory()->getVersionAliasResolver();

Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function configure(): void
parent::configure();
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$versions = $this->getSortedVersions(
$this->getDependencyFactory()->getMigrationPlanCalculator()->getMigrations(), // available migrations
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected function configure(): void
parent::configure();
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$migratorConfigurationFactory = $this->getDependencyFactory()->getConsoleInputMigratorConfigurationFactory();
$migratorConfiguration = $migratorConfigurationFactory->getMigratorConfiguration($input);
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/RollupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function configure(): void
EOT);
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$question = sprintf(
'WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?',
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function configure(): void
parent::configure();
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$infosHelper = $this->getDependencyFactory()->getMigrationStatusInfosHelper();
$infosHelper->showMigrationsInfo($output);
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/SyncMetadataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function configure(): void
EOT);
}

public function execute(
public function doExecute(
InputInterface $input,
OutputInterface $output,
): int {
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/UpToDateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function configure(): void
parent::configure();
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$statusCalculator = $this->getDependencyFactory()->getMigrationStatusCalculator();

Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/VersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function configure(): void
}

/** @throws InvalidOptionUsage */
protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
if ($input->getOption('add') === false && $input->getOption('delete') === false) {
throw InvalidOptionUsage::new('You must specify whether you want to --add or --delete the specified version.');
Expand Down
23 changes: 14 additions & 9 deletions tests/Tools/Console/Command/DoctrineCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testCommandFreezes(): void

$command = new class ($dependencyFactory) extends DoctrineCommand
{
protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
return 0;
}
Expand All @@ -67,7 +67,7 @@ public function testCustomConfiguration(): void

$command = new class ($dependencyFactory) extends DoctrineCommand
{
protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$migrationDirectories = $this->getDependencyFactory()->getConfiguration()->getMigrationDirectories();
DoctrineCommandTest::assertSame(['DoctrineMigrationsTest' => 'bar'], $migrationDirectories);
Expand All @@ -88,6 +88,11 @@ public function testDependencyFactoryIsSetFirst(): void
$dependencyFactory = $this->createMock(DependencyFactory::class);
$command = new class ($dependencyFactory) extends DoctrineCommand
{
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
return 0;
}

protected function configure(): void
{
$this->getDependencyFactory();
Expand Down Expand Up @@ -122,7 +127,7 @@ public function __construct(EntityManager $entityManager, DependencyFactory $dep
$this->expectedEm = $entityManager;
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$em = $this->getDependencyFactory()->getEntityManager();
DoctrineCommandTest::assertSame($this->expectedEm, $em);
Expand Down Expand Up @@ -163,7 +168,7 @@ public function __construct(Connection $connection, DependencyFactory $dependenc
$this->expectedConnection = $connection;
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$connection = $this->getDependencyFactory()->getConnection();
DoctrineCommandTest::assertSame($this->expectedConnection, $connection);
Expand Down Expand Up @@ -196,7 +201,7 @@ public function testCanNotSpecifyBothEmAndConnection(): void

$command = new class ($dependencyFactory) extends DoctrineCommand
{
protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
return 0;
}
Expand Down Expand Up @@ -239,7 +244,7 @@ protected function configure(): void
);
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandTest::assertSame($this->getNamespace($input, $output), 'DoctrineMigrations');

Expand Down Expand Up @@ -282,7 +287,7 @@ protected function configure(): void
);
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
$this->getNamespace($input, $output);

Expand Down Expand Up @@ -327,7 +332,7 @@ protected function configure(): void
);
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandTest::assertSame($this->getNamespace($input, $output), 'DoctrineMigrations');

Expand Down Expand Up @@ -368,7 +373,7 @@ protected function configure(): void
);
}

protected function execute(InputInterface $input, OutputInterface $output): int
protected function doExecute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandTest::assertSame($this->getNamespace($input, $output), 'DoctrineMigrationsTwo');

Expand Down