|
4 | 4 |
|
5 | 5 | namespace Doctrine\DBAL\Schema;
|
6 | 6 |
|
| 7 | +use Doctrine\Deprecations\Deprecation; |
| 8 | + |
7 | 9 | use function array_filter;
|
| 10 | +use function array_values; |
8 | 11 | use function count;
|
9 | 12 |
|
10 | 13 | /**
|
@@ -60,6 +63,52 @@ public function getChangedColumns(): array
|
60 | 63 | return $this->changedColumns;
|
61 | 64 | }
|
62 | 65 |
|
| 66 | + /** |
| 67 | + * @deprecated Use {@see getChangedColumns()} instead. |
| 68 | + * |
| 69 | + * @return list<ColumnDiff> |
| 70 | + */ |
| 71 | + public function getModifiedColumns(): array |
| 72 | + { |
| 73 | + Deprecation::triggerIfCalledFromOutside( |
| 74 | + 'doctrine/dbal', |
| 75 | + 'https://github.com/doctrine/dbal/pull/6280', |
| 76 | + '%s is deprecated, use `getChangedColumns()` instead.', |
| 77 | + __METHOD__, |
| 78 | + ); |
| 79 | + |
| 80 | + return array_values(array_filter( |
| 81 | + $this->getChangedColumns(), |
| 82 | + static fn (ColumnDiff $diff): bool => $diff->countChangedProperties() > ($diff->hasNameChanged() ? 1 : 0), |
| 83 | + )); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * @deprecated Use {@see getChangedColumns()} instead. |
| 88 | + * |
| 89 | + * @return array<string,Column> |
| 90 | + */ |
| 91 | + public function getRenamedColumns(): array |
| 92 | + { |
| 93 | + Deprecation::triggerIfCalledFromOutside( |
| 94 | + 'doctrine/dbal', |
| 95 | + 'https://github.com/doctrine/dbal/pull/6280', |
| 96 | + '%s is deprecated, you should use `getChangedColumns()` instead.', |
| 97 | + __METHOD__, |
| 98 | + ); |
| 99 | + $renamed = []; |
| 100 | + foreach ($this->getChangedColumns() as $diff) { |
| 101 | + if (! $diff->hasNameChanged()) { |
| 102 | + continue; |
| 103 | + } |
| 104 | + |
| 105 | + $oldColumnName = $diff->getOldColumn()->getName(); |
| 106 | + $renamed[$oldColumnName] = $diff->getNewColumn(); |
| 107 | + } |
| 108 | + |
| 109 | + return $renamed; |
| 110 | + } |
| 111 | + |
63 | 112 | /** @return array<Column> */
|
64 | 113 | public function getDroppedColumns(): array
|
65 | 114 | {
|
|
0 commit comments