Skip to content

Commit

Permalink
Do not implement driver-level interfaces by wrapper-level classes
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Jul 10, 2020
1 parent 0f6b728 commit 6bcc08b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
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
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

0 comments on commit 6bcc08b

Please sign in to comment.