Skip to content

Commit

Permalink
Remove deprecated Comparator::compare()
Browse files Browse the repository at this point in the history
The method has been deprecated and scheduled for removal since doctrine#4707.
  • Loading branch information
trompette committed Jul 16, 2021
1 parent 3713f6a commit 6de842b
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 140 deletions.
10 changes: 10 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ awareness about deprecated code.

# Upgrade to 4.0

## Removed static keyword from `Comparator::compareSchemas($fromSchema, $toSchema)` signature

The method `Comparator::compareSchemas($fromSchema, $toSchema)` cannot be called
statically anymore.

## Removed `Comparator::compare($fromSchema, $toSchema)`

The method `Comparator::compare($fromSchema, $toSchema)` has been removed, use
`Comparator::compareSchemas($fromSchema, $toSchema)` instead.

## Removed `TableGenerator` component

The `TableGenerator` component has been removed.
Expand Down
8 changes: 0 additions & 8 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ parameters:
paths:
- %currentWorkingDirectory%/src/Platforms/AbstractPlatform.php

# See https://github.com/doctrine/dbal/pull/4707
# TODO: remove in 4.0.0
-
message: '~^Dynamic call to static method Doctrine\\DBAL\\Schema\\Comparator::compareSchemas\(\)\.$~'
paths:
- %currentWorkingDirectory%/src/Schema/AbstractSchemaManager.php
- %currentWorkingDirectory%/src/Schema/Comparator.php
- %currentWorkingDirectory%/src/Schema/Schema.php
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
Expand Down
7 changes: 0 additions & 7 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@
-->
<referencedMethod name="Doctrine\DBAL\Query\QueryBuilder::execute"/>
<referencedMethod name="Doctrine\DBAL\Statement::execute"/>
<!--
See https://github.com/doctrine/dbal/pull/4707
TODO: remove in 4.0.0
-->
<file name="src/Schema/Comparator.php" />
<file name="tests/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php" />
<file name="tests/Schema/ComparatorTest.php" />
</errorLevel>
</DeprecatedMethod>
<DocblockTypeContradiction>
Expand Down
23 changes: 1 addition & 22 deletions src/Schema/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Doctrine\DBAL\Schema;

use Doctrine\DBAL\Types;
use Doctrine\Deprecations\Deprecation;

use function array_intersect_key;
use function array_key_exists;
Expand All @@ -26,11 +25,9 @@ class Comparator
/**
* Returns a SchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.
*
* This method should be called non-statically since it will be declared as non-static in the next major release.
*
* @throws SchemaException
*/
public static function compareSchemas(Schema $fromSchema, Schema $toSchema): SchemaDiff
public function compareSchemas(Schema $fromSchema, Schema $toSchema): SchemaDiff
{
$comparator = new self();
$diff = new SchemaDiff();
Expand Down Expand Up @@ -147,24 +144,6 @@ public static function compareSchemas(Schema $fromSchema, Schema $toSchema): Sch
return $diff;
}

/**
* @deprecated Use non-static call to {@link compareSchemas()} instead.
*
* @return SchemaDiff
*
* @throws SchemaException
*/
public function compare(Schema $fromSchema, Schema $toSchema)
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4707',
'Method compare() is deprecated. Use a non-static call to compareSchemas() instead.'
);

return $this->compareSchemas($fromSchema, $toSchema);
}

private function isAutoIncrementSequenceInSchema(Schema $schema, Sequence $sequence): bool
{
foreach ($schema->getTables() as $table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testAlterPrimaryKeyToAutoIncrementColumn(): void
$newTable->dropPrimaryKey();
$newTable->setPrimaryKey(['new_id']);

$diff = (new Comparator())->compare($schema, $newSchema);
$diff = (new Comparator())->compareSchemas($schema, $newSchema);

foreach ($diff->toSql($this->getPlatform()) as $sql) {
$this->connection->executeStatement($sql);
Expand Down
Loading

0 comments on commit 6de842b

Please sign in to comment.