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

New deprecations for 2.10 #3708

Merged
merged 1 commit into from
Oct 31, 2019
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
37 changes: 37 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# Upgrade to 2.10

## Deprecated `Doctrine\DBAL\Event\ConnectionEventArgs` methods
Ocramius marked this conversation as resolved.
Show resolved Hide resolved

The usage of the `getDriver()`, `getDatabasePlatform()` and `getSchemaManager()` methods of the `ConnectionEventArgs` class has been deprecated. Obtain the underlying connection via `getConnection()` and call the corresponding methods on the connection instance.

## Deprecated `Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs` methods

The usage of the `getDatabasePlatform()` method of the `SchemaColumnDefinitionEventArgs` class has been deprecated. Obtain the underlying connection via `getConnection()` and call the corresponding method on the connection instance.

## Deprecated `Doctrine\DBAL\Connection` methods

The usage of the `getHost()`, `getPort()`, `getUsername()` and `getPassword()` methods of the `Connection` class has been deprecated as they leak implementation details.

## Deprecated array of statements in `addSql()` of `SchemaEventArgs`-based classes.

Passing multiple SQL statements as an array to `SchemaAlterTableAddColumnEventArgs::addSql()` and the same method in other `SchemaEventArgs`-based classes is deprecated. Pass each statement as an individual argument instead.

## Deprecated calling `AbstractSchemaManager::tablesExist()` with a string argument.

Instead of passing a string, pass a one-element array.

## Deprecated calling `OracleSchemaManager::createDatabase()` without an argument or by passing NULL.

In order to create a database, always pass the database name.

## Deprecated unused schema manager methods.

The following methods have been deprecated as unused:

- `AbstractSchemaManager::_getPortableFunctionsList()`,
- `AbstractSchemaManager::_getPortableFunctionDefinition()`,
- `OracleSchemaManager::_getPortableFunctionDefinition()`,
- `SqliteSchemaManager::_getPortableTableIndexDefinition()`.

# Deprecations in `Doctrine\DBAL\Driver`

- The usage of NULL to indicate empty `$username` or `$password` when calling `connect()` is deprecated. Use an empty string instead.

## Deprecated `Doctrine\DBAL\Platforms::_getAlterTableIndexForeignKeySQL()`

Method `Doctrine\DBAL\Platforms::_getAlterTableIndexForeignKeySQL()` has been deprecated as no longer used.
Expand Down
8 changes: 8 additions & 0 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ public function getDatabase()
/**
* Gets the hostname of the currently connected database.
*
* @deprecated
*
* @return string|null
*/
public function getHost()
Expand All @@ -252,6 +254,8 @@ public function getHost()
/**
* Gets the port of the currently connected database.
*
* @deprecated
*
* @return mixed
*/
public function getPort()
Expand All @@ -262,6 +266,8 @@ public function getPort()
/**
* Gets the username used by this connection.
*
* @deprecated
*
* @return string|null
*/
public function getUsername()
Expand All @@ -272,6 +278,8 @@ public function getUsername()
/**
* Gets the password used by this connection.
*
* @deprecated
*
* @return string|null
*/
public function getPassword()
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ interface Driver
/**
* Attempts to create a connection with the database.
*
* The usage of NULL to indicate empty username or password is deprecated. Use an empty string instead.
*
* @param mixed[] $params All connection parameters passed by the user.
* @param string|null $username The username to use when connecting.
* @param string|null $password The password to use when connecting.
Expand Down
6 changes: 6 additions & 0 deletions lib/Doctrine/DBAL/Event/ConnectionEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function getConnection()
}

/**
* @deprecated Use ConnectionEventArgs::getConnection() and Connection::getDriver() instead.
*
* @return Driver
*/
public function getDriver()
Expand All @@ -38,6 +40,8 @@ public function getDriver()
}

/**
* @deprecated Use ConnectionEventArgs::getConnection() and Connection::getDatabasePlatform() instead.
*
* @return AbstractPlatform
*/
public function getDatabasePlatform()
Expand All @@ -46,6 +50,8 @@ public function getDatabasePlatform()
}

/**
* @deprecated Use ConnectionEventArgs::getConnection() and Connection::getSchemaManager() instead.
*
* @return AbstractSchemaManager
*/
public function getSchemaManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff;
use function array_merge;
use function func_get_args;
use function is_array;

/**
Expand Down Expand Up @@ -57,17 +58,15 @@ public function getPlatform()
}

/**
* Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
*
* @param string|string[] $sql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's our policy about documenting variadicity or extra arguments achieved with func_get_args()? Should this be amended to reflect what @Ocramius described in https://github.com/doctrine/dbal/pull/3708/files#r341326501 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think there's a way to document it properly other than declaring it explicitly as parameter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I'm understanding… I'm proposing to use @param string|string[]|...string $sql. Is that understood by SA tools/ IDEs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering my own question: phpstan does not like it. https://phpstan.org/r/52013d4d-e7c9-4c70-8b21-f28255ed96bd

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking this was going to be an issue, but apparently you can't trust the playground for that kind of thing: phpstan/phpstan#1881 (comment)

*
* @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
*/
public function addSql($sql)
{
if (is_array($sql)) {
$this->sql = array_merge($this->sql, $sql);
} else {
$this->sql[] = $sql;
}
$this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
Ocramius marked this conversation as resolved.
Show resolved Hide resolved

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\TableDiff;
use function array_merge;
use function func_get_args;
use function is_array;

/**
Expand Down Expand Up @@ -57,17 +58,15 @@ public function getPlatform()
}

/**
* Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
*
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
*/
public function addSql($sql)
{
if (is_array($sql)) {
$this->sql = array_merge($this->sql, $sql);
} else {
$this->sql[] = $sql;
}
$this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
Ocramius marked this conversation as resolved.
Show resolved Hide resolved

return $this;
}
Expand Down
9 changes: 4 additions & 5 deletions lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\TableDiff;
use function array_merge;
use function func_get_args;
use function is_array;

/**
Expand Down Expand Up @@ -44,17 +45,15 @@ public function getPlatform()
}

/**
* Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
*
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs
*/
public function addSql($sql)
{
if (is_array($sql)) {
$this->sql = array_merge($this->sql, $sql);
} else {
$this->sql[] = $sql;
}
$this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
Ocramius marked this conversation as resolved.
Show resolved Hide resolved

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff;
use function array_merge;
use function func_get_args;
use function is_array;

/**
Expand Down Expand Up @@ -57,17 +58,15 @@ public function getPlatform()
}

/**
* Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
*
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs
*/
public function addSql($sql)
{
if (is_array($sql)) {
$this->sql = array_merge($this->sql, $sql);
} else {
$this->sql[] = $sql;
}
$this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
Ocramius marked this conversation as resolved.
Show resolved Hide resolved

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff;
use function array_merge;
use function func_get_args;
use function is_array;

/**
Expand Down Expand Up @@ -72,17 +73,15 @@ public function getPlatform()
}

/**
* Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
*
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
*/
public function addSql($sql)
{
if (is_array($sql)) {
$this->sql = array_merge($this->sql, $sql);
} else {
$this->sql[] = $sql;
}
$this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
Ocramius marked this conversation as resolved.
Show resolved Hide resolved

return $this;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public function getConnection()
}

/**
* @deprecated Use SchemaColumnDefinitionEventArgs::getConnection() and Connection::getDatabasePlatform() instead.
*
* @return AbstractPlatform
*/
public function getDatabasePlatform()
Expand Down
9 changes: 4 additions & 5 deletions lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Table;
use function array_merge;
use function func_get_args;
use function is_array;

/**
Expand Down Expand Up @@ -57,17 +58,15 @@ public function getPlatform()
}

/**
* Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
*
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs
*/
public function addSql($sql)
{
if (is_array($sql)) {
$this->sql = array_merge($this->sql, $sql);
} else {
$this->sql[] = $sql;
}
$this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
Ocramius marked this conversation as resolved.
Show resolved Hide resolved

return $this;
}
Expand Down
9 changes: 4 additions & 5 deletions lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Table;
use function array_merge;
use function func_get_args;
use function is_array;

/**
Expand Down Expand Up @@ -72,17 +73,15 @@ public function getPlatform()
}

/**
* Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
*
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs
*/
public function addSql($sql)
{
if (is_array($sql)) {
$this->sql = array_merge($this->sql, $sql);
} else {
$this->sql[] = $sql;
}
$this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
Ocramius marked this conversation as resolved.
Show resolved Hide resolved

return $this;
}
Expand Down
6 changes: 6 additions & 0 deletions lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ public function listTableIndexes($table)
/**
* Returns true if all the given tables exist.
*
* The usage of a string $tableNames is deprecated. Pass a one-element array instead.
*
* @param string|string[] $tableNames
*
* @return bool
Expand Down Expand Up @@ -683,6 +685,8 @@ protected function getPortableNamespaceDefinition(array $namespace)
}

/**
* @deprecated
*
* @param mixed[][] $functions
*
* @return mixed[][]
Expand All @@ -704,6 +708,8 @@ protected function _getPortableFunctionsList($functions)
}

/**
* @deprecated
*
* @param mixed[] $function
*
* @return mixed
Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ protected function _getPortableSequenceDefinition($sequence)

/**
* {@inheritdoc}
*
* @deprecated
*/
protected function _getPortableFunctionDefinition($function)
{
Expand All @@ -284,6 +286,8 @@ protected function _getPortableDatabaseDefinition($database)

/**
* {@inheritdoc}
*
* Calling this method without an argument or by passing NULL is deprecated.
*/
public function createDatabase($database = null)
{
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null

/**
* {@inheritdoc}
*
* @deprecated
*/
protected function _getPortableTableIndexDefinition($tableIndex)
{
Expand Down