44
55namespace Doctrine \DBAL \Schema ;
66
7- use Doctrine \DBAL \Exception \InvalidArgumentException ;
8- use Doctrine \DBAL \Schema \Exception \InvalidState ;
97use Doctrine \DBAL \Schema \Name \UnqualifiedName ;
108use Doctrine \Deprecations \Deprecation ;
119
@@ -23,14 +21,14 @@ final class TableDiff
2321 *
2422 * @internal The diff can be only instantiated by a {@see Comparator}.
2523 *
26- * @param array<ForeignKeyConstraint> $droppedForeignKeys
2724 * @param array<Column> $addedColumns
2825 * @param array<string, ColumnDiff> $changedColumns
2926 * @param array<Column> $droppedColumns
3027 * @param array<Index> $addedIndexes
3128 * @param array<Index> $droppedIndexes
3229 * @param array<string, Index> $renamedIndexes
3330 * @param array<ForeignKeyConstraint> $addedForeignKeys
31+ * @param array<UnqualifiedName> $droppedForeignKeyConstraintNames
3432 */
3533 public function __construct (
3634 private readonly Table $ oldTable ,
@@ -41,17 +39,10 @@ public function __construct(
4139 private array $ droppedIndexes = [],
4240 private readonly array $ renamedIndexes = [],
4341 private readonly array $ addedForeignKeys = [],
44- private readonly array $ droppedForeignKeys = [],
42+ private readonly array $ droppedForeignKeyConstraintNames = [],
4543 private readonly ?PrimaryKeyConstraint $ addedPrimaryKeyConstraint = null ,
4644 private readonly ?PrimaryKeyConstraint $ droppedPrimaryKeyConstraint = null ,
4745 ) {
48- foreach ($ droppedForeignKeys as $ droppedForeignKey ) {
49- if ($ droppedForeignKey ->getObjectName () === null ) {
50- throw new InvalidArgumentException (
51- 'Dropping a foreign key constraints without specifying its name is not allowed. ' ,
52- );
53- }
54- }
5546 }
5647
5748 public function getOldTable (): Table
@@ -179,31 +170,10 @@ public function getAddedForeignKeys(): array
179170 return $ this ->addedForeignKeys ;
180171 }
181172
182- /**
183- * @deprecated Use {@see getDroppedForeignKeyConstraintNames()}.
184- *
185- * @return array<ForeignKeyConstraint>
186- */
187- public function getDroppedForeignKeys (): array
188- {
189- return $ this ->droppedForeignKeys ;
190- }
191-
192173 /** @return array<UnqualifiedName> */
193174 public function getDroppedForeignKeyConstraintNames (): array
194175 {
195- $ names = [];
196- foreach ($ this ->droppedForeignKeys as $ constraint ) {
197- $ name = $ constraint ->getObjectName ();
198-
199- if ($ name === null ) {
200- throw InvalidState::tableDiffContainsUnnamedDroppedForeignKeyConstraints ();
201- }
202-
203- $ names [] = $ name ;
204- }
205-
206- return $ names ;
176+ return $ this ->droppedForeignKeyConstraintNames ;
207177 }
208178
209179 public function getAddedPrimaryKeyConstraint (): ?PrimaryKeyConstraint
@@ -228,7 +198,7 @@ public function isEmpty(): bool
228198 && count ($ this ->droppedIndexes ) === 0
229199 && count ($ this ->renamedIndexes ) === 0
230200 && count ($ this ->addedForeignKeys ) === 0
231- && count ($ this ->droppedForeignKeys ) === 0
201+ && count ($ this ->droppedForeignKeyConstraintNames ) === 0
232202 && $ this ->addedPrimaryKeyConstraint === null
233203 && $ this ->droppedPrimaryKeyConstraint === null ;
234204 }
0 commit comments