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

Do not implement driver-level interfaces by wrapper-level classes #4159

Merged
merged 1 commit into from
Jul 10, 2020
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
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Upgrade to 3.0

## BC BREAK: Changes in the wrapper-level API ancestry

The wrapper-level `Connection` and `Statement` classes no longer implement the corresponding driver-level interfaces.

## BC BREAK: Removed DBALException factory methods

The following factory methods of the DBALException class have been removed:
Expand Down
6 changes: 1 addition & 5 deletions docs/en/reference/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ interfaces are implemented by concrete drivers. For all PDO based
drivers, ``PDO`` and ``PDOStatement`` are the implementations of
these interfaces. Thus, for PDO-based drivers, a
``Doctrine\DBAL\Connection`` wraps a ``PDO`` instance and a
``Doctrine\DBAL\Statement`` wraps a ``PDOStatement`` instance. Even
more, a ``Doctrine\DBAL\Connection`` *is a*
``Doctrine\DBAL\Driver\Connection`` and a
``Doctrine\DBAL\Statement`` *is a*
``Doctrine\DBAL\Driver\Statement``.
``Doctrine\DBAL\Statement`` wraps a ``PDOStatement`` instance.

What does a ``Doctrine\DBAL\Connection`` or a
``Doctrine\DBAL\Statement`` add to the underlying driver
Expand Down
20 changes: 10 additions & 10 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@
use function sprintf;

/**
* A wrapper around a Doctrine\DBAL\Driver\Connection that adds features like
* events, transaction isolation levels, configuration, emulated transaction nesting,
* lazy connecting and more.
* A database abstraction-level connection that implements features like events, transaction isolation levels,
* configuration, emulated transaction nesting, lazy connecting and more.
*/
class Connection implements DriverConnection
class Connection
{
/**
* Represents an array of ints to be expanded by Doctrine SQL parsing.
Expand Down Expand Up @@ -757,7 +756,10 @@ public function quoteIdentifier($str)
}

/**
* {@inheritDoc}
* @param mixed $input
* @param int|string $type
*
* @return mixed
*/
public function quote($input, $type = ParameterType::STRING)
{
Expand Down Expand Up @@ -905,11 +907,9 @@ public function iterateColumn(string $query, array $params = [], array $types =
*
* @param string $sql The SQL statement to prepare.
*
* @return Statement
*
* @throws DBALException
*/
public function prepare(string $sql): DriverStatement
public function prepare(string $sql): Statement
{
return new Statement($sql, $this);
}
Expand Down Expand Up @@ -1215,7 +1215,7 @@ protected function _getNestedTransactionSavePointName()
}

/**
* {@inheritDoc}
* @return bool
*/
public function beginTransaction()
{
Expand Down Expand Up @@ -1250,7 +1250,7 @@ public function beginTransaction()
}

/**
* {@inheritDoc}
* @return bool
*
* @throws ConnectionException If the commit failed due to no active transaction or
* because the transaction was marked for rollback only.
Expand Down
2 changes: 1 addition & 1 deletion src/Connections/PrimaryReadReplicaConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\Exception as DriverException;
use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Statement;
use InvalidArgumentException;

use function array_rand;
Expand Down
3 changes: 0 additions & 3 deletions src/Portability/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ public function __construct(ConnectionInterface $connection, Converter $converte
$this->converter = $converter;
}

/**
* @return Statement
*/
public function prepare(string $sql): DriverStatement
{
return new Statement(
Expand Down
8 changes: 3 additions & 5 deletions src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
namespace Doctrine\DBAL;

use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\Result as DriverResult;
use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;

use function is_string;

/**
* A thin wrapper around a Doctrine\DBAL\Driver\Statement that adds support
* for logging, DBAL mapping types, etc.
* A database abstraction-level statement that implements support for logging, DBAL mapping types, etc.
*/
class Statement implements DriverStatement
class Statement
{
/**
* The SQL statement.
Expand Down Expand Up @@ -148,7 +146,7 @@ public function bindParam($name, &$var, $type = ParameterType::STRING, $length =
*
* @throws DBALException
*/
public function execute($params = null): DriverResult
public function execute($params = null): Result
{
if ($params !== null) {
$this->params = $params;
Expand Down