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 deprecated APIs #4831

Merged
merged 9 commits into from
Oct 2, 2021
56 changes: 56 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,62 @@ awareness about deprecated code.

# Upgrade to 4.0

## BC BREAK: Removed `AbstractSchemaManager::getSchemaSearchPaths()`.

The `AbstractSchemaManager::getSchemaSearchPaths()` method has been removed.

The schema configuration returned by `AbstractSchemaManager::createSchemaConfig()` will contain a non-empty schema name
only for those database platforms that support schemas (currently, PostgreSQL).

The schema returned by `AbstractSchemaManager::createSchema()` will have a non-empty name only for those
database platforms that support schemas.

## BC BREAK: Removed `AbstractAsset::getFullQualifiedName()`.

The `AbstractAsset::getFullQualifiedName()` method has been removed.

## BC BREAK: Removed schema methods related to explicit foreign key indexes.

The following methods have been removed:

- `Schema::hasExplicitForeignKeyIndexes()`,
- `SchemaConfig::hasExplicitForeignKeyIndexes()`,
- `SchemaConfig::setExplicitForeignKeyIndexes()`.

## BC BREAK: Removed `Schema::getTableNames()`.

The `Schema::getTableNames()` method has been removed.

## BC BREAK: Changes in `Schema` method return values.

The `Schema::getNamespaces()`, `Schema::getTables()` and `Schema::getSequences()` methods will return numeric arrays
of namespaces, tables and sequences respectively instead of associative arrays.

## BC BREAK: Removed `SqlitePlatform::udf*()` methods.

The following `SqlitePlatform` methods have been removed:

- `udfSqrt()`,
- `udfMod()`,
- `udfLocate()`.

## BC BREAK: `SQLServerPlatform` methods marked protected.

The following `SQLServerPlatform` methods have been marked protected:

- `getDefaultConstraintDeclarationSQL()`,
- `getAddExtendedPropertySQL()`,
- `getDropExtendedPropertySQL()`,
- `getUpdateExtendedPropertySQL()`.

## BC BREAK: `OraclePlatform` methods marked protected.

The `OraclePlatform::getCreateAutoincrementSql()` method has been marked protected.

## BC BREAK: Removed `OraclePlatform::assertValidIdentifier()`.

The `OraclePlatform::assertValidIdentifier()` method has been removed.

## BC BREAK: Changed signatures of `AbstractPlatform::getIndexDeclarationSQL()` and `::getUniqueConstraintDeclarationSQL()`

The `AbstractPlatform::getIndexDeclarationSQL()` and `::getUniqueConstraintDeclarationSQL()` methods no longer accept
Expand Down
1 change: 0 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<exclude name="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants.DisallowedLateStaticBindingForConstant"/>
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing.IncorrectLinesCountAfterLastControlStructure"/>
<exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator.RequiredNullCoalesceEqualOperator"/>

<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
<!-- https://github.com/slevomat/coding-standard/issues/867 -->
Expand Down
29 changes: 0 additions & 29 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,8 @@
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Schema\Schema::getMigrateToSql"/>
<!--
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Platforms\OraclePlatform::assertValidIdentifier"/>
<!--
TODO: remove in 4.0.0
See https://github.com/doctrine/dbal/pull/4822
-->
<referencedMethod name="Doctrine\DBAL\Schema\SchemaConfig::hasExplicitForeignKeyIndexes"/>
<!--
TODO: remove in 4.0.0
See https://github.com/doctrine/dbal/pull/4814
-->
<referencedMethod name="Doctrine\DBAL\Schema\AbstractAsset::getFullQualifiedName"/>
<!--
TODO: remove in 4.0.0
See https://github.com/doctrine/dbal/pull/4821
-->
<referencedMethod name="Doctrine\DBAL\Schema\AbstractSchemaManager::getSchemaSearchPaths"/>
<referencedMethod name="Doctrine\DBAL\Schema\PostgreSQLSchemaManager::getSchemaSearchPaths"/>
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
<errorLevel type="suppress">
<!--
This suppression should be removed in 4.0.x
See https://github.com/doctrine/dbal/pull/4822
-->
<referencedProperty name="Doctrine\DBAL\Schema\SchemaConfig::$hasExplicitForeignKeyIndexes"/>
</errorLevel>
</DeprecatedProperty>
<DocblockTypeContradiction>
<errorLevel type="suppress">
<!--
Expand Down
2 changes: 1 addition & 1 deletion src/Connections/PrimaryReadReplicaConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function connect(?string $connectionName = null): void
protected function performConnect(?string $connectionName = null): void
{
$requestedConnectionChange = ($connectionName !== null);
$connectionName = $connectionName ?? 'replica';
$connectionName ??= 'replica';

if ($connectionName !== 'replica' && $connectionName !== 'primary') {
throw new InvalidArgumentException('Invalid option to connect(), only primary or replica allowed.');
Expand Down
17 changes: 13 additions & 4 deletions src/Driver/PDO/SQLite/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,28 @@
namespace Doctrine\DBAL\Driver\PDO\SQLite;

use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
use Doctrine\DBAL\Driver\API\SQLite\UserDefinedFunctions;
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
use Doctrine\DBAL\Driver\PDO\Connection;
use Doctrine\DBAL\Platforms\SqlitePlatform;

use function array_merge;

final class Driver extends AbstractSQLiteDriver
{
/** @var mixed[] */
private array $userDefinedFunctions = [
'sqrt' => ['callback' => [SqlitePlatform::class, 'udfSqrt'], 'numArgs' => 1],
'mod' => ['callback' => [SqlitePlatform::class, 'udfMod'], 'numArgs' => 2],
'locate' => ['callback' => [SqlitePlatform::class, 'udfLocate'], 'numArgs' => -1],
'sqrt' => [
'callback' => 'sqrt',
'numArgs' => 1,
],
'mod' => [
'callback' => [UserDefinedFunctions::class, 'mod'],
'numArgs' => 2,
],
'locate' => [
'callback' => [UserDefinedFunctions::class, 'locate'],
'numArgs' => -1,
],
];

/**
Expand Down
21 changes: 1 addition & 20 deletions src/Platforms/OraclePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception\ColumnLengthRequired;
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
use Doctrine\DBAL\Platforms\Keywords\OracleKeywords;
Expand Down Expand Up @@ -33,22 +32,6 @@
*/
class OraclePlatform extends AbstractPlatform
{
/**
* Assertion for Oracle identifiers.
*
* @deprecated
*
* @link http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements008.htm
*
* @throws Exception
*/
public static function assertValidIdentifier(string $identifier): void
{
if (preg_match('(^(([a-zA-Z]{1}[a-zA-Z0-9_$#]{0,})|("[^"]+"))$)', $identifier) === 0) {
throw new Exception('Invalid Oracle identifier.');
}
}

public function getSubstringExpression(string $string, string $start, ?string $length = null): string
{
if ($length === null) {
Expand Down Expand Up @@ -405,11 +388,9 @@ public function getListViewsSQL(string $database): string
}

/**
* @internal The method should be only used from within the OraclePlatform class hierarchy.
*
* @return array<int, string>
*/
public function getCreateAutoincrementSql(string $name, string $table, int $start = 1): array
protected function getCreateAutoincrementSql(string $name, string $table, int $start = 1): array
{
$tableIdentifier = $this->normalizeIdentifier($table);
$quotedTableName = $tableIdentifier->getQuotedName($this);
Expand Down
16 changes: 4 additions & 12 deletions src/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,12 @@ protected function getCreateColumnCommentSQL(string $tableName, string $columnNa
/**
* Returns the SQL snippet for declaring a default constraint.
*
* @internal The method should be only used from within the SQLServerPlatform class hierarchy.
*
* @param string $table Name of the table to return the default constraint declaration for.
* @param mixed[] $column Column definition.
*
* @throws InvalidArgumentException
*/
public function getDefaultConstraintDeclarationSQL(string $table, array $column): string
protected function getDefaultConstraintDeclarationSQL(string $table, array $column): string
{
if (! isset($column['default'])) {
throw new InvalidArgumentException('Incomplete column definition. "default" required.');
Expand Down Expand Up @@ -678,8 +676,6 @@ protected function getRenameIndexSQL(string $oldIndexName, Index $index, string
/**
* Returns the SQL statement for adding an extended property to a database object.
*
* @internal The method should be only used from within the SQLServerPlatform class hierarchy.
*
* @link http://msdn.microsoft.com/en-us/library/ms180047%28v=sql.90%29.aspx
*
* @param string $name The name of the property to add.
Expand All @@ -691,7 +687,7 @@ protected function getRenameIndexSQL(string $oldIndexName, Index $index, string
* @param string|null $level2Type The type of the object at level 2 the property belongs to.
* @param string|null $level2Name The name of the object at level 2 the property belongs to.
*/
public function getAddExtendedPropertySQL(
protected function getAddExtendedPropertySQL(
string $name,
?string $value = null,
?string $level0Type = null,
Expand All @@ -711,8 +707,6 @@ public function getAddExtendedPropertySQL(
/**
* Returns the SQL statement for dropping an extended property from a database object.
*
* @internal The method should be only used from within the SQLServerPlatform class hierarchy.
*
* @link http://technet.microsoft.com/en-gb/library/ms178595%28v=sql.90%29.aspx
*
* @param string $name The name of the property to drop.
Expand All @@ -723,7 +717,7 @@ public function getAddExtendedPropertySQL(
* @param string|null $level2Type The type of the object at level 2 the property belongs to.
* @param string|null $level2Name The name of the object at level 2 the property belongs to.
*/
public function getDropExtendedPropertySQL(
protected function getDropExtendedPropertySQL(
string $name,
?string $level0Type = null,
?string $level0Name = null,
Expand All @@ -742,8 +736,6 @@ public function getDropExtendedPropertySQL(
/**
* Returns the SQL statement for updating an extended property of a database object.
*
* @internal The method should be only used from within the SQLServerPlatform class hierarchy.
*
* @link http://msdn.microsoft.com/en-us/library/ms186885%28v=sql.90%29.aspx
*
* @param string $name The name of the property to update.
Expand All @@ -755,7 +747,7 @@ public function getDropExtendedPropertySQL(
* @param string|null $level2Type The type of the object at level 2 the property belongs to.
* @param string|null $level2Name The name of the object at level 2 the property belongs to.
*/
public function getUpdateExtendedPropertySQL(
protected function getUpdateExtendedPropertySQL(
string $name,
?string $value = null,
?string $level0Type = null,
Expand Down
32 changes: 0 additions & 32 deletions src/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Driver\API\SQLite\UserDefinedFunctions;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
use Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords;
Expand All @@ -28,7 +27,6 @@
use function array_values;
use function implode;
use function sprintf;
use function sqrt;
use function str_replace;
use function strtolower;
use function trim;
Expand Down Expand Up @@ -462,36 +460,6 @@ public function getTruncateTableSQL(string $tableName, bool $cascade = false): s
return 'DELETE FROM ' . $tableIdentifier->getQuotedName($this);
}

/**
* User-defined function for Sqlite that is used with PDO::sqliteCreateFunction().
*
* @deprecated The driver will use {@link sqrt()} in the next major release.
*
* @param int|float $value
*/
public static function udfSqrt($value): float
{
return sqrt($value);
}

/**
* User-defined function for Sqlite that implements MOD(a, b).
*
* @deprecated The driver will use {@link UserDefinedFunctions::mod()} in the next major release.
*/
public static function udfMod(int $a, int $b): int
{
return UserDefinedFunctions::mod($a, $b);
}

/**
* @deprecated The driver will use {@link UserDefinedFunctions::locate()} in the next major release.
*/
public static function udfLocate(string $str, string $substr, int $offset = 0): int
{
return UserDefinedFunctions::locate($str, $substr, $offset);
}

public function getForUpdateSQL(): string
{
return '';
Expand Down
29 changes: 0 additions & 29 deletions src/Schema/AbstractAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Doctrine\DBAL\Schema;

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

use function array_map;
use function crc32;
Expand Down Expand Up @@ -86,34 +85,6 @@ public function getShortestName(?string $defaultNamespaceName): string
return strtolower($shortestName);
}

/**
* The normalized name is full-qualified and lower-cased. Lower-casing is
* actually wrong, but we have to do it to keep our sanity. If you are
* using database objects that only differentiate in the casing (FOO vs
* Foo) then you will NOT be able to use Doctrine Schema abstraction.
*
* Every non-namespaced element is prefixed with the default namespace
* name which is passed as argument to this method.
*
* @deprecated Use {@link getNamespaceName()} and {@link getName()} instead.
*/
public function getFullQualifiedName(string $defaultNamespaceName): string
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4814',
'AbstractAsset::getFullQualifiedName() is deprecated.'
. ' Use AbstractAsset::getNamespaceName() and ::getName() instead.'
);

$name = $this->getName();
if ($this->_namespace === null) {
$name = $defaultNamespaceName . '.' . $name;
}

return strtolower($name);
}

/**
* Checks if this asset's name is quoted.
*/
Expand Down
Loading