Skip to content

Commit

Permalink
Deprecate Connection::getWrappedConnection(), mark Connection::connec…
Browse files Browse the repository at this point in the history
…t() internal
  • Loading branch information
morozov committed Nov 7, 2021
1 parent c355101 commit 0591041
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 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.2

## Deprecated `Connection::getWrappedConnection()`, `Connection::connect()` made `@internal`.

The wrapper-level `Connection::getWrappedConnection()` method has been deprecated. Use a custom driver implementation
to access the underlying connection.

The `Connection::connect()` method has been marked internal. It will be marked `protected` in DBAL 4.0.

## Deprecated `AbstractSchemaManager::dropAndCreate*()` and `::tryMethod()` methods.

The following `AbstractSchemaManager::dropAndCreate*()` methods have been deprecated:
Expand Down
5 changes: 5 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@
See https://github.com/doctrine/dbal/pull/4897
-->
<referencedMethod name="Doctrine\DBAL\Schema\AbstractSchemaManager::tryMethod"/>
<!--
TODO: remove in 4.0.0
See https://github.com/doctrine/dbal/pull/4966
-->
<referencedMethod name="Doctrine\DBAL\Connection::getWrappedConnection"/>
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
Expand Down
16 changes: 16 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,21 @@ public function getExpressionBuilder()
/**
* Establishes the connection with the database.
*
* @internal This method will be made protected in DBAL 4.0.
*
* @return bool TRUE if the connection was successfully established, FALSE if
* the connection is already open.
*
* @throws Exception
*/
public function connect()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4966',
'Public access to Connection::connect() is deprecated.'
);

if ($this->_conn !== null) {
return false;
}
Expand Down Expand Up @@ -1496,12 +1504,20 @@ public function rollbackSavepoint($savepoint)
/**
* Gets the wrapped driver connection.
*
* @deprecated Use a custom {@link Driver} implementation to access the underlying connection.
*
* @return DriverConnection
*
* @throws Exception
*/
public function getWrappedConnection()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4966',
'Connection::getWrappedConnection() is deprecated. Use a custom driver, if necessary.'
);

$this->connect();

assert($this->_conn !== null);
Expand Down

0 comments on commit 0591041

Please sign in to comment.