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 27, 2021
1 parent bf37340 commit 7daa10f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ The following methods have been deprecated:

Call `getNativeConnection()` to access the underlying PDO or MySQLi connection.

## 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.

# Upgrade to 3.2

## Deprecated `SQLLogger` and its implementations.
Expand Down
5 changes: 5 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@

<!-- TODO: remove in 4.0.0 -->
<referencedMethod name="Doctrine\DBAL\Driver\PDO\Connection::getWrappedConnection"/>
<!--
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
17 changes: 17 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,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 @@ -1501,12 +1509,21 @@ public function rollbackSavepoint($savepoint)
/**
* Gets the wrapped driver connection.
*
* @deprecated Use {@link getNativeConnection()} to access the native connection.
*
* @return DriverConnection
*
* @throws Exception
*/
public function getWrappedConnection()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4966',
'Connection::getWrappedConnection() is deprecated.'
. ' Use Connection::getNativeConnection() to access the native connection.'
);

$this->connect();

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

0 comments on commit 7daa10f

Please sign in to comment.