Skip to content

Commit

Permalink
Deprecate Type::getName()
Browse files Browse the repository at this point in the history
It serves little to no purpose now.
  • Loading branch information
greg0ire committed Jan 26, 2022
1 parent b347cdb commit e0f4e26
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ awareness about deprecated code.

# Upgrade to 3.4

# Deprecated `Type::getName()`

This will method is not useful for the DBAL anymore, and will be removed in 4.0.
As a consequence, depending on the name of a type being `json` for `jsonb` to
be used for the Postgres platform is deprecated in favor of extending
`Doctrine\DBAL\Types\JsonType`.

# Deprecated `AbstractPlatform::getColumnComment()` and `AbstractPlatform::getDoctrineTypeComment()`

DBAL no longer needs column comments to ensure proper diffing. Note that both
Expand Down
13 changes: 13 additions & 0 deletions src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Types\JsonType;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\Deprecation;
Expand All @@ -15,6 +16,7 @@
use function array_shift;
use function assert;
use function explode;
use function get_class;
use function implode;
use function in_array;
use function preg_match;
Expand Down Expand Up @@ -530,6 +532,17 @@ protected function _getPortableTableColumnDefinition($tableColumn)
}

if ($column->getType()->getName() === Types::JSON) {
if (! $column->getType() instanceof JsonType) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5049',
'%s not extending %s while being named %s is deprecated, and will lead to jsonb never to being used in 4.0.',
get_class($column->getType()),
JsonType::class,
Types::JSON
);
}

$column->setPlatformOption('jsonb', $jsonb);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Types/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ abstract public function getSQLDeclaration(array $column, AbstractPlatform $plat
/**
* Gets the name of this type.
*
* @return string
* @deprecated this method will be removed in Doctrine DBAL 4.0.
*
* @todo Needed?
* @return string
*/
abstract public function getName();

Expand Down

0 comments on commit e0f4e26

Please sign in to comment.