$addedColumns * @param array $modifiedColumns * @param array $droppedColumns * @param array $addedIndexes * @param array $changedIndexes * @param array $removedIndexes * @param list $addedForeignKeys * @param list $changedForeignKeys * @param list $removedForeignKeys * @param array $renamedColumns * @param array $renamedIndexes */ public function __construct( $tableName, $addedColumns = [], $modifiedColumns = [], $droppedColumns = [], $addedIndexes = [], $changedIndexes = [], $removedIndexes = [], ?Table $fromTable = null, $addedForeignKeys = [], $changedForeignKeys = [], $removedForeignKeys = [], $renamedColumns = [], $renamedIndexes = [] ) { $this->name = $tableName; $this->addedColumns = $addedColumns; $this->changedColumns = $modifiedColumns; $this->renamedColumns = $renamedColumns; $this->removedColumns = $droppedColumns; $this->addedIndexes = $addedIndexes; $this->changedIndexes = $changedIndexes; $this->renamedIndexes = $renamedIndexes; $this->removedIndexes = $removedIndexes; $this->addedForeignKeys = $addedForeignKeys; $this->changedForeignKeys = $changedForeignKeys; $this->removedForeignKeys = $removedForeignKeys; if ($fromTable === null) { Deprecation::trigger( 'doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5678', 'Not passing the $fromTable to %s is deprecated.', __METHOD__, ); } $this->fromTable = $fromTable; } /** * @deprecated Use {@see getOldTable()} instead. * * @param AbstractPlatform $platform The platform to use for retrieving this table diff's name. * * @return Identifier */ public function getName(AbstractPlatform $platform) { return new Identifier( $this->fromTable instanceof Table ? $this->fromTable->getQuotedName($platform) : $this->name, ); } /** * @deprecated Rename tables via {@link AbstractSchemaManager::renameTable()} instead. * * @return Identifier|false */ public function getNewName() { Deprecation::triggerIfCalledFromOutside( 'doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5663', '%s is deprecated. Rename tables via AbstractSchemaManager::renameTable() instead.', __METHOD__, ); if ($this->newName === false) { return false; } return new Identifier($this->newName); } public function getOldTable(): ?Table { return $this->fromTable; } /** @return list */ public function getAddedColumns(): array { return array_values($this->addedColumns); } /** @return list */ public function getModifiedColumns(): array { return array_values($this->changedColumns); } /** @return list */ public function getDroppedColumns(): array { return array_values($this->removedColumns); } /** @return array */ public function getRenamedColumns(): array { return $this->renamedColumns; } /** @return list */ public function getAddedIndexes(): array { return array_values($this->addedIndexes); } /** * @internal This method exists only for compatibility with the current implementation of schema managers * that modify the diff while processing it. */ public function unsetAddedIndex(Index $index): void { $this->addedIndexes = array_filter( $this->addedIndexes, static function (Index $addedIndex) use ($index): bool { return $addedIndex !== $index; }, ); } /** @return array */ public function getModifiedIndexes(): array { return array_values($this->changedIndexes); } /** @return list */ public function getDroppedIndexes(): array { return array_values($this->removedIndexes); } /** * @internal This method exists only for compatibility with the current implementation of schema managers * that modify the diff while processing it. */ public function unsetDroppedIndex(Index $index): void { $this->removedIndexes = array_filter( $this->removedIndexes, static function (Index $removedIndex) use ($index): bool { return $removedIndex !== $index; }, ); } /** @return array */ public function getRenamedIndexes(): array { return $this->renamedIndexes; } /** @return list */ public function getAddedForeignKeys(): array { return $this->addedForeignKeys; } /** @return list */ public function getModifiedForeignKeys(): array { return $this->changedForeignKeys; } /** @return list */ public function getDroppedForeignKeys(): array { return $this->removedForeignKeys; } /** * @internal This method exists only for compatibility with the current implementation of the schema comparator. * * @param ForeignKeyConstraint|string $foreignKey */ public function unsetDroppedForeignKey($foreignKey): void { $this->removedForeignKeys = array_filter( $this->removedForeignKeys, static function ($removedForeignKey) use ($foreignKey): bool { return $removedForeignKey !== $foreignKey; }, ); } /** * Returns whether the diff is empty (contains no changes). */ public function isEmpty(): bool { return count($this->addedColumns) === 0 && count($this->changedColumns) === 0 && count($this->removedColumns) === 0 && count($this->renamedColumns) === 0 && count($this->addedIndexes) === 0 && count($this->changedIndexes) === 0 && count($this->removedIndexes) === 0 && count($this->renamedIndexes) === 0 && count($this->addedForeignKeys) === 0 && count($this->changedForeignKeys) === 0 && count($this->removedForeignKeys) === 0; } }