Skip to content

Commit

Permalink
Merge pull request #4253 from morozov/deprecate-dbal-exception
Browse files Browse the repository at this point in the history
Deprecate DBAL\DBALException in favor of DBAL\Exception
  • Loading branch information
morozov authored Sep 4, 2020
2 parents f69c990 + ad1e482 commit f97ee94
Show file tree
Hide file tree
Showing 55 changed files with 365 additions and 386 deletions.
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ The non-interface methods of driver-level classes have been marked internal:
- `OCI8Connection::getExecuteMode()`
- `OCI8Statement::convertPositionalToNamedPlaceholders()`

## Deprecated `DBALException`

The `Doctrine\DBAL\DBALException` class has been deprecated in favor of `Doctrine\DBAL\Exception`.

## Inconsistently and ambiguously named driver-level classes are deprecated

The following classes under the `Driver` namespace have been deprecated in favor of their consistently named counterparts:
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/DBAL/Abstraction/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Doctrine\DBAL\Abstraction;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Result as DriverResult;
use Doctrine\DBAL\Exception;
use Traversable;

/**
Expand All @@ -19,7 +19,7 @@ interface Result extends DriverResult
*
* @return Traversable<int,array<int,mixed>>
*
* @throws DBALException
* @throws Exception
*/
public function iterateNumeric(): Traversable;

Expand All @@ -28,7 +28,7 @@ public function iterateNumeric(): Traversable;
*
* @return Traversable<int,array<string,mixed>>
*
* @throws DBALException
* @throws Exception
*/
public function iterateAssociative(): Traversable;

Expand All @@ -37,7 +37,7 @@ public function iterateAssociative(): Traversable;
*
* @return Traversable<int,mixed>
*
* @throws DBALException
* @throws Exception
*/
public function iterateColumn(): Traversable;
}
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Cache/CacheException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Doctrine\DBAL\Cache;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception;

/**
* @psalm-immutable
*/
class CacheException extends DBALException
class CacheException extends Exception
{
/**
* @return CacheException
Expand Down
71 changes: 32 additions & 39 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Types\Type;
use Exception;
use Throwable;
use Traversable;

Expand Down Expand Up @@ -175,7 +174,7 @@ class Connection implements DriverConnection
* @param Configuration|null $config The configuration, optional.
* @param EventManager|null $eventManager The event manager, optional.
*
* @throws DBALException
* @throws Exception
*/
public function __construct(
array $params,
Expand All @@ -193,7 +192,7 @@ public function __construct(

if (isset($params['platform'])) {
if (! $params['platform'] instanceof Platforms\AbstractPlatform) {
throw DBALException::invalidPlatformType($params['platform']);
throw Exception::invalidPlatformType($params['platform']);
}

$this->platform = $params['platform'];
Expand Down Expand Up @@ -321,7 +320,7 @@ public function getEventManager()
*
* @return AbstractPlatform
*
* @throws DBALException
* @throws Exception
*/
public function getDatabasePlatform()
{
Expand Down Expand Up @@ -379,7 +378,7 @@ public function connect()
*
* Evaluates custom platform class and version in order to set the correct platform.
*
* @throws DBALException If an invalid platform was specified for this connection.
* @throws Exception If an invalid platform was specified for this connection.
*/
private function detectDatabasePlatform(): void
{
Expand All @@ -406,7 +405,7 @@ private function detectDatabasePlatform(): void
*
* @return string|null
*
* @throws Exception
* @throws Throwable
*/
private function getDatabasePlatformVersion()
{
Expand Down Expand Up @@ -550,7 +549,7 @@ public function setFetchMode($fetchMode)
*
* @return mixed[]|false False is returned if no rows are found.
*
* @throws DBALException
* @throws Exception
*/
public function fetchAssoc($sql, array $params = [], array $types = [])
{
Expand Down Expand Up @@ -587,7 +586,7 @@ public function fetchArray($sql, array $params = [], array $types = [])
*
* @return mixed|false False is returned if no rows are found.
*
* @throws DBALException
* @throws Exception
*/
public function fetchColumn($sql, array $params = [], $column = 0, array $types = [])
{
Expand All @@ -604,7 +603,7 @@ public function fetchColumn($sql, array $params = [], $column = 0, array $types
*
* @return array<string, mixed>|false False is returned if no rows are found.
*
* @throws DBALException
* @throws Exception
*/
public function fetchAssociative(string $query, array $params = [], array $types = [])
{
Expand All @@ -631,7 +630,7 @@ public function fetchAssociative(string $query, array $params = [], array $types
*
* @return array<int, mixed>|false False is returned if no rows are found.
*
* @throws DBALException
* @throws Exception
*/
public function fetchNumeric(string $query, array $params = [], array $types = [])
{
Expand All @@ -658,7 +657,7 @@ public function fetchNumeric(string $query, array $params = [], array $types = [
*
* @return mixed|false False is returned if no rows are found.
*
* @throws DBALException
* @throws Exception
*/
public function fetchOne(string $query, array $params = [], array $types = [])
{
Expand Down Expand Up @@ -703,7 +702,7 @@ public function isTransactionActive()
* @param mixed[] $values Column values
* @param string[] $conditions Key conditions
*
* @throws DBALException
* @throws Exception
*/
private function addIdentifierCondition(
array $identifier,
Expand Down Expand Up @@ -736,8 +735,7 @@ private function addIdentifierCondition(
*
* @return int The number of affected rows.
*
* @throws DBALException
* @throws InvalidArgumentException
* @throws Exception
*/
public function delete($table, array $identifier, array $types = [])
{
Expand Down Expand Up @@ -806,7 +804,7 @@ public function getTransactionIsolation()
*
* @return int The number of affected rows.
*
* @throws DBALException
* @throws Exception
*/
public function update($table, array $data, array $identifier, array $types = [])
{
Expand Down Expand Up @@ -841,7 +839,7 @@ public function update($table, array $data, array $identifier, array $types = []
*
* @return int The number of affected rows.
*
* @throws DBALException
* @throws Exception
*/
public function insert($table, array $data, array $types = [])
{
Expand Down Expand Up @@ -942,7 +940,7 @@ public function fetchAll($sql, array $params = [], $types = [])
*
* @return array<int,array<int,mixed>>
*
* @throws DBALException
* @throws Exception
*/
public function fetchAllNumeric(string $query, array $params = [], array $types = []): array
{
Expand All @@ -968,7 +966,7 @@ public function fetchAllNumeric(string $query, array $params = [], array $types
*
* @return array<int,array<string,mixed>>
*
* @throws DBALException
* @throws Exception
*/
public function fetchAllAssociative(string $query, array $params = [], array $types = []): array
{
Expand All @@ -994,7 +992,7 @@ public function fetchAllAssociative(string $query, array $params = [], array $ty
*
* @return array<int,mixed>
*
* @throws DBALException
* @throws Exception
*/
public function fetchFirstColumn(string $query, array $params = [], array $types = []): array
{
Expand All @@ -1020,7 +1018,7 @@ public function fetchFirstColumn(string $query, array $params = [], array $types
*
* @return Traversable<int,array<int,mixed>>
*
* @throws DBALException
* @throws Exception
*/
public function iterateNumeric(string $query, array $params = [], array $types = []): Traversable
{
Expand Down Expand Up @@ -1049,7 +1047,7 @@ public function iterateNumeric(string $query, array $params = [], array $types =
*
* @return Traversable<int,array<string,mixed>>
*
* @throws DBALException
* @throws Exception
*/
public function iterateAssociative(string $query, array $params = [], array $types = []): Traversable
{
Expand Down Expand Up @@ -1077,7 +1075,7 @@ public function iterateAssociative(string $query, array $params = [], array $typ
*
* @return Traversable<int,mixed>
*
* @throws DBALException
* @throws Exception
*/
public function iterateColumn(string $query, array $params = [], array $types = []): Traversable
{
Expand All @@ -1103,7 +1101,7 @@ public function iterateColumn(string $query, array $params = [], array $types =
*
* @return Statement The prepared statement.
*
* @throws DBALException
* @throws Exception
*/
public function prepare($sql)
{
Expand Down Expand Up @@ -1131,7 +1129,7 @@ public function prepare($sql)
*
* @return ResultStatement The executed statement.
*
* @throws DBALException
* @throws Exception
*/
public function executeQuery($sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null)
{
Expand Down Expand Up @@ -1265,7 +1263,7 @@ public function project($sql, array $params, Closure $function)
*
* @return \Doctrine\DBAL\Driver\Statement
*
* @throws DBALException
* @throws Exception
*/
public function query()
{
Expand Down Expand Up @@ -1307,7 +1305,7 @@ public function query()
*
* @return int The number of affected rows.
*
* @throws DBALException
* @throws Exception
*/
public function executeUpdate($sql, array $params = [], array $types = [])
{
Expand All @@ -1332,7 +1330,7 @@ public function executeUpdate($sql, array $params = [], array $types = [])
*
* @return int The number of affected rows.
*
* @throws DBALException
* @throws Exception
*/
public function executeStatement($sql, array $params = [], array $types = [])
{
Expand Down Expand Up @@ -1385,7 +1383,7 @@ public function executeStatement($sql, array $params = [], array $types = [])
*
* @return int The number of affected rows.
*
* @throws DBALException
* @throws Exception
*/
public function exec($sql)
{
Expand Down Expand Up @@ -1470,7 +1468,6 @@ public function lastInsertId($name = null)
*
* @return mixed The value returned by $func
*
* @throws Exception
* @throws Throwable
*/
public function transactional(Closure $func)
Expand All @@ -1481,10 +1478,6 @@ public function transactional(Closure $func)
$this->commit();

return $res;
} catch (Exception $e) {
$this->rollBack();

throw $e;
} catch (Throwable $e) {
$this->rollBack();

Expand Down Expand Up @@ -2014,14 +2007,14 @@ public function ping()
* @param array<int, mixed>|array<string, mixed> $params
* @param array<int, int|string>|array<string, int|string> $types
*
* @throws DBALException
* @throws Exception
*
* @psalm-return never-return
*/
public function handleExceptionDuringQuery(Throwable $e, string $sql, array $params = [], array $types = []): void
{
$this->throw(
DBALException::driverExceptionDuringQuery(
Exception::driverExceptionDuringQuery(
$this->_driver,
$e,
$sql,
Expand All @@ -2033,14 +2026,14 @@ public function handleExceptionDuringQuery(Throwable $e, string $sql, array $par
/**
* @internal
*
* @throws DBALException
* @throws Exception
*
* @psalm-return never-return
*/
public function handleDriverException(Throwable $e): void
{
$this->throw(
DBALException::driverException(
Exception::driverException(
$this->_driver,
$e
)
Expand All @@ -2050,11 +2043,11 @@ public function handleDriverException(Throwable $e): void
/**
* @internal
*
* @throws DBALException
* @throws Exception
*
* @psalm-return never-return
*/
private function throw(DBALException $e): void
private function throw(Exception $e): void
{
if ($e instanceof ConnectionLost) {
$this->close();
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/ConnectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @psalm-immutable
*/
class ConnectionException extends DBALException
class ConnectionException extends Exception
{
/**
* @return ConnectionException
Expand Down
Loading

0 comments on commit f97ee94

Please sign in to comment.