Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate and mark internal APIs related to schema comparison #5650

Merged
merged 1 commit into from
Sep 3, 2022
Merged
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
16 changes: 13 additions & 3 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ awareness about deprecated code.
Relying on the default precision and scale of decimal columns provided by the DBAL is deprecated.
When declaring decimal columns, specify the precision and scale explicitly.

## Marked `ColumnDiff::hasChanged()` as internal.
## Marked `Comparator` methods as internal.

The `ColumnDiff::hasChanged()` method has been marked as internal. Use one of the following `ColumnDiff` methods
in order to check if a given column property has changed:
The following `Comparator` methods have been marked as internal:

- `columnsEqual()`,
- `diffForeignKey()`,
- `diffIndex()`.

The `diffColumn()` method has been deprecated. Use `diffTable()` instead.

## Deprecated `ColumnDiff::$changedProperties` and `::hasChanged()`.

The `ColumnDiff::$changedProperties` property and the `hasChanged()` method have been deprecated. Use one of the
following `ColumnDiff` methods in order to check if a given column property has changed:

- `hasTypeChanged()`,
- `hasLengthChanged()`,
Expand Down
9 changes: 9 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Schema\ColumnDiff::getOldColumnName"/>
<!--
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Schema\ColumnDiff::hasChanged"/>
<referencedMethod name="Doctrine\DBAL\Schema\Comparator::diffColumn"/>
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
Expand Down Expand Up @@ -451,6 +456,10 @@
TODO: remove in 4.0.0
-->
<referencedProperty name="Doctrine\DBAL\Schema\ColumnDiff::$oldColumnName"/>
<!--
TODO: remove in 4.0.0
-->
<referencedProperty name="Doctrine\DBAL\Schema\ColumnDiff::$changedProperties"/>
</errorLevel>
</DeprecatedProperty>
<DocblockTypeContradiction>
Expand Down
12 changes: 10 additions & 2 deletions src/Schema/ColumnDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ class ColumnDiff
/** @var Column */
public $column;

/** @var string[] */
/**
* @deprecated Use {@see hasTypeChanged()}, {@see hasLengthChanged()}, {@see hasPrecisionChanged()},
* {@see hasScaleChanged()}, {@see hasUnsignedChanged()}, {@see hasFixedChanged()}, {@see hasNotNullChanged()},
* {@see hasDefaultChanged()}, {@see hasAutoIncrementChanged()} or {@see hasCommentChanged()} instead.
*
* @var string[]
*/
public $changedProperties = [];

/** @var Column|null */
Expand Down Expand Up @@ -105,7 +111,9 @@ public function hasCommentChanged(): bool
}

/**
* @internal
* @deprecated Use {@see hasTypeChanged()}, {@see hasLengthChanged()}, {@see hasPrecisionChanged()},
* {@see hasScaleChanged()}, {@see hasUnsignedChanged()}, {@see hasFixedChanged()}, {@see hasNotNullChanged()},
* {@see hasDefaultChanged()}, {@see hasAutoIncrementChanged()} or {@see hasCommentChanged()} instead.
*
* @param string $propertyName
*
Expand Down
19 changes: 18 additions & 1 deletion src/Schema/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ private function detectIndexRenamings(TableDiff $tableDifferences): void
}
}

/** @return bool */
/**
* @internal The method should be only used from within the {@see Comparator} class hierarchy.
*
* @return bool
*/
public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2)
{
if (
Expand Down Expand Up @@ -498,6 +502,8 @@ public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint
/**
* Compares the definitions of the given columns
*
* @internal The method should be only used from within the {@see Comparator} class hierarchy.
*
* @throws Exception
*/
public function columnsEqual(Column $column1, Column $column2): bool
Expand All @@ -515,10 +521,19 @@ public function columnsEqual(Column $column1, Column $column2): bool
* If there are differences this method returns the changed properties as a
* string array, otherwise an empty array gets returned.
*
* @deprecated Use {@see diffTable()} instead.
*
* @return string[]
*/
public function diffColumn(Column $column1, Column $column2)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5650',
'%s is deprecated. Use diffTable() instead.',
__METHOD__,
);

$properties1 = $column1->toArray();
$properties2 = $column2->toArray();

Expand Down Expand Up @@ -609,6 +624,8 @@ public function diffColumn(Column $column1, Column $column2)
* Compares $index1 with $index2 and returns $index2 if there are any
* differences or false in case there are no differences.
*
* @internal The method should be only used from within the {@see Comparator} class hierarchy.
*
* @return bool
*/
public function diffIndex(Index $index1, Index $index2)
Expand Down