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
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@
*/
class MigrationConfiguration
{
/**
* @var string
*/
protected $comments;
protected ?string $comments;

/**
* @var string
*/
protected $warnings;
protected ?string $warnings;

/**
* @var array<int,mixed>
*/
protected $migration;
protected ?array $migration;

/**
* @param array<string,mixed> $configuration
Expand All @@ -44,42 +38,30 @@ public function __construct(array $configuration = [])
$this->migration = $configuration['migration'] ?? null;
}

/**
* @return string
*/
public function getComments()
public function getComments(): ?string
{
return $this->comments;
}

/**
* @return boolean
*/
public function hasComments()
public function hasComments(): bool
{
return ($this->comments !== null);
}

/**
* @return array<int,mixed>
*/
public function getMigration(): array
public function getMigration(): ?array
{
return $this->migration;
}

/**
* @return string
*/
public function getWarnings()
public function getWarnings(): ?string
{
return $this->warnings;
}

/**
* @return boolean
*/
public function hasWarnings()
public function hasWarnings(): bool
{
return ($this->warnings !== null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ public function executeMigration(ExecuteMigration $command): void
}

$transformationSteps = TransformationSteps::createEmpty();
foreach ($command->migrationConfiguration->getMigration() as $migrationDescription) {
$transformationSteps = $transformationSteps->merge($this->executeSubMigration(
$migrationDescription,
$command->sourceWorkspaceName,
$command->targetWorkspaceName
));
if ($command->migrationConfiguration->getMigration() !== null) {
foreach ($command->migrationConfiguration->getMigration() as $migrationDescription) {
$transformationSteps = $transformationSteps->merge($this->executeSubMigration(
$migrationDescription,
$command->sourceWorkspaceName,
$command->targetWorkspaceName
));
}
}

if ($command->requireConfirmation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ public function listCommand(): void

$tableRows = [];
foreach ($availableMigrations as $version => $migration) {
$migrationUpConfigurationComments = $this->migrationFactory->getMigrationForVersion($version)->getComments();
$migrationUpConfiguration = $this->migrationFactory->getMigrationForVersion($version);
/** @var string $migrationUpConfigurationComments */
$migrationUpConfigurationComments = $migrationUpConfiguration->hasComments() ? $migrationUpConfiguration->getComments() : '';

$tableRows[] = [
$version,
Expand All @@ -195,13 +197,13 @@ protected function outputCommentsAndWarnings(MigrationConfiguration $migrationCo
if ($migrationConfiguration->hasComments()) {
$this->outputLine();
$this->outputLine('<b>Comments</b>');
$this->outputFormatted($migrationConfiguration->getComments(), [], 2);
$this->outputFormatted($migrationConfiguration->getComments() ?? '', [], 2);
}

if ($migrationConfiguration->hasWarnings()) {
$this->outputLine();
$this->outputLine('<b><u>Warnings</u></b>');
$this->outputFormatted($migrationConfiguration->getWarnings(), [], 2);
$this->outputFormatted($migrationConfiguration->getWarnings() ?? '', [], 2);
}
}
}