$createdSchemas * @param array $droppedSchemas * @param array $createdTables * @param array $alteredTables * @param array $droppedTables * @param array $createdSequences * @param array $alteredSequences * @param array $droppedSequences */ public function __construct( public array $createdSchemas, public array $droppedSchemas, public array $createdTables, public array $alteredTables, public array $droppedTables, public array $createdSequences, public array $alteredSequences, public array $droppedSequences, ) { $this->alteredTables = array_filter($alteredTables, static function (TableDiff $diff): bool { return !$diff->isEmpty(); }); // NOTE: parent::__construct() not called by intention. } /** @return array */ public function getCreatedSchemas(): array { return $this->createdSchemas; } /** @return array */ public function getDroppedSchemas(): array { return $this->droppedSchemas; } /** @return array */ public function getCreatedTables(): array { return $this->createdTables; } /** @return array */ public function getAlteredTables(): array { return $this->alteredTables; } /** @return array */ public function getDroppedTables(): array { return $this->droppedTables; } /** @return array */ public function getCreatedSequences(): array { return $this->createdSequences; } /** @return array */ public function getAlteredSequences(): array { return $this->alteredSequences; } /** @return array */ public function getDroppedSequences(): array { return $this->droppedSequences; } /** * Returns whether the diff is empty (contains no changes). */ public function isEmpty(): bool { return count($this->createdSchemas) === 0 && count($this->droppedSchemas) === 0 && count($this->createdTables) === 0 && count($this->alteredTables) === 0 && count($this->droppedTables) === 0 && count($this->createdSequences) === 0 && count($this->alteredSequences) === 0 && count($this->droppedSequences) === 0; } public static function ensure(SchemaDiff|DoctrineSchemaDiff $schemaDiff, array $additionalArguments = []): self { return new self(...[ 'createdSchemas' => $schemaDiff->getCreatedSchemas(), 'droppedSchemas' => $schemaDiff->getDroppedSchemas(), 'createdTables' => self::ensureCollection(...$schemaDiff->getCreatedTables()), 'alteredTables' => self::ensureCollection(...$schemaDiff->getAlteredTables()), 'droppedTables' => self::ensureCollection(...$schemaDiff->getDroppedTables()), 'createdSequences' => $schemaDiff->getCreatedSequences(), 'alteredSequences' => $schemaDiff->getAlteredSequences(), 'droppedSequences' => $schemaDiff->getDroppedSequences(), ...$additionalArguments, ]); } /** * @param DoctrineTableDiff|TableDiff|Table ...$tableDiffs * @return TableDiff[]|Table[] */ public static function ensureCollection(DoctrineTableDiff|TableDiff|Table ...$tableDiffs): array { $collection = []; foreach ($tableDiffs as $key => $tableDiff) { if ($tableDiff instanceof DoctrineTableDiff) { $tableDiff = TableDiff::ensure($tableDiff); } if (is_int($key) || MathUtility::canBeInterpretedAsInteger($key)) { $key = $tableDiff instanceof Table ? $tableDiff->getName() : $tableDiff->getOldTable()->getName(); } $collection[$key] = $tableDiff; } return $collection; } }