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

Remove AbstractPlatform::hasNative*Type() methods and Type::requiresSQLCommentHint() #5512

Merged
merged 2 commits into from
Jul 16, 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
7 changes: 4 additions & 3 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,14 @@ Postgres 9 is not actively supported anymore. The following classes have been me

## BC BREAK: Removed Platform "commented type" API

Since `Type::requiresSQLCommentTypeHint()` already allows determining whether a
type should result in SQL columns with a type hint in their comments, the
following methods are removed:
The following methods are removed:

- `AbstractPlatform::hasNativeJsonType()`
- `AbstractPlatform::hasNativeGuidType()`
- `AbstractPlatform::isCommentedDoctrineType()`
- `AbstractPlatform::initializeCommentedDoctrineTypes()`
- `AbstractPlatform::markDoctrineTypeCommented()`
- `Type::requiresSQLCommentHint()`

The protected property `AbstractPlatform::$doctrineTypeComments` is removed as
well.
Expand Down
18 changes: 0 additions & 18 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,6 @@
See https://github.com/doctrine/dbal/pull/4317
-->
<file name="tests/Functional/LegacyAPITest.php"/>
<!--
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Types\Type::requiresSQLCommentHint"/>
<referencedMethod name="Doctrine\DBAL\Types\DateImmutableType::requiresSQLCommentHint"/>
<referencedMethod name="Doctrine\DBAL\Types\DateIntervalType::requiresSQLCommentHint"/>
<referencedMethod name="Doctrine\DBAL\Types\DateTimeTzImmutableType::requiresSQLCommentHint"/>
<referencedMethod name="Doctrine\DBAL\Types\DateTimeImmutableType::requiresSQLCommentHint"/>
<referencedMethod name="Doctrine\DBAL\Types\GuidType::requiresSQLCommentHint"/>
<referencedMethod name="Doctrine\DBAL\Types\JsonType::requiresSQLCommentHint"/>
<referencedMethod name="Doctrine\DBAL\Types\TimeImmutableType::requiresSQLCommentHint"/>
<referencedMethod name="Doctrine\DBAL\Types\VarDateTimeImmutableType::requiresSQLCommentHint"/>
<!--
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::hasNativeGuidType"/>
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::hasNativeJsonType"/>
<referencedMethod name="Doctrine\DBAL\Platforms\PostgreSQLPlatform::hasNativeJsonType"/>
</errorLevel>
</DeprecatedMethod>
<DocblockTypeContradiction>
Expand Down
35 changes: 0 additions & 35 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
use Doctrine\DBAL\Types;
use Doctrine\DBAL\Types\Exception\TypeNotFound;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;
use InvalidArgumentException;
use UnexpectedValueException;

Expand Down Expand Up @@ -2286,40 +2285,6 @@ public function supportsCommentOnStatement(): bool
return false;
}

/**
* Does this platform have native guid type.
*
* @deprecated
*/
public function hasNativeGuidType(): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return false;
}

/**
* Does this platform have native JSON type.
*
* @deprecated
*/
public function hasNativeJsonType(): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return false;
}

/**
* Does this platform support column collation?
*/
Expand Down
5 changes: 0 additions & 5 deletions src/Platforms/MySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public function getDefaultValueDeclarationSQL(array $column): string
return parent::getDefaultValueDeclarationSQL($column);
}

public function hasNativeJsonType(): bool
{
return true;
}

/**
* {@inheritdoc}
*/
Expand Down
31 changes: 0 additions & 31 deletions src/Platforms/PostgreSQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BinaryType;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\Deprecations\Deprecation;
use UnexpectedValueException;

use function array_diff;
Expand Down Expand Up @@ -155,21 +154,6 @@ public function supportsCommentOnStatement(): bool
return true;
}

/**
* @deprecated
*/
public function hasNativeGuidType(): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return true;
}

public function getListDatabasesSQL(): string
{
return 'SELECT datname FROM pg_database';
Expand Down Expand Up @@ -823,21 +807,6 @@ protected function initializeDoctrineTypeMappings(): void
];
}

/**
* @deprecated
*/
public function hasNativeJsonType(): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return true;
}

protected function createReservedKeywordsList(): KeywordList
{
return new PostgreSQLKeywords();
Expand Down
16 changes: 0 additions & 16 deletions src/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\SQLServerSchemaManager;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\Deprecations\Deprecation;
use InvalidArgumentException;

use function array_merge;
Expand Down Expand Up @@ -155,21 +154,6 @@ public function getSequenceNextValSQL(string $sequence): string
return 'SELECT NEXT VALUE FOR ' . $sequence;
}

/**
* @deprecated
*/
public function hasNativeGuidType(): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return true;
}

public function getDropForeignKeySQL(string $foreignKey, string $table): string
{
return $this->getDropConstraintSQL($foreignKey, $table);
Expand Down
19 changes: 0 additions & 19 deletions src/Types/BooleanType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\Deprecations\Deprecation;

/**
* Type that maps an SQL boolean to a PHP boolean.
Expand Down Expand Up @@ -36,21 +34,4 @@ public function getBindingType(): int
{
return ParameterType::BOOLEAN;
}

/**
* @deprecated
*/
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

// We require a commented boolean type in order to distinguish between
// boolean and smallint as both (have to) map to the same native type.
return $platform instanceof DB2Platform;
}
}
16 changes: 0 additions & 16 deletions src/Types/DateImmutableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Exception\InvalidFormat;
use Doctrine\DBAL\Types\Exception\InvalidType;
use Doctrine\Deprecations\Deprecation;

/**
* Immutable type of {@see DateType}.
Expand Down Expand Up @@ -50,19 +49,4 @@ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?Da

return $dateTime;
}

/**
* @deprecated
*/
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return true;
}
}
16 changes: 0 additions & 16 deletions src/Types/DateIntervalType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Exception\InvalidFormat;
use Doctrine\DBAL\Types\Exception\InvalidType;
use Doctrine\Deprecations\Deprecation;
use Throwable;

use function substr;
Expand Down Expand Up @@ -68,19 +67,4 @@ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?Da
throw InvalidFormat::new($value, static::class, self::FORMAT, $exception);
}
}

/**
* @deprecated
*/
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return true;
}
}
16 changes: 0 additions & 16 deletions src/Types/DateTimeImmutableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Exception\InvalidFormat;
use Doctrine\DBAL\Types\Exception\InvalidType;
use Doctrine\Deprecations\Deprecation;

use function date_create_immutable;

Expand Down Expand Up @@ -56,19 +55,4 @@ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?Da

return $dateTime;
}

/**
* @deprecated
*/
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return true;
}
}
16 changes: 0 additions & 16 deletions src/Types/DateTimeTzImmutableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Exception\InvalidFormat;
use Doctrine\DBAL\Types\Exception\InvalidType;
use Doctrine\Deprecations\Deprecation;

/**
* Immutable type of {@see DateTimeTzType}.
Expand Down Expand Up @@ -50,19 +49,4 @@ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?Da

return $dateTime;
}

/**
* @deprecated
*/
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return true;
}
}
16 changes: 0 additions & 16 deletions src/Types/GuidType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Doctrine\DBAL\Types;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\Deprecations\Deprecation;

/**
* Represents a GUID/UUID datatype (both are actually synonyms) in the database.
Expand All @@ -19,19 +18,4 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
{
return $platform->getGuidTypeDeclarationSQL($column);
}

/**
* @deprecated
*/
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return ! $platform->hasNativeGuidType();
}
}
16 changes: 0 additions & 16 deletions src/Types/JsonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Exception\SerializationFailed;
use Doctrine\DBAL\Types\Exception\ValueNotConvertible;
use Doctrine\Deprecations\Deprecation;
use JsonException;

use function is_resource;
Expand Down Expand Up @@ -60,19 +59,4 @@ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mix
throw ValueNotConvertible::new($value, 'json', $e->getMessage(), $e);
}
}

/**
* @deprecated
*/
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5509',
'%s is deprecated.',
__METHOD__
);

return ! $platform->hasNativeJsonType();
}
}
Loading