Remove deprecated exception classes

parent 6de4aeae
# Upgrade to 3.0 # Upgrade to 3.0
## BC BREAK: Deprecated driver-level classes and interfaces are removed.
- `AbstractDriverException`
- `DriverException`
- `PDOException`
- `IBMDB2\DB2Exception`
- `Mysqli\MysqliException`
- `OCI8\OCI8Exception`
- `SQLSrv\SQLSrvException`
## BC BREAK: `ServerInfoAwareConnection::requiresQueryForServerVersion()` is removed. ## BC BREAK: `ServerInfoAwareConnection::requiresQueryForServerVersion()` is removed.
The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been removed as an implementation detail which is the same for all supported drivers. The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been removed as an implementation detail which is the same for all supported drivers.
......
...@@ -10,7 +10,7 @@ use Doctrine\DBAL\Cache\CacheException; ...@@ -10,7 +10,7 @@ use Doctrine\DBAL\Cache\CacheException;
use Doctrine\DBAL\Cache\CachingResult; use Doctrine\DBAL\Cache\CachingResult;
use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\Exception as DriverException;
use Doctrine\DBAL\Driver\PingableConnection; use Doctrine\DBAL\Driver\PingableConnection;
use Doctrine\DBAL\Driver\Result as DriverResult; use Doctrine\DBAL\Driver\Result as DriverResult;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
......
...@@ -8,7 +8,7 @@ use Doctrine\DBAL\Connection; ...@@ -8,7 +8,7 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\Exception as DriverException;
use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Event\ConnectionEventArgs;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Doctrine\DBAL; namespace Doctrine\DBAL;
use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; use Doctrine\DBAL\Driver\Exception as TheDriverException;
use Doctrine\DBAL\Driver\ExceptionConverterDriver; use Doctrine\DBAL\Driver\ExceptionConverterDriver;
use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
...@@ -169,7 +169,7 @@ class DBALException extends Exception ...@@ -169,7 +169,7 @@ class DBALException extends Exception
return $driverEx; return $driverEx;
} }
if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof DeprecatedDriverException) { if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof TheDriverException) {
return $driver->convertException($msg, $driverEx); return $driver->convertException($msg, $driverEx);
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Doctrine\DBAL; namespace Doctrine\DBAL;
use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\AbstractSchemaManager;
...@@ -20,7 +20,7 @@ interface Driver ...@@ -20,7 +20,7 @@ interface Driver
* *
* @return DriverConnection The database connection. * @return DriverConnection The database connection.
* *
* @throws DriverException * @throws Exception
*/ */
public function connect(array $params); public function connect(array $params);
......
...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Driver; ...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\DriverException as TheDriverException; use Doctrine\DBAL\Driver\Exception as TheDriverException;
use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Platforms\DB2Platform; use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\DB2SchemaManager; use Doctrine\DBAL\Schema\DB2SchemaManager;
......
<?php
namespace Doctrine\DBAL\Driver;
/**
* @deprecated
*
* @psalm-immutable
*/
abstract class AbstractDriverException extends AbstractException
{
}
...@@ -14,7 +14,7 @@ use Throwable; ...@@ -14,7 +14,7 @@ use Throwable;
* *
* @psalm-immutable * @psalm-immutable
*/ */
abstract class AbstractException extends BaseException implements DriverException abstract class AbstractException extends BaseException implements Exception
{ {
/** /**
* The SQLSTATE of the driver. * The SQLSTATE of the driver.
......
...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Driver; ...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; use Doctrine\DBAL\Driver\Exception as TheDriverException;
use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\ConnectionLost; use Doctrine\DBAL\Exception\ConnectionLost;
use Doctrine\DBAL\Exception\DeadlockException; use Doctrine\DBAL\Exception\DeadlockException;
...@@ -40,7 +40,7 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA ...@@ -40,7 +40,7 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
* @link https://dev.mysql.com/doc/refman/8.0/en/client-error-reference.html * @link https://dev.mysql.com/doc/refman/8.0/en/client-error-reference.html
* @link https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html * @link https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html
*/ */
public function convertException($message, DeprecatedDriverException $exception) public function convertException($message, TheDriverException $exception)
{ {
switch ($exception->getCode()) { switch ($exception->getCode()) {
case 1213: case 1213:
......
...@@ -5,7 +5,7 @@ namespace Doctrine\DBAL\Driver; ...@@ -5,7 +5,7 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString; use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; use Doctrine\DBAL\Driver\Exception as TheDriverException;
use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
...@@ -27,7 +27,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver ...@@ -27,7 +27,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function convertException($message, DeprecatedDriverException $exception) public function convertException($message, TheDriverException $exception)
{ {
switch ($exception->getCode()) { switch ($exception->getCode()) {
case 1: case 1:
......
...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Driver; ...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; use Doctrine\DBAL\Driver\Exception as TheDriverException;
use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\DeadlockException; use Doctrine\DBAL\Exception\DeadlockException;
use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\DriverException;
...@@ -35,7 +35,7 @@ abstract class AbstractPostgreSQLDriver implements ExceptionConverterDriver, Ver ...@@ -35,7 +35,7 @@ abstract class AbstractPostgreSQLDriver implements ExceptionConverterDriver, Ver
* *
* @link http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html * @link http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
*/ */
public function convertException($message, DeprecatedDriverException $exception) public function convertException($message, TheDriverException $exception)
{ {
switch ($exception->getSQLState()) { switch ($exception->getSQLState()) {
case '40001': case '40001':
......
...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Driver; ...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\DriverException as TheDriverException; use Doctrine\DBAL\Driver\Exception as TheDriverException;
use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Platforms\SQLServer2012Platform; use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Schema\SQLServerSchemaManager; use Doctrine\DBAL\Schema\SQLServerSchemaManager;
......
...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Driver; ...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; use Doctrine\DBAL\Driver\Exception as TheDriverException;
use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
...@@ -32,7 +32,7 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver ...@@ -32,7 +32,7 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
* *
* @link http://www.sqlite.org/c3ref/c_abort.html * @link http://www.sqlite.org/c3ref/c_abort.html
*/ */
public function convertException($message, DeprecatedDriverException $exception) public function convertException($message, TheDriverException $exception)
{ {
if (strpos($exception->getMessage(), 'database is locked') !== false) { if (strpos($exception->getMessage(), 'database is locked') !== false) {
return new LockWaitTimeoutException($message, $exception); return new LockWaitTimeoutException($message, $exception);
......
<?php
namespace Doctrine\DBAL\Driver;
/**
* @deprecated Use {@link Exception} instead
*
* @psalm-immutable
*/
interface DriverException extends Exception
{
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\DriverException as TheDriverException; use Doctrine\DBAL\Driver\Exception as TheDriverException;
use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\DriverException;
/** /**
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Doctrine\DBAL\Driver\IBMDB2; namespace Doctrine\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionError; use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionError;
use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionFailed; use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionFailed;
use Doctrine\DBAL\Driver\IBMDB2\Exception\PrepareFailed; use Doctrine\DBAL\Driver\IBMDB2\Exception\PrepareFailed;
...@@ -40,7 +41,7 @@ class DB2Connection implements ServerInfoAwareConnection ...@@ -40,7 +41,7 @@ class DB2Connection implements ServerInfoAwareConnection
/** /**
* @param array<string,mixed> $driverOptions * @param array<string,mixed> $driverOptions
* *
* @throws DB2Exception * @throws Exception
*/ */
public function __construct( public function __construct(
string $database, string $database,
......
<?php
namespace Doctrine\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Driver\AbstractDriverException;
/**
* @deprecated Use {@link Exception} instead
*
* @psalm-immutable
*/
class DB2Exception extends AbstractDriverException
{
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Doctrine\DBAL\Driver\IBMDB2; namespace Doctrine\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCopyStreamToStream; use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCopyStreamToStream;
use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCreateTemporaryFile; use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCreateTemporaryFile;
use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotWriteToTemporaryFile; use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotWriteToTemporaryFile;
...@@ -106,7 +107,7 @@ class DB2Statement implements StatementInterface ...@@ -106,7 +107,7 @@ class DB2Statement implements StatementInterface
* @param int $position Parameter position * @param int $position Parameter position
* @param mixed $variable * @param mixed $variable
* *
* @throws DB2Exception * @throws Exception
*/ */
private function bind($position, &$variable, int $parameterType, int $dataType): void private function bind($position, &$variable, int $parameterType, int $dataType): void
{ {
...@@ -160,7 +161,7 @@ class DB2Statement implements StatementInterface ...@@ -160,7 +161,7 @@ class DB2Statement implements StatementInterface
/** /**
* @return resource * @return resource
* *
* @throws DB2Exception * @throws Exception
*/ */
private function createTemporaryFile() private function createTemporaryFile()
{ {
...@@ -177,7 +178,7 @@ class DB2Statement implements StatementInterface ...@@ -177,7 +178,7 @@ class DB2Statement implements StatementInterface
* @param resource $source * @param resource $source
* @param resource $target * @param resource $target
* *
* @throws DB2Exception * @throws Exception
*/ */
private function copyStreamToStream($source, $target): void private function copyStreamToStream($source, $target): void
{ {
...@@ -189,7 +190,7 @@ class DB2Statement implements StatementInterface ...@@ -189,7 +190,7 @@ class DB2Statement implements StatementInterface
/** /**
* @param resource $target * @param resource $target
* *
* @throws DB2Exception * @throws Exception
*/ */
private function writeStringToStream(string $string, $target): void private function writeStringToStream(string $string, $target): void
{ {
......
...@@ -4,14 +4,14 @@ declare(strict_types=1); ...@@ -4,14 +4,14 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\IBMDB2\Exception; namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
use Doctrine\DBAL\Driver\IBMDB2\DB2Exception; use Doctrine\DBAL\Driver\AbstractException;
/** /**
* @internal * @internal
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class CannotCopyStreamToStream extends DB2Exception final class CannotCopyStreamToStream extends AbstractException
{ {
public static function new(string $message): self public static function new(string $message): self
{ {
......
...@@ -4,14 +4,14 @@ declare(strict_types=1); ...@@ -4,14 +4,14 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\IBMDB2\Exception; namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
use Doctrine\DBAL\Driver\IBMDB2\DB2Exception; use Doctrine\DBAL\Driver\AbstractException;
/** /**
* @internal * @internal
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class CannotCreateTemporaryFile extends DB2Exception final class CannotCreateTemporaryFile extends AbstractException
{ {
public static function new(string $message): self public static function new(string $message): self
{ {
......
...@@ -4,14 +4,14 @@ declare(strict_types=1); ...@@ -4,14 +4,14 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\IBMDB2\Exception; namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
use Doctrine\DBAL\Driver\IBMDB2\DB2Exception; use Doctrine\DBAL\Driver\AbstractException;
/** /**
* @internal * @internal
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class CannotWriteToTemporaryFile extends DB2Exception final class CannotWriteToTemporaryFile extends AbstractException
{ {
public static function new(string $message): self public static function new(string $message): self
{ {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Driver\Mysqli; namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\AbstractMySQLDriver; use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Driver\Mysqli\Exception\HostRequired;
use Doctrine\DBAL\Driver\Mysqli\Initializer\Charset; use Doctrine\DBAL\Driver\Mysqli\Initializer\Charset;
use Doctrine\DBAL\Driver\Mysqli\Initializer\Options; use Doctrine\DBAL\Driver\Mysqli\Initializer\Options;
use Doctrine\DBAL\Driver\Mysqli\Initializer\Secure; use Doctrine\DBAL\Driver\Mysqli\Initializer\Secure;
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli\Exception; namespace Doctrine\DBAL\Driver\Mysqli\Exception;
use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\DBAL\Driver\AbstractException;
use mysqli; use mysqli;
/** /**
...@@ -12,7 +12,7 @@ use mysqli; ...@@ -12,7 +12,7 @@ use mysqli;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class ConnectionError extends MysqliException final class ConnectionError extends AbstractException
{ {
public static function new(mysqli $connection): self public static function new(mysqli $connection): self
{ {
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli\Exception; namespace Doctrine\DBAL\Driver\Mysqli\Exception;
use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\DBAL\Driver\AbstractException;
use mysqli; use mysqli;
/** /**
...@@ -12,7 +12,7 @@ use mysqli; ...@@ -12,7 +12,7 @@ use mysqli;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class ConnectionFailed extends MysqliException final class ConnectionFailed extends AbstractException
{ {
public static function new(mysqli $connection): self public static function new(mysqli $connection): self
{ {
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli\Exception; namespace Doctrine\DBAL\Driver\Mysqli\Exception;
use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\DBAL\Driver\AbstractException;
use function sprintf; use function sprintf;
...@@ -13,7 +13,7 @@ use function sprintf; ...@@ -13,7 +13,7 @@ use function sprintf;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class FailedReadingStreamOffset extends MysqliException final class FailedReadingStreamOffset extends AbstractException
{ {
public static function new(int $offset): self public static function new(int $offset): self
{ {
......
...@@ -2,14 +2,16 @@ ...@@ -2,14 +2,16 @@
declare(strict_types=1); declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli; namespace Doctrine\DBAL\Driver\Mysqli\Exception;
use Doctrine\DBAL\Driver\AbstractException;
/** /**
* @internal * @internal
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class HostRequired extends MysqliException final class HostRequired extends AbstractException
{ {
public static function forPersistentConnection(): self public static function forPersistentConnection(): self
{ {
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli\Exception; namespace Doctrine\DBAL\Driver\Mysqli\Exception;
use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\DBAL\Driver\AbstractException;
use mysqli; use mysqli;
use function sprintf; use function sprintf;
...@@ -14,7 +14,7 @@ use function sprintf; ...@@ -14,7 +14,7 @@ use function sprintf;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class InvalidCharset extends MysqliException final class InvalidCharset extends AbstractException
{ {
public static function fromCharset(mysqli $connection, string $charset): self public static function fromCharset(mysqli $connection, string $charset): self
{ {
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli\Exception; namespace Doctrine\DBAL\Driver\Mysqli\Exception;
use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\DBAL\Driver\AbstractException;
use function sprintf; use function sprintf;
...@@ -13,7 +13,7 @@ use function sprintf; ...@@ -13,7 +13,7 @@ use function sprintf;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class InvalidOption extends MysqliException final class InvalidOption extends AbstractException
{ {
/** /**
* @param mixed $value * @param mixed $value
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli\Exception; namespace Doctrine\DBAL\Driver\Mysqli\Exception;
use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\DBAL\Driver\AbstractException;
use mysqli_stmt; use mysqli_stmt;
/** /**
...@@ -12,7 +12,7 @@ use mysqli_stmt; ...@@ -12,7 +12,7 @@ use mysqli_stmt;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class StatementError extends MysqliException final class StatementError extends AbstractException
{ {
public static function new(mysqli_stmt $statement): self public static function new(mysqli_stmt $statement): self
{ {
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli\Exception; namespace Doctrine\DBAL\Driver\Mysqli\Exception;
use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\DBAL\Driver\AbstractException;
use function sprintf; use function sprintf;
...@@ -13,7 +13,7 @@ use function sprintf; ...@@ -13,7 +13,7 @@ use function sprintf;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class UnknownType extends MysqliException final class UnknownType extends AbstractException
{ {
/** /**
* @param mixed $type * @param mixed $type
......
...@@ -4,12 +4,13 @@ declare(strict_types=1); ...@@ -4,12 +4,13 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli; namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\Exception;
use mysqli; use mysqli;
interface Initializer interface Initializer
{ {
/** /**
* @throws MysqliException * @throws Exception
*/ */
public function initialize(mysqli $connection): void; public function initialize(mysqli $connection): void;
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Doctrine\DBAL\Driver\Mysqli; namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError; use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError;
use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionFailed; use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionFailed;
use Doctrine\DBAL\Driver\PingableConnection; use Doctrine\DBAL\Driver\PingableConnection;
...@@ -32,7 +33,7 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection ...@@ -32,7 +33,7 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
* @param iterable<Initializer> $preInitializers * @param iterable<Initializer> $preInitializers
* @param iterable<Initializer> $postInitializers * @param iterable<Initializer> $postInitializers
* *
* @throws MysqliException * @throws Exception
*/ */
public function __construct( public function __construct(
?string $host = null, ?string $host = null,
......
<?php
namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\AbstractDriverException;
/**
* @deprecated Use {@link Exception} instead
*
* @psalm-immutable
*/
class MysqliException extends AbstractDriverException
{
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Doctrine\DBAL\Driver\Mysqli; namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError; use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError;
use Doctrine\DBAL\Driver\Mysqli\Exception\FailedReadingStreamOffset; use Doctrine\DBAL\Driver\Mysqli\Exception\FailedReadingStreamOffset;
use Doctrine\DBAL\Driver\Mysqli\Exception\StatementError; use Doctrine\DBAL\Driver\Mysqli\Exception\StatementError;
...@@ -62,7 +63,7 @@ class MysqliStatement implements StatementInterface ...@@ -62,7 +63,7 @@ class MysqliStatement implements StatementInterface
* *
* @param string $prepareString * @param string $prepareString
* *
* @throws MysqliException * @throws Exception
*/ */
public function __construct(mysqli $conn, $prepareString) public function __construct(mysqli $conn, $prepareString)
{ {
...@@ -186,7 +187,7 @@ class MysqliStatement implements StatementInterface ...@@ -186,7 +187,7 @@ class MysqliStatement implements StatementInterface
* *
* @param array<int, resource> $streams * @param array<int, resource> $streams
* *
* @throws MysqliException * @throws Exception
*/ */
private function sendLongData(array $streams): void private function sendLongData(array $streams): void
{ {
......
...@@ -4,6 +4,7 @@ declare(strict_types=1); ...@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\Mysqli; namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\FetchUtils;
use Doctrine\DBAL\Driver\Mysqli\Exception\StatementError; use Doctrine\DBAL\Driver\Mysqli\Exception\StatementError;
use Doctrine\DBAL\Driver\Result as ResultInterface; use Doctrine\DBAL\Driver\Result as ResultInterface;
...@@ -42,7 +43,7 @@ final class Result implements ResultInterface ...@@ -42,7 +43,7 @@ final class Result implements ResultInterface
private $boundValues = []; private $boundValues = [];
/** /**
* @throws MysqliException * @throws Exception
*/ */
public function __construct(mysqli_stmt $statement) public function __construct(mysqli_stmt $statement)
{ {
......
...@@ -4,6 +4,7 @@ declare(strict_types=1); ...@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\OCI8; namespace Doctrine\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\OCI8\Exception\NonTerminatedStringLiteral; use Doctrine\DBAL\Driver\OCI8\Exception\NonTerminatedStringLiteral;
use function count; use function count;
...@@ -31,7 +32,7 @@ final class ConvertPositionalToNamedPlaceholders ...@@ -31,7 +32,7 @@ final class ConvertPositionalToNamedPlaceholders
* *
* @return mixed[] [0] => the statement value (string), [1] => the paramMap value (array). * @return mixed[] [0] => the statement value (string), [1] => the paramMap value (array).
* *
* @throws OCI8Exception * @throws Exception
*/ */
public function __invoke(string $statement): array public function __invoke(string $statement): array
{ {
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\OCI8\Exception; namespace Doctrine\DBAL\Driver\OCI8\Exception;
use Doctrine\DBAL\Driver\OCI8\OCI8Exception; use Doctrine\DBAL\Driver\AbstractException;
use function assert; use function assert;
use function oci_error; use function oci_error;
...@@ -14,7 +14,7 @@ use function oci_error; ...@@ -14,7 +14,7 @@ use function oci_error;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class ConnectionFailed extends OCI8Exception final class ConnectionFailed extends AbstractException
{ {
public static function new(): self public static function new(): self
{ {
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\OCI8\Exception; namespace Doctrine\DBAL\Driver\OCI8\Exception;
use Doctrine\DBAL\Driver\OCI8\OCI8Exception; use Doctrine\DBAL\Driver\AbstractException;
use function assert; use function assert;
use function oci_error; use function oci_error;
...@@ -14,7 +14,7 @@ use function oci_error; ...@@ -14,7 +14,7 @@ use function oci_error;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class Error extends OCI8Exception final class Error extends AbstractException
{ {
/** /**
* @param resource $resource * @param resource $resource
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\OCI8\Exception; namespace Doctrine\DBAL\Driver\OCI8\Exception;
use Doctrine\DBAL\Driver\OCI8\OCI8Exception; use Doctrine\DBAL\Driver\AbstractException;
use function sprintf; use function sprintf;
...@@ -13,7 +13,7 @@ use function sprintf; ...@@ -13,7 +13,7 @@ use function sprintf;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class NonTerminatedStringLiteral extends OCI8Exception final class NonTerminatedStringLiteral extends AbstractException
{ {
public static function new(int $offset): self public static function new(int $offset): self
{ {
......
...@@ -4,14 +4,14 @@ declare(strict_types=1); ...@@ -4,14 +4,14 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\OCI8\Exception; namespace Doctrine\DBAL\Driver\OCI8\Exception;
use Doctrine\DBAL\Driver\OCI8\OCI8Exception; use Doctrine\DBAL\Driver\AbstractException;
/** /**
* @internal * @internal
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class SequenceDoesNotExist extends OCI8Exception final class SequenceDoesNotExist extends AbstractException
{ {
public static function new(): self public static function new(): self
{ {
......
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\OCI8\Exception; namespace Doctrine\DBAL\Driver\OCI8\Exception;
use Doctrine\DBAL\Driver\OCI8\OCI8Exception; use Doctrine\DBAL\Driver\AbstractException;
use function sprintf; use function sprintf;
...@@ -13,7 +13,7 @@ use function sprintf; ...@@ -13,7 +13,7 @@ use function sprintf;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class UnknownParameterIndex extends OCI8Exception final class UnknownParameterIndex extends AbstractException
{ {
public static function new(int $index): self public static function new(int $index): self
{ {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Driver\OCI8; namespace Doctrine\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\Connection as ConnectionInterface; use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\OCI8\Exception\ConnectionFailed; use Doctrine\DBAL\Driver\OCI8\Exception\ConnectionFailed;
use Doctrine\DBAL\Driver\OCI8\Exception\Error; use Doctrine\DBAL\Driver\OCI8\Exception\Error;
use Doctrine\DBAL\Driver\OCI8\Exception\SequenceDoesNotExist; use Doctrine\DBAL\Driver\OCI8\Exception\SequenceDoesNotExist;
...@@ -49,7 +50,7 @@ class OCI8Connection implements ConnectionInterface, ServerInfoAwareConnection ...@@ -49,7 +50,7 @@ class OCI8Connection implements ConnectionInterface, ServerInfoAwareConnection
* @param int $sessionMode * @param int $sessionMode
* @param bool $persistent * @param bool $persistent
* *
* @throws OCI8Exception * @throws Exception
*/ */
public function __construct( public function __construct(
$username, $username,
......
<?php
namespace Doctrine\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\AbstractDriverException;
/**
* @deprecated Use {@link Exception} instead
*
* @psalm-immutable
*/
class OCI8Exception extends AbstractDriverException
{
}
...@@ -4,17 +4,25 @@ declare(strict_types=1); ...@@ -4,17 +4,25 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\PDO; namespace Doctrine\DBAL\Driver\PDO;
use Doctrine\DBAL\Driver\PDOException; use Doctrine\DBAL\Driver\AbstractException;
use PDOException;
/** /**
* @internal * @internal
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class Exception extends PDOException final class Exception extends AbstractException
{ {
public static function new(\PDOException $exception): self public static function new(PDOException $exception): self
{ {
return new self($exception); if ($exception->errorInfo !== null) {
[$sqlState, $code] = $exception->errorInfo;
} else {
$code = $exception->getCode();
$sqlState = null;
}
return new self($exception->getMessage(), $sqlState, $code, $exception);
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Doctrine\DBAL\Driver; namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Exception as ExceptionInterface;
use Doctrine\DBAL\Driver\PDO\Exception; use Doctrine\DBAL\Driver\PDO\Exception;
use Doctrine\DBAL\Driver\PDO\Result; use Doctrine\DBAL\Driver\PDO\Result;
use Doctrine\DBAL\Driver\PDO\Statement; use Doctrine\DBAL\Driver\PDO\Statement;
...@@ -32,7 +33,7 @@ class PDOConnection implements ServerInfoAwareConnection ...@@ -32,7 +33,7 @@ class PDOConnection implements ServerInfoAwareConnection
* @param string|null $password * @param string|null $password
* @param mixed[]|null $options * @param mixed[]|null $options
* *
* @throws PDOException In case of an error. * @throws ExceptionInterface
*/ */
public function __construct($dsn, $user = null, $password = null, ?array $options = null) public function __construct($dsn, $user = null, $password = null, ?array $options = null)
{ {
......
<?php
namespace Doctrine\DBAL\Driver;
/**
* @deprecated Use {@link Exception} instead
*
* @psalm-immutable
*/
class PDOException extends AbstractDriverException
{
/**
* @param \PDOException $exception The PDO exception to wrap.
*/
public function __construct(\PDOException $exception)
{
if ($exception->errorInfo !== null) {
[$sqlState, $code] = $exception->errorInfo;
} else {
$code = $exception->getCode();
$sqlState = null;
}
parent::__construct($exception->getMessage(), $sqlState, $code, $exception);
}
}
...@@ -4,7 +4,7 @@ declare(strict_types=1); ...@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL\Driver\SQLSrv\Exception; namespace Doctrine\DBAL\Driver\SQLSrv\Exception;
use Doctrine\DBAL\Driver\SQLSrv\SQLSrvException; use Doctrine\DBAL\Driver\AbstractException;
use function rtrim; use function rtrim;
use function sqlsrv_errors; use function sqlsrv_errors;
...@@ -16,7 +16,7 @@ use const SQLSRV_ERR_ERRORS; ...@@ -16,7 +16,7 @@ use const SQLSRV_ERR_ERRORS;
* *
* @psalm-immutable * @psalm-immutable
*/ */
final class Error extends SQLSrvException final class Error extends AbstractException
{ {
public static function new(): self public static function new(): self
{ {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Doctrine\DBAL\Driver\SQLSrv; namespace Doctrine\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\Result as ResultInterface; use Doctrine\DBAL\Driver\Result as ResultInterface;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\SQLSrv\Exception\Error; use Doctrine\DBAL\Driver\SQLSrv\Exception\Error;
...@@ -38,7 +39,7 @@ class SQLSrvConnection implements ServerInfoAwareConnection ...@@ -38,7 +39,7 @@ class SQLSrvConnection implements ServerInfoAwareConnection
* @param string $serverName * @param string $serverName
* @param mixed[] $connectionOptions * @param mixed[] $connectionOptions
* *
* @throws SQLSrvException * @throws Exception
*/ */
public function __construct($serverName, $connectionOptions) public function __construct($serverName, $connectionOptions)
{ {
......
<?php
namespace Doctrine\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver\AbstractDriverException;
use Doctrine\DBAL\Driver\SQLSrv\Exception\Error;
/**
* @deprecated Use {@link Exception} instead
*
* @psalm-immutable
*/
class SQLSrvException extends AbstractDriverException
{
/**
* Helper method to turn sql server errors into exception.
*
* @return SQLSrvException
*/
public static function fromSqlSrvErrors()
{
return Error::new();
}
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Doctrine\DBAL\Driver\SQLSrv; namespace Doctrine\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\Result as ResultInterface; use Doctrine\DBAL\Driver\Result as ResultInterface;
use Doctrine\DBAL\Driver\SQLSrv\Exception\Error; use Doctrine\DBAL\Driver\SQLSrv\Exception\Error;
use Doctrine\DBAL\Driver\Statement as StatementInterface; use Doctrine\DBAL\Driver\Statement as StatementInterface;
...@@ -161,7 +162,7 @@ class SQLSrvStatement implements StatementInterface ...@@ -161,7 +162,7 @@ class SQLSrvStatement implements StatementInterface
* *
* @return resource * @return resource
* *
* @throws SQLSrvException * @throws Exception
*/ */
private function prepare() private function prepare()
{ {
......
...@@ -66,7 +66,7 @@ interface Statement ...@@ -66,7 +66,7 @@ interface Statement
* @param mixed[]|null $params A numeric array of values with as many elements as there are * @param mixed[]|null $params A numeric array of values with as many elements as there are
* bound parameters in the SQL statement being executed. * bound parameters in the SQL statement being executed.
* *
* @throws DriverException * @throws Exception
*/ */
public function execute($params = null): Result; public function execute($params = null): Result;
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Doctrine\DBAL\Exception; namespace Doctrine\DBAL\Exception;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; use Doctrine\DBAL\Driver\Exception as TheDriverException;
use function assert; use function assert;
...@@ -12,13 +12,13 @@ use function assert; ...@@ -12,13 +12,13 @@ use function assert;
* *
* @psalm-immutable * @psalm-immutable
*/ */
class DriverException extends DBALException implements DeprecatedDriverException class DriverException extends DBALException implements TheDriverException
{ {
/** /**
* @param string $message The exception message. * @param string $message The exception message.
* @param DeprecatedDriverException $driverException The DBAL driver exception to chain. * @param TheDriverException $driverException The DBAL driver exception to chain.
*/ */
public function __construct($message, DeprecatedDriverException $driverException) public function __construct($message, TheDriverException $driverException)
{ {
parent::__construct($message, $driverException->getCode(), $driverException); parent::__construct($message, $driverException->getCode(), $driverException);
} }
...@@ -29,7 +29,7 @@ class DriverException extends DBALException implements DeprecatedDriverException ...@@ -29,7 +29,7 @@ class DriverException extends DBALException implements DeprecatedDriverException
public function getSQLState() public function getSQLState()
{ {
$previous = $this->getPrevious(); $previous = $this->getPrevious();
assert($previous instanceof DeprecatedDriverException); assert($previous instanceof TheDriverException);
return $previous->getSQLState(); return $previous->getSQLState();
} }
......
...@@ -5,7 +5,7 @@ declare(strict_types=1); ...@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Doctrine\DBAL; namespace Doctrine\DBAL;
use Doctrine\DBAL\Abstraction\Result as ResultInterface; use Doctrine\DBAL\Abstraction\Result as ResultInterface;
use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\Exception as DriverException;
use Doctrine\DBAL\Driver\Result as DriverResult; use Doctrine\DBAL\Driver\Result as DriverResult;
use Traversable; use Traversable;
......
...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Tests; ...@@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Tests;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\DriverException as InnerDriverException; use Doctrine\DBAL\Driver\Exception as InnerDriverException;
use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\DriverException;
use Exception; use Exception;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
......
...@@ -5,7 +5,7 @@ namespace Doctrine\DBAL\Tests\Driver; ...@@ -5,7 +5,7 @@ namespace Doctrine\DBAL\Tests\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\DriverException as DriverExceptionInterface; use Doctrine\DBAL\Driver\Exception as DriverExceptionInterface;
use Doctrine\DBAL\Driver\ExceptionConverterDriver; use Doctrine\DBAL\Driver\ExceptionConverterDriver;
use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\ConstraintViolationException; use Doctrine\DBAL\Exception\ConstraintViolationException;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Doctrine\DBAL\Tests\Driver\Mysqli; namespace Doctrine\DBAL\Tests\Driver\Mysqli;
use Doctrine\DBAL\Driver\Mysqli\Driver; use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\DBAL\Driver\Mysqli\HostRequired; use Doctrine\DBAL\Driver\Mysqli\Exception\HostRequired;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use function extension_loaded; use function extension_loaded;
......
...@@ -5,7 +5,7 @@ declare(strict_types=1); ...@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver\OCI8; namespace Doctrine\Tests\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\OCI8\ConvertPositionalToNamedPlaceholders; use Doctrine\DBAL\Driver\OCI8\ConvertPositionalToNamedPlaceholders;
use Doctrine\DBAL\Driver\OCI8\OCI8Exception; use Doctrine\DBAL\Driver\OCI8\Exception\NonTerminatedStringLiteral;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class ConvertPositionalToNamedPlaceholdersTest extends TestCase class ConvertPositionalToNamedPlaceholdersTest extends TestCase
...@@ -95,7 +95,7 @@ class ConvertPositionalToNamedPlaceholdersTest extends TestCase ...@@ -95,7 +95,7 @@ class ConvertPositionalToNamedPlaceholdersTest extends TestCase
*/ */
public function testConvertNonTerminatedLiteral(string $sql, string $expectedExceptionMessageRegExp): void public function testConvertNonTerminatedLiteral(string $sql, string $expectedExceptionMessageRegExp): void
{ {
$this->expectException(OCI8Exception::class); $this->expectException(NonTerminatedStringLiteral::class);
$this->expectExceptionMessageMatches($expectedExceptionMessageRegExp); $this->expectExceptionMessageMatches($expectedExceptionMessageRegExp);
($this->convertPositionalToNamedPlaceholders)($sql); ($this->convertPositionalToNamedPlaceholders)($sql);
} }
......
...@@ -40,7 +40,7 @@ class ExceptionTest extends TestCase ...@@ -40,7 +40,7 @@ class ExceptionTest extends TestCase
$this->wrappedException->errorInfo = [self::SQLSTATE, self::ERROR_CODE]; $this->wrappedException->errorInfo = [self::SQLSTATE, self::ERROR_CODE];
$this->exception = new Exception($this->wrappedException); $this->exception = Exception::new($this->wrappedException);
} }
public function testReturnsCode(): void public function testReturnsCode(): void
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
namespace Doctrine\DBAL\Tests\Functional\Driver\Mysqli; namespace Doctrine\DBAL\Tests\Functional\Driver\Mysqli;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\Mysqli\Driver; use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\DBAL\Driver\Mysqli\MysqliConnection; use Doctrine\DBAL\Driver\Mysqli\MysqliConnection;
use Doctrine\DBAL\Driver\Mysqli\MysqliException;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil; use Doctrine\DBAL\Tests\TestUtil;
...@@ -43,7 +43,7 @@ class ConnectionTest extends FunctionalTestCase ...@@ -43,7 +43,7 @@ class ConnectionTest extends FunctionalTestCase
public function testUnsupportedDriverOption(): void public function testUnsupportedDriverOption(): void
{ {
$this->expectException(MysqliException::class); $this->expectException(Exception::class);
$this->getConnection([12345 => 'world']); $this->getConnection([12345 => 'world']);
} }
...@@ -52,7 +52,7 @@ class ConnectionTest extends FunctionalTestCase ...@@ -52,7 +52,7 @@ class ConnectionTest extends FunctionalTestCase
{ {
$params = TestUtil::getConnectionParams(); $params = TestUtil::getConnectionParams();
$this->expectException(MysqliException::class); $this->expectException(Exception::class);
(new Driver())->connect( (new Driver())->connect(
array_merge( array_merge(
$params, $params,
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
namespace Doctrine\DBAL\Tests\Functional\Driver\SQLSrv; namespace Doctrine\DBAL\Tests\Functional\Driver\SQLSrv;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\SQLSrv\Driver; use Doctrine\DBAL\Driver\SQLSrv\Driver;
use Doctrine\DBAL\Driver\SQLSrv\SQLSrvException;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use function extension_loaded; use function extension_loaded;
...@@ -32,7 +32,7 @@ class StatementTest extends FunctionalTestCase ...@@ -32,7 +32,7 @@ class StatementTest extends FunctionalTestCase
// it's impossible to prepare the statement without bound variables for SQL Server, // it's impossible to prepare the statement without bound variables for SQL Server,
// so the preparation happens before the first execution when variables are already in place // so the preparation happens before the first execution when variables are already in place
$this->expectException(SQLSrvException::class); $this->expectException(Exception::class);
$stmt->execute(); $stmt->execute();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment