Skip to content

Commit

Permalink
Deprecate DBAL\DBALException in favor of DBAL\Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Sep 4, 2020
1 parent c115e9f commit ad1e482
Show file tree
Hide file tree
Showing 54 changed files with 363 additions and 352 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
63 changes: 31 additions & 32 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,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 @@ -192,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 @@ -320,7 +320,7 @@ public function getEventManager()
*
* @return AbstractPlatform
*
* @throws DBALException
* @throws Exception
*/
public function getDatabasePlatform()
{
Expand Down Expand Up @@ -378,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 Down Expand Up @@ -549,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 @@ -586,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 @@ -603,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 @@ -630,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 @@ -657,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 @@ -702,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 @@ -735,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 @@ -805,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 @@ -840,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 @@ -941,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 @@ -967,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 @@ -993,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 @@ -1019,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 @@ -1048,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 @@ -1076,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 @@ -1102,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 @@ -1130,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 @@ -1264,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 @@ -1306,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 @@ -1331,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 @@ -1384,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 @@ -2008,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 @@ -2027,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 @@ -2044,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 ad1e482

Please sign in to comment.