From 3691e814f58aada2a8c5901b00ddaca5c2801e33 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Fri, 11 Sep 2020 19:35:35 +0200 Subject: [PATCH] Revert "Merge pull request #4253 from morozov/deprecate-dbal-exception" This reverts commit f97ee9445186e2f5edd519579405df53521cdae4, reversing changes made to f69c990e359931753232a81c3a1821a7ea060bfd. --- UPGRADE.md | 4 - lib/Doctrine/DBAL/Abstraction/Result.php | 8 +- lib/Doctrine/DBAL/Cache/CacheException.php | 4 +- lib/Doctrine/DBAL/Connection.php | 71 ++++--- lib/Doctrine/DBAL/ConnectionException.php | 2 +- lib/Doctrine/DBAL/DBALException.php | 77 ++++--- .../DBAL/Driver/AbstractMySQLDriver.php | 12 +- .../DBAL/Driver/AbstractPostgreSQLDriver.php | 4 +- .../DBAL/Driver/AbstractSQLAnywhereDriver.php | 4 +- .../DBAL/Driver/AbstractSQLServerDriver.php | 4 +- lib/Doctrine/DBAL/Driver/Mysqli/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/OCI8/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php | 4 +- .../DBAL/Driver/SQLAnywhere/Driver.php | 6 +- lib/Doctrine/DBAL/DriverManager.php | 22 +- lib/Doctrine/DBAL/Exception.php | 10 - .../DBAL/Exception/DriverException.php | 13 +- .../Exception/InvalidArgumentException.php | 4 +- lib/Doctrine/DBAL/Id/TableGenerator.php | 12 +- .../DBAL/Platforms/AbstractPlatform.php | 192 +++++++++--------- lib/Doctrine/DBAL/Platforms/DB2Platform.php | 4 +- .../DBAL/Platforms/OraclePlatform.php | 6 +- .../DBAL/Platforms/SQLAnywherePlatform.php | 4 +- .../DBAL/Platforms/SqlitePlatform.php | 22 +- lib/Doctrine/DBAL/Query/QueryException.php | 4 +- lib/Doctrine/DBAL/SQLParserUtilsException.php | 2 +- .../DBAL/Schema/AbstractSchemaManager.php | 6 +- lib/Doctrine/DBAL/Schema/SchemaException.php | 4 +- .../DBAL/Schema/SqliteSchemaManager.php | 6 +- lib/Doctrine/DBAL/Schema/Table.php | 14 +- .../DBAL/Sharding/ShardingException.php | 4 +- lib/Doctrine/DBAL/Statement.php | 20 +- .../DBAL/Types/ConversionException.php | 4 +- lib/Doctrine/DBAL/Types/Type.php | 8 +- lib/Doctrine/DBAL/Types/TypeRegistry.php | 22 +- .../DBAL/VersionAwarePlatformDriver.php | 2 +- tests/Doctrine/Tests/DBAL/ConnectionTest.php | 11 +- .../Doctrine/Tests/DBAL/DBALExceptionTest.php | 19 +- .../Tests/DBAL/Driver/AbstractDriverTest.php | 4 +- .../Doctrine/Tests/DBAL/DriverManagerTest.php | 14 +- .../Tests/DBAL/Functional/DataAccessTest.php | 4 +- .../Schema/SqliteSchemaManagerTest.php | 4 +- .../DBAL/Functional/Ticket/DBAL630Test.php | 4 +- .../Platforms/AbstractPlatformTestCase.php | 20 +- .../AbstractSQLServerPlatformTestCase.php | 13 +- .../DBAL/Platforms/OraclePlatformTest.php | 8 +- .../Platforms/SQLAnywherePlatformTest.php | 6 +- .../Platforms/SQLServer2012PlatformTest.php | 10 + .../DBAL/Platforms/SqlitePlatformTest.php | 8 +- .../Doctrine/Tests/DBAL/Schema/TableTest.php | 4 +- tests/Doctrine/Tests/DBAL/StatementTest.php | 9 +- .../Tests/DBAL/Types/TypeRegistryTest.php | 14 +- 55 files changed, 392 insertions(+), 365 deletions(-) delete mode 100644 lib/Doctrine/DBAL/Exception.php diff --git a/UPGRADE.md b/UPGRADE.md index 9eb98d764a3..0392cdad627 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -84,10 +84,6 @@ 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: diff --git a/lib/Doctrine/DBAL/Abstraction/Result.php b/lib/Doctrine/DBAL/Abstraction/Result.php index 42ff3419e37..5e163785405 100644 --- a/lib/Doctrine/DBAL/Abstraction/Result.php +++ b/lib/Doctrine/DBAL/Abstraction/Result.php @@ -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; /** @@ -19,7 +19,7 @@ interface Result extends DriverResult * * @return Traversable> * - * @throws Exception + * @throws DBALException */ public function iterateNumeric(): Traversable; @@ -28,7 +28,7 @@ public function iterateNumeric(): Traversable; * * @return Traversable> * - * @throws Exception + * @throws DBALException */ public function iterateAssociative(): Traversable; @@ -37,7 +37,7 @@ public function iterateAssociative(): Traversable; * * @return Traversable * - * @throws Exception + * @throws DBALException */ public function iterateColumn(): Traversable; } diff --git a/lib/Doctrine/DBAL/Cache/CacheException.php b/lib/Doctrine/DBAL/Cache/CacheException.php index 3db115bdfae..db5680812e2 100644 --- a/lib/Doctrine/DBAL/Cache/CacheException.php +++ b/lib/Doctrine/DBAL/Cache/CacheException.php @@ -2,12 +2,12 @@ namespace Doctrine\DBAL\Cache; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; /** * @psalm-immutable */ -class CacheException extends Exception +class CacheException extends DBALException { /** * @return CacheException diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 82ef5d80170..507a5170d10 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -20,6 +20,7 @@ use Doctrine\DBAL\Query\QueryBuilder; use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Types\Type; +use Exception; use Throwable; use Traversable; @@ -174,7 +175,7 @@ class Connection implements DriverConnection * @param Configuration|null $config The configuration, optional. * @param EventManager|null $eventManager The event manager, optional. * - * @throws Exception + * @throws DBALException */ public function __construct( array $params, @@ -192,7 +193,7 @@ public function __construct( if (isset($params['platform'])) { if (! $params['platform'] instanceof Platforms\AbstractPlatform) { - throw Exception::invalidPlatformType($params['platform']); + throw DBALException::invalidPlatformType($params['platform']); } $this->platform = $params['platform']; @@ -320,7 +321,7 @@ public function getEventManager() * * @return AbstractPlatform * - * @throws Exception + * @throws DBALException */ public function getDatabasePlatform() { @@ -378,7 +379,7 @@ public function connect() * * Evaluates custom platform class and version in order to set the correct platform. * - * @throws Exception If an invalid platform was specified for this connection. + * @throws DBALException If an invalid platform was specified for this connection. */ private function detectDatabasePlatform(): void { @@ -405,7 +406,7 @@ private function detectDatabasePlatform(): void * * @return string|null * - * @throws Throwable + * @throws Exception */ private function getDatabasePlatformVersion() { @@ -549,7 +550,7 @@ public function setFetchMode($fetchMode) * * @return mixed[]|false False is returned if no rows are found. * - * @throws Exception + * @throws DBALException */ public function fetchAssoc($sql, array $params = [], array $types = []) { @@ -586,7 +587,7 @@ public function fetchArray($sql, array $params = [], array $types = []) * * @return mixed|false False is returned if no rows are found. * - * @throws Exception + * @throws DBALException */ public function fetchColumn($sql, array $params = [], $column = 0, array $types = []) { @@ -603,7 +604,7 @@ public function fetchColumn($sql, array $params = [], $column = 0, array $types * * @return array|false False is returned if no rows are found. * - * @throws Exception + * @throws DBALException */ public function fetchAssociative(string $query, array $params = [], array $types = []) { @@ -630,7 +631,7 @@ public function fetchAssociative(string $query, array $params = [], array $types * * @return array|false False is returned if no rows are found. * - * @throws Exception + * @throws DBALException */ public function fetchNumeric(string $query, array $params = [], array $types = []) { @@ -657,7 +658,7 @@ public function fetchNumeric(string $query, array $params = [], array $types = [ * * @return mixed|false False is returned if no rows are found. * - * @throws Exception + * @throws DBALException */ public function fetchOne(string $query, array $params = [], array $types = []) { @@ -702,7 +703,7 @@ public function isTransactionActive() * @param mixed[] $values Column values * @param string[] $conditions Key conditions * - * @throws Exception + * @throws DBALException */ private function addIdentifierCondition( array $identifier, @@ -735,7 +736,8 @@ private function addIdentifierCondition( * * @return int The number of affected rows. * - * @throws Exception + * @throws DBALException + * @throws InvalidArgumentException */ public function delete($table, array $identifier, array $types = []) { @@ -804,7 +806,7 @@ public function getTransactionIsolation() * * @return int The number of affected rows. * - * @throws Exception + * @throws DBALException */ public function update($table, array $data, array $identifier, array $types = []) { @@ -839,7 +841,7 @@ public function update($table, array $data, array $identifier, array $types = [] * * @return int The number of affected rows. * - * @throws Exception + * @throws DBALException */ public function insert($table, array $data, array $types = []) { @@ -940,7 +942,7 @@ public function fetchAll($sql, array $params = [], $types = []) * * @return array> * - * @throws Exception + * @throws DBALException */ public function fetchAllNumeric(string $query, array $params = [], array $types = []): array { @@ -966,7 +968,7 @@ public function fetchAllNumeric(string $query, array $params = [], array $types * * @return array> * - * @throws Exception + * @throws DBALException */ public function fetchAllAssociative(string $query, array $params = [], array $types = []): array { @@ -992,7 +994,7 @@ public function fetchAllAssociative(string $query, array $params = [], array $ty * * @return array * - * @throws Exception + * @throws DBALException */ public function fetchFirstColumn(string $query, array $params = [], array $types = []): array { @@ -1018,7 +1020,7 @@ public function fetchFirstColumn(string $query, array $params = [], array $types * * @return Traversable> * - * @throws Exception + * @throws DBALException */ public function iterateNumeric(string $query, array $params = [], array $types = []): Traversable { @@ -1047,7 +1049,7 @@ public function iterateNumeric(string $query, array $params = [], array $types = * * @return Traversable> * - * @throws Exception + * @throws DBALException */ public function iterateAssociative(string $query, array $params = [], array $types = []): Traversable { @@ -1075,7 +1077,7 @@ public function iterateAssociative(string $query, array $params = [], array $typ * * @return Traversable * - * @throws Exception + * @throws DBALException */ public function iterateColumn(string $query, array $params = [], array $types = []): Traversable { @@ -1101,7 +1103,7 @@ public function iterateColumn(string $query, array $params = [], array $types = * * @return Statement The prepared statement. * - * @throws Exception + * @throws DBALException */ public function prepare($sql) { @@ -1129,7 +1131,7 @@ public function prepare($sql) * * @return ResultStatement The executed statement. * - * @throws Exception + * @throws DBALException */ public function executeQuery($sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null) { @@ -1263,7 +1265,7 @@ public function project($sql, array $params, Closure $function) * * @return \Doctrine\DBAL\Driver\Statement * - * @throws Exception + * @throws DBALException */ public function query() { @@ -1305,7 +1307,7 @@ public function query() * * @return int The number of affected rows. * - * @throws Exception + * @throws DBALException */ public function executeUpdate($sql, array $params = [], array $types = []) { @@ -1330,7 +1332,7 @@ public function executeUpdate($sql, array $params = [], array $types = []) * * @return int The number of affected rows. * - * @throws Exception + * @throws DBALException */ public function executeStatement($sql, array $params = [], array $types = []) { @@ -1383,7 +1385,7 @@ public function executeStatement($sql, array $params = [], array $types = []) * * @return int The number of affected rows. * - * @throws Exception + * @throws DBALException */ public function exec($sql) { @@ -1468,6 +1470,7 @@ public function lastInsertId($name = null) * * @return mixed The value returned by $func * + * @throws Exception * @throws Throwable */ public function transactional(Closure $func) @@ -1478,6 +1481,10 @@ public function transactional(Closure $func) $this->commit(); return $res; + } catch (Exception $e) { + $this->rollBack(); + + throw $e; } catch (Throwable $e) { $this->rollBack(); @@ -2007,14 +2014,14 @@ public function ping() * @param array|array $params * @param array|array $types * - * @throws Exception + * @throws DBALException * * @psalm-return never-return */ public function handleExceptionDuringQuery(Throwable $e, string $sql, array $params = [], array $types = []): void { $this->throw( - Exception::driverExceptionDuringQuery( + DBALException::driverExceptionDuringQuery( $this->_driver, $e, $sql, @@ -2026,14 +2033,14 @@ public function handleExceptionDuringQuery(Throwable $e, string $sql, array $par /** * @internal * - * @throws Exception + * @throws DBALException * * @psalm-return never-return */ public function handleDriverException(Throwable $e): void { $this->throw( - Exception::driverException( + DBALException::driverException( $this->_driver, $e ) @@ -2043,11 +2050,11 @@ public function handleDriverException(Throwable $e): void /** * @internal * - * @throws Exception + * @throws DBALException * * @psalm-return never-return */ - private function throw(Exception $e): void + private function throw(DBALException $e): void { if ($e instanceof ConnectionLost) { $this->close(); diff --git a/lib/Doctrine/DBAL/ConnectionException.php b/lib/Doctrine/DBAL/ConnectionException.php index 8426ca28891..f1914f5294e 100644 --- a/lib/Doctrine/DBAL/ConnectionException.php +++ b/lib/Doctrine/DBAL/ConnectionException.php @@ -5,7 +5,7 @@ /** * @psalm-immutable */ -class ConnectionException extends Exception +class ConnectionException extends DBALException { /** * @return ConnectionException diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index b9a33cf1f70..f208a14ae92 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; +use Exception; use Throwable; use function array_map; @@ -23,20 +24,18 @@ use function sprintf; /** - * @deprecated Use {@link Exception} instead - * * @psalm-immutable */ -class DBALException extends \Exception +class DBALException extends Exception { /** * @param string $method * - * @return Exception + * @return DBALException */ public static function notSupported($method) { - return new Exception(sprintf("Operation '%s' is not supported by platform.", $method)); + return new self(sprintf("Operation '%s' is not supported by platform.", $method)); } /** @@ -44,7 +43,7 @@ public static function notSupported($method) */ public static function invalidPlatformSpecified(): self { - return new Exception( + return new self( "Invalid 'platform' option specified, need to give an instance of " . AbstractPlatform::class . '.' ); } @@ -55,7 +54,7 @@ public static function invalidPlatformSpecified(): self public static function invalidPlatformType($invalidPlatform): self { if (is_object($invalidPlatform)) { - return new Exception( + return new self( sprintf( "Option 'platform' must be a subtype of '%s', instance of '%s' given", AbstractPlatform::class, @@ -64,7 +63,7 @@ public static function invalidPlatformType($invalidPlatform): self ); } - return new Exception( + return new self( sprintf( "Option 'platform' must be an object and subtype of '%s'. Got '%s'", AbstractPlatform::class, @@ -79,11 +78,11 @@ public static function invalidPlatformType($invalidPlatform): self * @param string $version The invalid platform version given. * @param string $expectedFormat The expected platform version format. * - * @return Exception + * @return DBALException */ public static function invalidPlatformVersionSpecified($version, $expectedFormat) { - return new Exception( + return new self( sprintf( 'Invalid platform version "%s" specified. ' . 'The platform version has to be specified in the format: "%s".', @@ -96,11 +95,11 @@ public static function invalidPlatformVersionSpecified($version, $expectedFormat /** * @deprecated Passing a PDO instance in connection parameters is deprecated. * - * @return Exception + * @return DBALException */ public static function invalidPdoInstance() { - return new Exception( + return new self( "The 'pdo' option was used in DriverManager::getConnection() but no " . 'instance of PDO was given.' ); @@ -109,12 +108,12 @@ public static function invalidPdoInstance() /** * @param string|null $url The URL that was provided in the connection parameters (if any). * - * @return Exception + * @return DBALException */ public static function driverRequired($url = null) { if ($url) { - return new Exception( + return new self( sprintf( "The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme " . 'is given to DriverManager::getConnection(). Given URL: %s', @@ -123,7 +122,7 @@ public static function driverRequired($url = null) ); } - return new Exception("The options 'driver' or 'driverClass' are mandatory if no PDO " . + return new self("The options 'driver' or 'driverClass' are mandatory if no PDO " . 'instance is given to DriverManager::getConnection().'); } @@ -131,11 +130,11 @@ public static function driverRequired($url = null) * @param string $unknownDriverName * @param string[] $knownDrivers * - * @return Exception + * @return DBALException */ public static function unknownDriver($unknownDriverName, array $knownDrivers) { - return new Exception("The given 'driver' " . $unknownDriverName . ' is unknown, ' . + return new self("The given 'driver' " . $unknownDriverName . ' is unknown, ' . 'Doctrine currently supports only the following drivers: ' . implode(', ', $knownDrivers)); } @@ -145,7 +144,7 @@ public static function unknownDriver($unknownDriverName, array $knownDrivers) * @param string $sql * @param mixed[] $params * - * @return Exception + * @return self */ public static function driverExceptionDuringQuery(Driver $driver, Throwable $driverEx, $sql, array $params = []) { @@ -162,7 +161,7 @@ public static function driverExceptionDuringQuery(Driver $driver, Throwable $dri /** * @deprecated * - * @return Exception + * @return self */ public static function driverException(Driver $driver, Throwable $driverEx) { @@ -170,7 +169,7 @@ public static function driverException(Driver $driver, Throwable $driverEx) } /** - * @return Exception + * @return self */ private static function wrapException(Driver $driver, Throwable $driverEx, string $msg) { @@ -182,7 +181,7 @@ private static function wrapException(Driver $driver, Throwable $driverEx, strin return $driver->convertException($msg, $driverEx); } - return new Exception($msg, 0, $driverEx); + return new self($msg, 0, $driverEx); } /** @@ -214,22 +213,22 @@ private static function formatParameters(array $params) /** * @param string $wrapperClass * - * @return Exception + * @return DBALException */ public static function invalidWrapperClass($wrapperClass) { - return new Exception("The given 'wrapperClass' " . $wrapperClass . ' has to be a ' . + return new self("The given 'wrapperClass' " . $wrapperClass . ' has to be a ' . 'subtype of \Doctrine\DBAL\Connection.'); } /** * @param string $driverClass * - * @return Exception + * @return DBALException */ public static function invalidDriverClass($driverClass) { - return new Exception( + return new self( "The given 'driverClass' " . $driverClass . ' has to implement the ' . Driver::class . ' interface.' ); } @@ -237,49 +236,49 @@ public static function invalidDriverClass($driverClass) /** * @param string $tableName * - * @return Exception + * @return DBALException */ public static function invalidTableName($tableName) { - return new Exception('Invalid table name specified: ' . $tableName); + return new self('Invalid table name specified: ' . $tableName); } /** * @param string $tableName * - * @return Exception + * @return DBALException */ public static function noColumnsSpecifiedForTable($tableName) { - return new Exception('No columns specified for table ' . $tableName); + return new self('No columns specified for table ' . $tableName); } /** - * @return Exception + * @return DBALException */ public static function limitOffsetInvalid() { - return new Exception('Invalid Offset in Limit Query, it has to be larger than or equal to 0.'); + return new self('Invalid Offset in Limit Query, it has to be larger than or equal to 0.'); } /** * @param string $name * - * @return Exception + * @return DBALException */ public static function typeExists($name) { - return new Exception('Type ' . $name . ' already exists.'); + return new self('Type ' . $name . ' already exists.'); } /** * @param string $name * - * @return Exception + * @return DBALException */ public static function unknownColumnType($name) { - return new Exception('Unknown column type "' . $name . '" requested. Any Doctrine type that you use has ' . + return new self('Unknown column type "' . $name . '" requested. Any Doctrine type that you use has ' . 'to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the ' . 'known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database ' . 'introspection then you might have forgotten to register all database types for a Doctrine Type. Use ' . @@ -291,23 +290,23 @@ public static function unknownColumnType($name) /** * @param string $name * - * @return Exception + * @return DBALException */ public static function typeNotFound($name) { - return new Exception('Type to be overwritten ' . $name . ' does not exist.'); + return new self('Type to be overwritten ' . $name . ' does not exist.'); } public static function typeNotRegistered(Type $type): self { - return new Exception( + return new self( sprintf('Type of the class %s@%s is not registered.', get_class($type), spl_object_hash($type)) ); } public static function typeAlreadyRegistered(Type $type): self { - return new Exception( + return new self( sprintf('Type of the class %s@%s is already registered.', get_class($type), spl_object_hash($type)) ); } diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index edb33b89a40..7fd77aa5c51 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -3,9 +3,9 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\ConnectionLost; use Doctrine\DBAL\Exception\DeadlockException; @@ -131,7 +131,7 @@ public function convertException($message, DeprecatedDriverException $exception) /** * {@inheritdoc} * - * @throws Exception + * @throws DBALException */ public function createDatabasePlatformForVersion($version) { @@ -160,7 +160,7 @@ public function createDatabasePlatformForVersion($version) * * @param string $versionString Version string returned by the driver, i.e. '5.7.10' * - * @throws Exception + * @throws DBALException */ private function getOracleMysqlVersionNumber(string $versionString): string { @@ -171,7 +171,7 @@ private function getOracleMysqlVersionNumber(string $versionString): string $versionParts ) ) { - throw Exception::invalidPlatformVersionSpecified( + throw DBALException::invalidPlatformVersionSpecified( $versionString, '..' ); @@ -194,7 +194,7 @@ private function getOracleMysqlVersionNumber(string $versionString): string * * @param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial' * - * @throws Exception + * @throws DBALException */ private function getMariaDbMysqlVersionNumber(string $versionString): string { @@ -205,7 +205,7 @@ private function getMariaDbMysqlVersionNumber(string $versionString): string $versionParts ) ) { - throw Exception::invalidPlatformVersionSpecified( + throw DBALException::invalidPlatformVersionSpecified( $versionString, '^(?:5\.5\.5-)?(mariadb-)?..' ); diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index b9610255546..93b3eaa33f5 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -3,9 +3,9 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\DeadlockException; use Doctrine\DBAL\Exception\DriverException; @@ -108,7 +108,7 @@ public function convertException($message, DeprecatedDriverException $exception) public function createDatabasePlatformForVersion($version) { if (! preg_match('/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?/', $version, $versionParts)) { - throw Exception::invalidPlatformVersionSpecified( + throw DBALException::invalidPlatformVersionSpecified( $version, '..' ); diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index 7fc71870d55..668f765e1ca 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -3,9 +3,9 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\DeadlockException; use Doctrine\DBAL\Exception\DriverException; @@ -103,7 +103,7 @@ public function createDatabasePlatformForVersion($version) $versionParts ) ) { - throw Exception::invalidPlatformVersionSpecified( + throw DBALException::invalidPlatformVersionSpecified( $version, '...' ); diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php index 2550ec5a87f..0d85a938dfb 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php @@ -3,9 +3,9 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as TheDriverException; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\SQLServer2005Platform; use Doctrine\DBAL\Platforms\SQLServer2008Platform; @@ -35,7 +35,7 @@ public function createDatabasePlatformForVersion($version) $versionParts ) ) { - throw Exception::invalidPlatformVersionSpecified( + throw DBALException::invalidPlatformVersionSpecified( $version, '...' ); diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php b/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php index 9ac74f27d07..561b51ba0f3 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php @@ -2,8 +2,8 @@ namespace Doctrine\DBAL\Driver\Mysqli; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractMySQLDriver; -use Doctrine\DBAL\Exception; class Driver extends AbstractMySQLDriver { @@ -15,7 +15,7 @@ public function connect(array $params, $username = null, $password = null, array try { return new Connection($params, (string) $username, (string) $password, $driverOptions); } catch (MysqliException $e) { - throw Exception::driverException($this, $e); + throw DBALException::driverException($this, $e); } } diff --git a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php index 5f7e3c0a9e8..d83c2bdc30f 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php @@ -2,8 +2,8 @@ namespace Doctrine\DBAL\Driver\OCI8; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractOracleDriver; -use Doctrine\DBAL\Exception; use const OCI_NO_AUTO_COMMIT; @@ -27,7 +27,7 @@ public function connect(array $params, $username = null, $password = null, array $params['persistent'] ?? false ); } catch (OCI8Exception $e) { - throw Exception::driverException($this, $e); + throw DBALException::driverException($this, $e); } } diff --git a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php index 25eb2fbdb6f..eec433a9924 100644 --- a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php @@ -2,9 +2,9 @@ namespace Doctrine\DBAL\Driver\PDOMySql; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractMySQLDriver; use Doctrine\DBAL\Driver\PDO; -use Doctrine\DBAL\Exception; use PDOException; /** @@ -27,7 +27,7 @@ public function connect(array $params, $username = null, $password = null, array $driverOptions ); } catch (PDOException $e) { - throw Exception::driverException($this, $e); + throw DBALException::driverException($this, $e); } return $conn; diff --git a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php index b6792996c71..2ea597d16f1 100644 --- a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php @@ -2,9 +2,9 @@ namespace Doctrine\DBAL\Driver\PDOOracle; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractOracleDriver; use Doctrine\DBAL\Driver\PDO; -use Doctrine\DBAL\Exception; use PDOException; /** @@ -32,7 +32,7 @@ public function connect(array $params, $username = null, $password = null, array $driverOptions ); } catch (PDOException $e) { - throw Exception::driverException($this, $e); + throw DBALException::driverException($this, $e); } } diff --git a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index 83076aa8c06..d7a19181c4e 100644 --- a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -2,9 +2,9 @@ namespace Doctrine\DBAL\Driver\PDOPgSql; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; use Doctrine\DBAL\Driver\PDO; -use Doctrine\DBAL\Exception; use PDOException; use function defined; @@ -48,7 +48,7 @@ public function connect(array $params, $username = null, $password = null, array return $pdo; } catch (PDOException $e) { - throw Exception::driverException($this, $e); + throw DBALException::driverException($this, $e); } } diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php index fc2b881ffce..0c3b3900059 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -2,9 +2,9 @@ namespace Doctrine\DBAL\Driver\PDOSqlite; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractSQLiteDriver; use Doctrine\DBAL\Driver\PDO; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\SqlitePlatform; use PDOException; @@ -45,7 +45,7 @@ public function connect(array $params, $username = null, $password = null, array $driverOptions ); } catch (PDOException $ex) { - throw Exception::driverException($this, $ex); + throw DBALException::driverException($this, $ex); } foreach ($this->_userDefinedFunctions as $fn => $data) { diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php index 95b59274e9e..bc29466e1a9 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php @@ -2,8 +2,8 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver; -use Doctrine\DBAL\Exception; use function array_keys; use function array_map; @@ -17,7 +17,7 @@ class Driver extends AbstractSQLAnywhereDriver /** * {@inheritdoc} * - * @throws Exception If there was a problem establishing the connection. + * @throws DBALException If there was a problem establishing the connection. */ public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { @@ -35,7 +35,7 @@ public function connect(array $params, $username = null, $password = null, array $params['persistent'] ?? false ); } catch (SQLAnywhereException $e) { - throw Exception::driverException($this, $e); + throw DBALException::driverException($this, $e); } } diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php index 6c21d806580..70894eaa4a5 100644 --- a/lib/Doctrine/DBAL/DriverManager.php +++ b/lib/Doctrine/DBAL/DriverManager.php @@ -117,7 +117,7 @@ private function __construct() * @param Configuration|null $config The configuration to use. * @param EventManager|null $eventManager The event manager to use. * - * @throws Exception + * @throws DBALException * * @phpstan-param mixed[] $params * @psalm-return ($params is array{wrapperClass:mixed} ? T : Connection) @@ -175,7 +175,7 @@ public static function getConnection( // check for existing pdo object if (isset($params['pdo']) && ! $params['pdo'] instanceof \PDO) { - throw Exception::invalidPdoInstance(); + throw DBALException::invalidPdoInstance(); } if (isset($params['pdo'])) { @@ -192,7 +192,7 @@ public static function getConnection( $wrapperClass = Connection::class; if (isset($params['wrapperClass'])) { if (! is_subclass_of($params['wrapperClass'], $wrapperClass)) { - throw Exception::invalidWrapperClass($params['wrapperClass']); + throw DBALException::invalidWrapperClass($params['wrapperClass']); } $wrapperClass = $params['wrapperClass']; @@ -216,7 +216,7 @@ public static function getAvailableDrivers(): array * * @param mixed[] $params The list of parameters. * - * @throws Exception + * @throws DBALException */ private static function _checkParams(array $params): void { @@ -224,21 +224,21 @@ private static function _checkParams(array $params): void // driver if (! isset($params['driver']) && ! isset($params['driverClass'])) { - throw Exception::driverRequired(); + throw DBALException::driverRequired(); } // check validity of parameters // driver if (isset($params['driver']) && ! isset(self::$_driverMap[$params['driver']])) { - throw Exception::unknownDriver($params['driver'], array_keys(self::$_driverMap)); + throw DBALException::unknownDriver($params['driver'], array_keys(self::$_driverMap)); } if ( isset($params['driverClass']) && ! in_array(Driver::class, class_implements($params['driverClass'], true)) ) { - throw Exception::invalidDriverClass($params['driverClass']); + throw DBALException::invalidDriverClass($params['driverClass']); } } @@ -262,7 +262,7 @@ private static function normalizeDatabaseUrlPath(string $urlPath): string * @return mixed[] A modified list of parameters with info from a database * URL extracted into indidivual parameter parts. * - * @throws Exception + * @throws DBALException */ private static function parseDatabaseUrl(array $params): array { @@ -277,7 +277,7 @@ private static function parseDatabaseUrl(array $params): array $url = parse_url($url); if ($url === false) { - throw new Exception('Malformed parameter "url".'); + throw new DBALException('Malformed parameter "url".'); } $url = array_map('rawurldecode', $url); @@ -417,7 +417,7 @@ private static function parseSqliteDatabaseUrlPath(array $url, array $params): a * * @return mixed[] The resolved connection parameters. * - * @throws Exception If parsing failed or resolution is not possible. + * @throws DBALException If parsing failed or resolution is not possible. */ private static function parseDatabaseUrlScheme(array $url, array $params): array { @@ -442,7 +442,7 @@ private static function parseDatabaseUrlScheme(array $url, array $params): array // If a schemeless connection URL is given, we require a default driver or default custom driver // as connection parameter. if (! isset($params['driverClass']) && ! isset($params['driver'])) { - throw Exception::driverRequired($params['url']); + throw DBALException::driverRequired($params['url']); } return $params; diff --git a/lib/Doctrine/DBAL/Exception.php b/lib/Doctrine/DBAL/Exception.php deleted file mode 100644 index 34442da6a8a..00000000000 --- a/lib/Doctrine/DBAL/Exception.php +++ /dev/null @@ -1,10 +0,0 @@ -driverException = $driverException; } diff --git a/lib/Doctrine/DBAL/Exception/InvalidArgumentException.php b/lib/Doctrine/DBAL/Exception/InvalidArgumentException.php index 0b06140740f..5d20332af09 100644 --- a/lib/Doctrine/DBAL/Exception/InvalidArgumentException.php +++ b/lib/Doctrine/DBAL/Exception/InvalidArgumentException.php @@ -2,14 +2,14 @@ namespace Doctrine\DBAL\Exception; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; /** * Exception to be thrown when invalid arguments are passed to any DBAL API * * @psalm-immutable */ -class InvalidArgumentException extends Exception +class InvalidArgumentException extends DBALException { /** * @return self diff --git a/lib/Doctrine/DBAL/Id/TableGenerator.php b/lib/Doctrine/DBAL/Id/TableGenerator.php index c17caadae28..1aeddc0d01c 100644 --- a/lib/Doctrine/DBAL/Id/TableGenerator.php +++ b/lib/Doctrine/DBAL/Id/TableGenerator.php @@ -3,9 +3,9 @@ namespace Doctrine\DBAL\Id; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\LockMode; use Throwable; @@ -66,12 +66,12 @@ class TableGenerator /** * @param string $generatorTableName * - * @throws Exception + * @throws DBALException */ public function __construct(Connection $conn, $generatorTableName = 'sequences') { if ($conn->getDriver() instanceof Driver\PDOSqlite\Driver) { - throw new Exception('Cannot use TableGenerator with SQLite.'); + throw new DBALException('Cannot use TableGenerator with SQLite.'); } $this->conn = DriverManager::getConnection( @@ -90,7 +90,7 @@ public function __construct(Connection $conn, $generatorTableName = 'sequences') * * @return int * - * @throws Exception + * @throws DBALException */ public function nextValue($sequence) { @@ -134,7 +134,7 @@ public function nextValue($sequence) $rows = $this->conn->executeStatement($sql, [$sequence, $row['sequence_value']]); if ($rows !== 1) { - throw new Exception('Race-condition detected while updating sequence. Aborting generation'); + throw new DBALException('Race-condition detected while updating sequence. Aborting generation'); } } else { $this->conn->insert( @@ -148,7 +148,7 @@ public function nextValue($sequence) } catch (Throwable $e) { $this->conn->rollBack(); - throw new Exception( + throw new DBALException( 'Error occurred while generating ID with TableGenerator, aborted generation: ' . $e->getMessage(), 0, $e diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 6dc828bf1b2..80dff51acfe 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\Common\EventManager; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs; use Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs; use Doctrine\DBAL\Event\SchemaAlterTableEventArgs; @@ -12,7 +13,6 @@ use Doctrine\DBAL\Event\SchemaCreateTableEventArgs; use Doctrine\DBAL\Event\SchemaDropTableEventArgs; use Doctrine\DBAL\Events; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\Keywords\KeywordList; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ColumnDiff; @@ -343,11 +343,11 @@ public function getJsonTypeDeclarationSQL(array $column) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) { - throw Exception::notSupported('VARCHARs not supported by Platform.'); + throw DBALException::notSupported('VARCHARs not supported by Platform.'); } /** @@ -358,11 +358,11 @@ protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed) { - throw Exception::notSupported('BINARY/VARBINARY column types are not supported by this platform.'); + throw DBALException::notSupported('BINARY/VARBINARY column types are not supported by this platform.'); } /** @@ -398,7 +398,7 @@ abstract public function getName(); * * @return void * - * @throws Exception If the type is not found. + * @throws DBALException If the type is not found. */ public function registerDoctrineTypeMapping($dbType, $doctrineType) { @@ -407,7 +407,7 @@ public function registerDoctrineTypeMapping($dbType, $doctrineType) } if (! Types\Type::hasType($doctrineType)) { - throw Exception::typeNotFound($doctrineType); + throw DBALException::typeNotFound($doctrineType); } $dbType = strtolower($dbType); @@ -429,7 +429,7 @@ public function registerDoctrineTypeMapping($dbType, $doctrineType) * * @return string * - * @throws Exception + * @throws DBALException */ public function getDoctrineTypeMapping($dbType) { @@ -440,7 +440,7 @@ public function getDoctrineTypeMapping($dbType) $dbType = strtolower($dbType); if (! isset($this->doctrineTypeMapping[$dbType])) { - throw new Exception( + throw new DBALException( 'Unknown database type ' . $dbType . ' requested, ' . static::class . ' may not support it.' ); } @@ -639,11 +639,11 @@ public function getWildcards() * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getRegexpExpression() { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -653,11 +653,11 @@ public function getRegexpExpression() * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getGuidExpression() { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -885,11 +885,11 @@ public function getLowerExpression($str) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getLocateExpression($str, $substr, $startPos = false) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -1056,11 +1056,11 @@ public function getCosExpression($value) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateDiffExpression($date1, $date2) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -1071,7 +1071,7 @@ public function getDateDiffExpression($date1, $date2) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateAddSecondsExpression($date, $seconds) { @@ -1086,7 +1086,7 @@ public function getDateAddSecondsExpression($date, $seconds) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateSubSecondsExpression($date, $seconds) { @@ -1101,7 +1101,7 @@ public function getDateSubSecondsExpression($date, $seconds) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateAddMinutesExpression($date, $minutes) { @@ -1116,7 +1116,7 @@ public function getDateAddMinutesExpression($date, $minutes) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateSubMinutesExpression($date, $minutes) { @@ -1131,7 +1131,7 @@ public function getDateSubMinutesExpression($date, $minutes) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateAddHourExpression($date, $hours) { @@ -1146,7 +1146,7 @@ public function getDateAddHourExpression($date, $hours) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateSubHourExpression($date, $hours) { @@ -1161,7 +1161,7 @@ public function getDateSubHourExpression($date, $hours) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateAddDaysExpression($date, $days) { @@ -1176,7 +1176,7 @@ public function getDateAddDaysExpression($date, $days) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateSubDaysExpression($date, $days) { @@ -1191,7 +1191,7 @@ public function getDateSubDaysExpression($date, $days) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateAddWeeksExpression($date, $weeks) { @@ -1206,7 +1206,7 @@ public function getDateAddWeeksExpression($date, $weeks) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateSubWeeksExpression($date, $weeks) { @@ -1221,7 +1221,7 @@ public function getDateSubWeeksExpression($date, $weeks) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateAddMonthExpression($date, $months) { @@ -1236,7 +1236,7 @@ public function getDateAddMonthExpression($date, $months) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateSubMonthExpression($date, $months) { @@ -1251,7 +1251,7 @@ public function getDateSubMonthExpression($date, $months) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateAddQuartersExpression($date, $quarters) { @@ -1266,7 +1266,7 @@ public function getDateAddQuartersExpression($date, $quarters) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateSubQuartersExpression($date, $quarters) { @@ -1281,7 +1281,7 @@ public function getDateSubQuartersExpression($date, $quarters) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateAddYearsExpression($date, $years) { @@ -1296,7 +1296,7 @@ public function getDateAddYearsExpression($date, $years) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateSubYearsExpression($date, $years) { @@ -1314,11 +1314,11 @@ public function getDateSubYearsExpression($date, $years) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -1541,7 +1541,7 @@ public function getDropForeignKeySQL($foreignKey, $table) * * @return string[] The sequence of SQL statements. * - * @throws Exception + * @throws DBALException * @throws InvalidArgumentException */ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDEXES) @@ -1553,7 +1553,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE } if (count($table->getColumns()) === 0) { - throw Exception::noColumnsSpecifiedForTable($table->getName()); + throw DBALException::noColumnsSpecifiedForTable($table->getName()); } $tableName = $table->getQuotedName($this); @@ -1682,12 +1682,12 @@ public function getCommentOnColumnSQL($tableName, $columnName, $comment) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getInlineColumnCommentSQL($comment) { if (! $this->supportsInlineColumnComments()) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } return 'COMMENT ' . $this->quoteStringLiteral($comment); @@ -1755,11 +1755,11 @@ public function getCreateTemporaryTableSnippetSQL() * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getCreateSequenceSQL(Sequence $sequence) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -1767,11 +1767,11 @@ public function getCreateSequenceSQL(Sequence $sequence) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getAlterSequenceSQL(Sequence $sequence) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -1895,11 +1895,11 @@ public function getCreatePrimaryKeySQL(Index $index, $table) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getCreateSchemaSQL($schemaName) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -1964,11 +1964,11 @@ public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) * * @return string[] * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getAlterTableSQL(TableDiff $diff) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2793,11 +2793,11 @@ protected function _getTransactionIsolationLevelSQL($level) /** * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getListDatabasesSQL() { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2805,11 +2805,11 @@ public function getListDatabasesSQL() * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getListNamespacesSQL() { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2817,11 +2817,11 @@ public function getListNamespacesSQL() * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getListSequencesSQL($database) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2829,11 +2829,11 @@ public function getListSequencesSQL($database) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getListTableConstraintsSQL($table) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2842,31 +2842,31 @@ public function getListTableConstraintsSQL($table) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getListTableColumnsSQL($table, $database = null) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getListTablesSQL() { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getListUsersSQL() { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2876,11 +2876,11 @@ public function getListUsersSQL() * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getListViewsSQL($database) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2898,11 +2898,11 @@ public function getListViewsSQL($database) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getListTableIndexesSQL($table, $database = null) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2910,11 +2910,11 @@ public function getListTableIndexesSQL($table, $database = null) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getListTableForeignKeysSQL($table) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2923,11 +2923,11 @@ public function getListTableForeignKeysSQL($table) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getCreateViewSQL($name, $sql) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2935,11 +2935,11 @@ public function getCreateViewSQL($name, $sql) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDropViewSQL($name) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2949,11 +2949,11 @@ public function getDropViewSQL($name) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDropSequenceSQL($sequence) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2961,11 +2961,11 @@ public function getDropSequenceSQL($sequence) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getSequenceNextValSQL($sequence) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2975,11 +2975,11 @@ public function getSequenceNextValSQL($sequence) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getCreateDatabaseSQL($database) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -2989,11 +2989,11 @@ public function getCreateDatabaseSQL($database) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getSetTransactionIsolationSQL($level) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -3004,11 +3004,11 @@ public function getSetTransactionIsolationSQL($level) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateTimeTypeDeclarationSQL(array $column) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -3031,11 +3031,11 @@ public function getDateTimeTzTypeDeclarationSQL(array $column) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDateTypeDeclarationSQL(array $column) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -3046,11 +3046,11 @@ public function getDateTypeDeclarationSQL(array $column) * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getTimeTypeDeclarationSQL(array $column) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -3124,11 +3124,11 @@ public function usesSequenceEmulatedIdentityColumns() * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getIdentitySequenceName($tableName, $columnName) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -3259,11 +3259,11 @@ public function canEmulateSchemas() * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ public function getDefaultSchemaName() { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** @@ -3413,7 +3413,7 @@ public function getTimeFormatString() * * @return string * - * @throws Exception + * @throws DBALException */ final public function modifyLimitQuery($query, $limit, $offset = null) { @@ -3424,14 +3424,14 @@ final public function modifyLimitQuery($query, $limit, $offset = null) $offset = (int) $offset; if ($offset < 0) { - throw new Exception(sprintf( + throw new DBALException(sprintf( 'Offset must be a positive integer or zero, %d given', $offset )); } if ($offset > 0 && ! $this->supportsLimitOffset()) { - throw new Exception(sprintf( + throw new DBALException(sprintf( 'Platform %s does not support offset values in limit queries.', $this->getName() )); @@ -3595,7 +3595,7 @@ public function rollbackSavePoint($savepoint) * * @return KeywordList * - * @throws Exception If no keyword list is specified. + * @throws DBALException If no keyword list is specified. */ final public function getReservedKeywordsList() { @@ -3607,7 +3607,7 @@ final public function getReservedKeywordsList() $class = $this->getReservedKeywordsClass(); $keywords = new $class(); if (! $keywords instanceof KeywordList) { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } // Store the instance so it doesn't need to be generated on every request. @@ -3621,11 +3621,11 @@ final public function getReservedKeywordsList() * * @return string * - * @throws Exception If not supported on this platform. + * @throws DBALException If not supported on this platform. */ protected function getReservedKeywordsClass() { - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** diff --git a/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/lib/Doctrine/DBAL/Platforms/DB2Platform.php index 3d75866e198..d0d58f9a371 100644 --- a/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\Identifier; use Doctrine\DBAL\Schema\Index; @@ -481,7 +481,7 @@ public function getCurrentTimestampSQL() public function getIndexDeclarationSQL($name, Index $index) { // Index declaration in statements like CREATE TABLE is not supported. - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index 9d2e44cbb8d..e6b97576f2e 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Identifier; use Doctrine\DBAL\Schema\Index; @@ -40,12 +40,12 @@ class OraclePlatform extends AbstractPlatform * * @return void * - * @throws Exception + * @throws DBALException */ public static function assertValidIdentifier($identifier) { if (! preg_match('(^(([a-zA-Z]{1}[a-zA-Z0-9_$#]{0,})|("[^"]+"))$)', $identifier)) { - throw new Exception('Invalid Oracle identifier'); + throw new DBALException('Invalid Oracle identifier'); } } diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php index f7921cbde48..006671bc81e 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ColumnDiff; @@ -691,7 +691,7 @@ public function getGuidTypeDeclarationSQL(array $column) public function getIndexDeclarationSQL($name, Index $index) { // Index declaration in statements like CREATE TABLE is not supported. - throw Exception::notSupported(__METHOD__); + throw DBALException::notSupported(__METHOD__); } /** diff --git a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php index c33970fc142..4e558396508 100644 --- a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Constraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint; @@ -697,7 +697,7 @@ protected function getReservedKeywordsClass() protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) { if (! $diff->fromTable instanceof Table) { - throw new Exception( + throw new DBALException( 'Sqlite platform requires for alter table the table diff with reference to original table schema' ); } @@ -720,7 +720,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) { if (! $diff->fromTable instanceof Table) { - throw new Exception( + throw new DBALException( 'Sqlite platform requires for alter table the table diff with reference to original table schema' ); } @@ -800,7 +800,7 @@ public function supportsForeignKeyConstraints() */ public function getCreatePrimaryKeySQL(Index $index, $table) { - throw new Exception('Sqlite platform does not support alter primary key.'); + throw new DBALException('Sqlite platform does not support alter primary key.'); } /** @@ -808,7 +808,10 @@ public function getCreatePrimaryKeySQL(Index $index, $table) */ public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) { - throw new Exception('Sqlite platform does not support alter foreign key.'); + throw new DBALException( + 'Sqlite platform does not support alter foreign key, ' + . 'the table must be fully recreated using getAlterTableSQL.' + ); } /** @@ -816,7 +819,10 @@ public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) */ public function getDropForeignKeySQL($foreignKey, $table) { - throw new Exception('Sqlite platform does not support alter foreign key.'); + throw new DBALException( + 'Sqlite platform does not support alter foreign key, ' + . 'the table must be fully recreated using getAlterTableSQL.' + ); } /** @@ -824,7 +830,7 @@ public function getDropForeignKeySQL($foreignKey, $table) */ public function getCreateConstraintSQL(Constraint $constraint, $table) { - throw new Exception('Sqlite platform does not support alter constraint.'); + throw new DBALException('Sqlite platform does not support alter constraint.'); } /** @@ -864,7 +870,7 @@ public function getAlterTableSQL(TableDiff $diff) $fromTable = $diff->fromTable; if (! $fromTable instanceof Table) { - throw new Exception( + throw new DBALException( 'Sqlite platform requires for alter table the table diff with reference to original table schema' ); } diff --git a/lib/Doctrine/DBAL/Query/QueryException.php b/lib/Doctrine/DBAL/Query/QueryException.php index 58e941e9843..76bb9ba7559 100644 --- a/lib/Doctrine/DBAL/Query/QueryException.php +++ b/lib/Doctrine/DBAL/Query/QueryException.php @@ -2,14 +2,14 @@ namespace Doctrine\DBAL\Query; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use function implode; /** * @psalm-immutable */ -class QueryException extends Exception +class QueryException extends DBALException { /** * @param string $alias diff --git a/lib/Doctrine/DBAL/SQLParserUtilsException.php b/lib/Doctrine/DBAL/SQLParserUtilsException.php index 297b0761b8d..99cdb8d4a66 100644 --- a/lib/Doctrine/DBAL/SQLParserUtilsException.php +++ b/lib/Doctrine/DBAL/SQLParserUtilsException.php @@ -9,7 +9,7 @@ * * @psalm-immutable */ -class SQLParserUtilsException extends Exception +class SQLParserUtilsException extends DBALException { /** * @param string $paramName diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index 35f2c612780..2bff61a8e90 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -4,10 +4,10 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\ConnectionException; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs; use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs; use Doctrine\DBAL\Events; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Throwable; @@ -776,11 +776,11 @@ protected function _getPortableSequencesList($sequences) * * @return Sequence * - * @throws Exception + * @throws DBALException */ protected function _getPortableSequenceDefinition($sequence) { - throw Exception::notSupported('Sequences'); + throw DBALException::notSupported('Sequences'); } /** diff --git a/lib/Doctrine/DBAL/Schema/SchemaException.php b/lib/Doctrine/DBAL/Schema/SchemaException.php index 64f4b250a8a..6317679de0a 100644 --- a/lib/Doctrine/DBAL/Schema/SchemaException.php +++ b/lib/Doctrine/DBAL/Schema/SchemaException.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Schema; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use function implode; use function sprintf; @@ -10,7 +10,7 @@ /** * @psalm-immutable */ -class SchemaException extends Exception +class SchemaException extends DBALException { public const TABLE_DOESNT_EXIST = 10; public const TABLE_ALREADY_EXISTS = 20; diff --git a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php index de7b1375032..eb85f32c2ed 100644 --- a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -2,8 +2,8 @@ namespace Doctrine\DBAL\Schema; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\Type; @@ -455,7 +455,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) * * @return TableDiff * - * @throws Exception + * @throws DBALException */ private function getTableDiffForAlterForeignKey($table) { @@ -463,7 +463,7 @@ private function getTableDiffForAlterForeignKey($table) $tableDetails = $this->tryMethod('listTableDetails', $table); if ($tableDetails === false) { - throw new Exception( + throw new DBALException( sprintf('Sqlite schema manager requires to modify foreign keys table definition "%s".', $table) ); } diff --git a/lib/Doctrine/DBAL/Schema/Table.php b/lib/Doctrine/DBAL/Schema/Table.php index 909b349107b..4d8b362a0d0 100644 --- a/lib/Doctrine/DBAL/Schema/Table.php +++ b/lib/Doctrine/DBAL/Schema/Table.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Schema; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Types\Type; @@ -51,7 +51,7 @@ class Table extends AbstractAsset * @param int $idGeneratorType * @param mixed[] $options * - * @throws Exception + * @throws DBALException */ public function __construct( $name, @@ -62,7 +62,7 @@ public function __construct( array $options = [] ) { if (strlen($name) === 0) { - throw Exception::invalidTableName($name); + throw DBALException::invalidTableName($name); } $this->_setName($name); @@ -316,11 +316,11 @@ public function addColumn($name, $typeName, array $options = []) * * @return void * - * @throws Exception + * @throws DBALException */ public function renameColumn($oldName, $name) { - throw new Exception('Table#renameColumn() was removed, because it drops and recreates ' . + throw new DBALException('Table#renameColumn() was removed, because it drops and recreates ' . 'the column instead. There is no fix available, because a schema diff cannot reliably detect if a ' . 'column was renamed or one column was created and another one dropped.'); } @@ -727,14 +727,14 @@ public function getPrimaryKey() * * @return string[] * - * @throws Exception + * @throws DBALException */ public function getPrimaryKeyColumns() { $primaryKey = $this->getPrimaryKey(); if ($primaryKey === null) { - throw new Exception('Table ' . $this->getName() . ' has no primary key.'); + throw new DBALException('Table ' . $this->getName() . ' has no primary key.'); } return $primaryKey->getColumns(); diff --git a/lib/Doctrine/DBAL/Sharding/ShardingException.php b/lib/Doctrine/DBAL/Sharding/ShardingException.php index d3363a126cd..2df764a6ff2 100644 --- a/lib/Doctrine/DBAL/Sharding/ShardingException.php +++ b/lib/Doctrine/DBAL/Sharding/ShardingException.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Sharding; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; /** * Sharding related Exceptions @@ -11,7 +11,7 @@ * * @psalm-immutable */ -class ShardingException extends Exception +class ShardingException extends DBALException { /** * @return ShardingException diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index 0e47e09303c..080c48e2061 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -143,7 +143,7 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le * * @return bool TRUE on success, FALSE on failure. * - * @throws Exception + * @throws DBALException */ public function execute($params = null) { @@ -280,7 +280,7 @@ public function fetchColumn($columnIndex = 0) /** * {@inheritdoc} * - * @throws Exception + * @throws DBALException */ public function fetchNumeric() { @@ -298,7 +298,7 @@ public function fetchNumeric() /** * {@inheritdoc} * - * @throws Exception + * @throws DBALException */ public function fetchAssociative() { @@ -316,7 +316,7 @@ public function fetchAssociative() /** * {@inheritDoc} * - * @throws Exception + * @throws DBALException */ public function fetchOne() { @@ -334,7 +334,7 @@ public function fetchOne() /** * {@inheritdoc} * - * @throws Exception + * @throws DBALException */ public function fetchAllNumeric(): array { @@ -352,7 +352,7 @@ public function fetchAllNumeric(): array /** * {@inheritdoc} * - * @throws Exception + * @throws DBALException */ public function fetchAllAssociative(): array { @@ -370,7 +370,7 @@ public function fetchAllAssociative(): array /** * {@inheritdoc} * - * @throws Exception + * @throws DBALException */ public function fetchFirstColumn(): array { @@ -390,7 +390,7 @@ public function fetchFirstColumn(): array * * @return Traversable> * - * @throws Exception + * @throws DBALException */ public function iterateNumeric(): Traversable { @@ -414,7 +414,7 @@ public function iterateNumeric(): Traversable * * @return Traversable> * - * @throws Exception + * @throws DBALException */ public function iterateAssociative(): Traversable { @@ -438,7 +438,7 @@ public function iterateAssociative(): Traversable * * @return Traversable * - * @throws Exception + * @throws DBALException */ public function iterateColumn(): Traversable { diff --git a/lib/Doctrine/DBAL/Types/ConversionException.php b/lib/Doctrine/DBAL/Types/ConversionException.php index 5be4743a5e5..55dfedee754 100644 --- a/lib/Doctrine/DBAL/Types/ConversionException.php +++ b/lib/Doctrine/DBAL/Types/ConversionException.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Types; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Throwable; use function get_class; @@ -19,7 +19,7 @@ * * @psalm-immutable */ -class ConversionException extends Exception +class ConversionException extends DBALException { /** * Thrown when a Database to Doctrine Type Conversion fails. diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php index f75a4905673..b0344062537 100644 --- a/lib/Doctrine/DBAL/Types/Type.php +++ b/lib/Doctrine/DBAL/Types/Type.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Types; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -225,7 +225,7 @@ private static function createTypeRegistry(): TypeRegistry * * @return Type * - * @throws Exception + * @throws DBALException */ public static function getType($name) { @@ -240,7 +240,7 @@ public static function getType($name) * * @return void * - * @throws Exception + * @throws DBALException */ public static function addType($name, $className) { @@ -267,7 +267,7 @@ public static function hasType($name) * * @return void * - * @throws Exception + * @throws DBALException */ public static function overrideType($name, $className) { diff --git a/lib/Doctrine/DBAL/Types/TypeRegistry.php b/lib/Doctrine/DBAL/Types/TypeRegistry.php index fdae6d603c8..4c2e31ecbcf 100644 --- a/lib/Doctrine/DBAL/Types/TypeRegistry.php +++ b/lib/Doctrine/DBAL/Types/TypeRegistry.php @@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Types; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use function array_search; use function in_array; @@ -31,12 +31,12 @@ public function __construct(array $instances = []) /** * Finds a type by the given name. * - * @throws Exception + * @throws DBALException */ public function get(string $name): Type { if (! isset($this->instances[$name])) { - throw Exception::unknownColumnType($name); + throw DBALException::unknownColumnType($name); } return $this->instances[$name]; @@ -45,14 +45,14 @@ public function get(string $name): Type /** * Finds a name for the given type. * - * @throws Exception + * @throws DBALException */ public function lookupName(Type $type): string { $name = $this->findTypeName($type); if ($name === null) { - throw Exception::typeNotRegistered($type); + throw DBALException::typeNotRegistered($type); } return $name; @@ -69,16 +69,16 @@ public function has(string $name): bool /** * Registers a custom type to the type map. * - * @throws Exception + * @throws DBALException */ public function register(string $name, Type $type): void { if (isset($this->instances[$name])) { - throw Exception::typeExists($name); + throw DBALException::typeExists($name); } if ($this->findTypeName($type) !== null) { - throw Exception::typeAlreadyRegistered($type); + throw DBALException::typeAlreadyRegistered($type); } $this->instances[$name] = $type; @@ -87,16 +87,16 @@ public function register(string $name, Type $type): void /** * Overrides an already defined type to use a different implementation. * - * @throws Exception + * @throws DBALException */ public function override(string $name, Type $type): void { if (! isset($this->instances[$name])) { - throw Exception::typeNotFound($name); + throw DBALException::typeNotFound($name); } if (! in_array($this->findTypeName($type), [$name, null], true)) { - throw Exception::typeAlreadyRegistered($type); + throw DBALException::typeAlreadyRegistered($type); } $this->instances[$name] = $type; diff --git a/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php b/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php index 8bdae926442..a4864d0b287 100644 --- a/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php +++ b/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php @@ -22,7 +22,7 @@ interface VersionAwarePlatformDriver * * @return AbstractPlatform * - * @throws Exception If the given version string could not be evaluated. + * @throws DBALException If the given version string could not be evaluated. */ public function createDatabasePlatformForVersion($version); } diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index 8bcf1b817fe..1bbb900f598 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -9,13 +9,13 @@ use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; use Doctrine\DBAL\ConnectionException; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Events; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Logging\DebugStack; @@ -23,6 +23,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\Tests\DbalTestCase; +use Exception; use PHPUnit\Framework\MockObject\MockObject; use stdClass; @@ -182,7 +183,7 @@ public function testEventManagerPassedToPlatform(): void */ public function testDriverExceptionIsWrapped(string $method): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->expectExceptionMessage(<<createMock(Driver::class); - $this->expectException(Exception::class); + $this->expectException(DBALException::class); new Connection($connectionParams, $driver); } @@ -842,8 +843,8 @@ public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnecting $driverMock = $this->createMock(FutureVersionAwarePlatformDriver::class); $connection = new Connection(['dbname' => 'foo'], $driverMock); - $originalException = new \Exception('Original exception'); - $fallbackException = new \Exception('Fallback exception'); + $originalException = new Exception('Original exception'); + $fallbackException = new Exception('Fallback exception'); $driverMock->method('connect') ->will(self::onConsecutiveCalls( diff --git a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php index 5f7f137225d..8fa510e8d0a 100644 --- a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php @@ -2,11 +2,12 @@ namespace Doctrine\Tests\DBAL; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as InnerDriverException; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\DriverException; use Doctrine\Tests\DbalTestCase; +use Exception; use stdClass; use function chr; @@ -18,7 +19,7 @@ class DBALExceptionTest extends DbalTestCase public function testDriverExceptionDuringQueryAcceptsBinaryData(): void { $driver = $this->createMock(Driver::class); - $e = Exception::driverExceptionDuringQuery($driver, new \Exception(), '', ['ABC', chr(128)]); + $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]); self::assertStringContainsString('with params ["ABC", "\x80"]', $e->getMessage()); } @@ -26,9 +27,9 @@ public function testDriverExceptionDuringQueryAcceptsResource(): void { $driver = $this->createMock(Driver::class); - $e = Exception::driverExceptionDuringQuery( + $e = DBALException::driverExceptionDuringQuery( $driver, - new \Exception(), + new Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')] ); @@ -43,16 +44,16 @@ public function testAvoidOverWrappingOnDriverException(): void $inner = $this->createMock(InnerDriverException::class); $ex = new DriverException('', $inner); - $e = Exception::driverExceptionDuringQuery($driver, $ex, ''); + $e = DBALException::driverExceptionDuringQuery($driver, $ex, ''); self::assertSame($ex, $e); } public function testDriverRequiredWithUrl(): void { $url = 'mysql://localhost'; - $exception = Exception::driverRequired($url); + $exception = DBALException::driverRequired($url); - self::assertInstanceOf(Exception::class, $exception); + self::assertInstanceOf(DBALException::class, $exception); self::assertSame( sprintf( "The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme " . @@ -65,7 +66,7 @@ public function testDriverRequiredWithUrl(): void public function testInvalidPlatformTypeObject(): void { - $exception = Exception::invalidPlatformType(new stdClass()); + $exception = DBALException::invalidPlatformType(new stdClass()); self::assertSame( "Option 'platform' must be a subtype of 'Doctrine\DBAL\Platforms\AbstractPlatform', " @@ -76,7 +77,7 @@ public function testInvalidPlatformTypeObject(): void public function testInvalidPlatformTypeScalar(): void { - $exception = Exception::invalidPlatformType('some string'); + $exception = DBALException::invalidPlatformType('some string'); self::assertSame( "Option 'platform' must be an object and subtype of 'Doctrine\DBAL\Platforms\AbstractPlatform'. " diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php index 078875a4086..29a8441f646 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php @@ -3,10 +3,10 @@ namespace Doctrine\Tests\DBAL\Driver; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as DriverExceptionInterface; use Doctrine\DBAL\Driver\ExceptionConverterDriver; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\ConstraintViolationException; use Doctrine\DBAL\Exception\DatabaseObjectExistsException; @@ -138,7 +138,7 @@ public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion( $this->markTestSkipped('This test is only intended for version aware platform drivers.'); } - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->driver->createDatabasePlatformForVersion('foo'); } diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php index e6544de56f5..03117de7f32 100644 --- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php @@ -4,13 +4,13 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySqlDriver; use Doctrine\DBAL\Driver\PDO\MySQL\Driver as PDOMySQLDriver; use Doctrine\DBAL\Driver\PDO\SQLite\Driver as PDOSQLiteDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Sharding\PoolingShardConnection; use Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser; @@ -30,7 +30,7 @@ class DriverManagerTest extends DbalTestCase */ public function testInvalidPdoInstance(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); DriverManager::getConnection(['pdo' => 'test']); } @@ -61,14 +61,14 @@ public function testPdoInstanceSetErrorMode(): void public function testCheckParams(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); DriverManager::getConnection([]); } public function testInvalidDriver(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); DriverManager::getConnection(['driver' => 'invalid_driver']); } @@ -111,7 +111,7 @@ public function testCustomWrapper(): void */ public function testInvalidWrapperClass(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $options = [ 'pdo' => new PDO('sqlite::memory:'), @@ -123,7 +123,7 @@ public function testInvalidWrapperClass(): void public function testInvalidDriverClass(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $options = ['driverClass' => stdClass::class]; @@ -227,7 +227,7 @@ public function testDatabaseUrl($url, $expected): void $options = is_array($url) ? $url : ['url' => $url]; if ($expected === false) { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); } $conn = DriverManager::getConnection($options); diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index ef68b5be62f..6984f7a471d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -4,13 +4,13 @@ use DateTime; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\IBMDB2\Driver as IBMDB2Driver; use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver; use Doctrine\DBAL\Driver\OCI8\Driver as Oci8Driver; use Doctrine\DBAL\Driver\PDO\Connection as PDOConnection; use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\SqlitePlatform; @@ -267,7 +267,7 @@ public function testFetchAllWithMissingTypes(callable $fetch): void $datetime = new DateTime($datetimeString); $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?'; - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $fetch($this->connection, $sql, [1, $datetime]); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php index d94a8f8dabe..53914d48c6d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -2,8 +2,8 @@ namespace Doctrine\Tests\DBAL\Functional\Schema; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\Connection; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\BlobType; @@ -19,7 +19,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase */ public function testListDatabases(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->schemaManager->listDatabases(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php index 77cd108b595..0abb50bdf92 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php @@ -2,8 +2,8 @@ namespace Doctrine\Tests\DBAL\Functional\Ticket; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\PDO\Connection; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\ParameterType; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; @@ -28,7 +28,7 @@ protected function setUp(): void try { $this->connection->exec('CREATE TABLE dbal630 (id SERIAL, bool_col BOOLEAN NOT NULL);'); $this->connection->exec('CREATE TABLE dbal630_allow_nulls (id SERIAL, bool_col BOOLEAN);'); - } catch (Exception $e) { + } catch (DBALException $e) { } $this->running = true; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php index ca17b35dbac..5e90a8e3c50 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php @@ -3,8 +3,8 @@ namespace Doctrine\Tests\DBAL\Platforms; use Doctrine\Common\EventManager; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Events; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\Keywords\KeywordList; use Doctrine\DBAL\Schema\Column; @@ -90,7 +90,7 @@ public function testGetInvalidForeignKeyReferentialActionSQL(): void public function testGetUnknownDoctrineMappingType(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->platform->getDoctrineTypeMapping('foobar'); } @@ -102,7 +102,7 @@ public function testRegisterDoctrineMappingType(): void public function testRegisterUnknownDoctrineMappingType(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->platform->registerDoctrineTypeMapping('foo', 'bar'); } @@ -151,7 +151,7 @@ public function testCreateWithNoColumns(): void { $table = new Table('test'); - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $sql = $this->platform->getCreateTableSQL($table); } @@ -732,7 +732,7 @@ public function testQuotesReservedKeywordInIndexDeclarationSQL(): void $index = new Index('select', ['foo']); if (! $this->supportsInlineIndexDeclaration()) { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); } self::assertSame( @@ -760,7 +760,7 @@ protected function supportsCommentOnStatement(): bool public function testGetCreateSchemaSQL(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->platform->getCreateSchemaSQL('schema'); } @@ -791,7 +791,7 @@ public function testUsesSequenceEmulatedIdentityColumns(): void public function testReturnsIdentitySequenceName(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->platform->getIdentitySequenceName('mytable', 'mycolumn'); } @@ -818,7 +818,7 @@ protected function getBinaryMaxLength(): int public function testReturnsBinaryTypeDeclarationSQL(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->platform->getBinaryTypeDeclarationSQL([]); } @@ -1226,7 +1226,7 @@ public function testThrowsExceptionOnGeneratingInlineColumnCommentSQLIfUnsupport $this->markTestSkipped(sprintf('%s supports inline column comments.', get_class($this->platform))); } - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->expectExceptionMessage( "Operation '" . AbstractPlatform::class . "::getInlineColumnCommentSQL' is not supported by platform." ); @@ -1255,7 +1255,7 @@ public function testQuoteStringLiteral(): void public function testReturnsGuidTypeDeclarationSQL(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->platform->getGuidTypeDeclarationSQL([]); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php index ddb7df84a00..6c166ac2dff 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Platforms; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ColumnDiff; @@ -61,7 +61,7 @@ public function getGenerateAlterTableSql(): array public function testDoesNotSupportRegexp(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->platform->getRegexpExpression(); } @@ -469,6 +469,9 @@ public function testModifyLimitQueryWithAggregateFunctionInOrderByClause(): void $this->expectCteWithMaxRowNum($alteredSql, 1, $sql); } + /** + * @throws DBALException + */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' @@ -490,6 +493,9 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBas $this->expectCteWithMaxRowNum($alteredSql, 5, $sql); } + /** + * @throws DBALException + */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' @@ -511,6 +517,9 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoi $this->expectCteWithMaxRowNum($alteredSql, 5, $sql); } + /** + * @throws DBALException + */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables(): void { $querySql = 'SELECT DISTINCT id_0, name_1, foo_2 ' diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php index 333a6e26bae..22e02ee405d 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Platforms; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Schema\Column; @@ -74,7 +74,7 @@ public static function dataInvalidIdentifiers(): iterable */ public function testInvalidIdentifiers(string $identifier): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $platform = $this->createPlatform(); $platform->assertValidIdentifier($identifier); @@ -120,7 +120,7 @@ public function getGenerateAlterTableSql(): array public function testRLike(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); self::assertEquals('RLIKE', $this->platform->getRegexpExpression()); } @@ -156,7 +156,7 @@ public function testGeneratesTransactionsCommands(): void public function testCreateDatabaseThrowsException(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php index 5f3bd50e2ac..6e0ae423063 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Platforms; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SQLAnywherePlatform; @@ -522,7 +522,7 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(): void public function testDoesNotSupportIndexDeclarationInCreateAlterTableStatements(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->platform->getIndexDeclarationSQL('index', new Index('index', [])); } @@ -712,7 +712,7 @@ public function testGeneratesSQLSnippets(): void public function testDoesNotSupportRegexp(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->platform->getRegexpExpression(); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php index 1c21098b678..47fe7ec69b3 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\DBAL\Platforms; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SQLServer2012Platform; use Doctrine\DBAL\Schema\Sequence; @@ -369,6 +370,9 @@ public function testModifyLimitQueryWithComplexOrderByExpression(): void self::assertEquals($sql, $expected); } + /** + * @throws DBALException + */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' @@ -389,6 +393,9 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBas self::assertEquals($alteredSql, $sql); } + /** + * @throws DBALException + */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' @@ -409,6 +416,9 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoi self::assertEquals($alteredSql, $sql); } + /** + * @throws DBALException + */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables(): void { $querySql = 'SELECT DISTINCT id_0, name_1, foo_2 ' diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php index 1bf0fd63ef5..83e25717ed6 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Platforms; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\Column; @@ -256,14 +256,14 @@ public function getGenerateUniqueIndexSql(): string public function testGeneratesForeignKeyCreationSql(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); parent::testGeneratesForeignKeyCreationSql(); } public function testGeneratesConstraintCreationSql(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); parent::testGeneratesConstraintCreationSql(); } @@ -345,7 +345,7 @@ public function testAlterTableAddColumns(): void */ public function testAlterTableAddComplexColumns(TableDiff $diff): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->platform->getAlterTableSQL($diff); } diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php index c596fecfc9c..25a50ba999e 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Schema; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\Column; @@ -20,7 +20,7 @@ class TableTest extends DbalTestCase { public function testCreateWithInvalidTableName(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); new Table(''); } diff --git a/tests/Doctrine/Tests/DBAL/StatementTest.php b/tests/Doctrine/Tests/DBAL/StatementTest.php index e40c0d15378..5cacf902cc6 100644 --- a/tests/Doctrine/Tests/DBAL/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/StatementTest.php @@ -4,14 +4,15 @@ use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Connection as DriverConnection; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Logging\SQLLogger; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Statement; use Doctrine\Tests\DbalTestCase; +use Exception; use PDOStatement; use PHPUnit\Framework\MockObject\MockObject; @@ -132,7 +133,7 @@ public function testExecuteCallsLoggerStopQueryOnException(): void $this->conn->expects($this->any()) ->method('handleExceptionDuringQuery') - ->will($this->throwException(new Exception())); + ->will($this->throwException(new DBALException())); $logger->expects($this->once()) ->method('startQuery'); @@ -142,11 +143,11 @@ public function testExecuteCallsLoggerStopQueryOnException(): void $this->pdoStatement->expects($this->once()) ->method('execute') - ->will($this->throwException(new \Exception('Mock test exception'))); + ->will($this->throwException(new Exception('Mock test exception'))); $statement = new Statement('', $this->conn); - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $statement->execute(); } diff --git a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php index 1cd7dca4fe1..98b0fd99a40 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php @@ -4,7 +4,7 @@ namespace Doctrine\Tests\DBAL\Types; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Types\BinaryType; use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\StringType; @@ -42,7 +42,7 @@ public function testGet(): void self::assertSame($this->testType, $this->registry->get(self::TEST_TYPE_NAME)); self::assertSame($this->otherTestType, $this->registry->get(self::OTHER_TEST_TYPE_NAME)); - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->registry->get('unknown'); } @@ -65,7 +65,7 @@ public function testLookupName(): void $this->registry->lookupName($this->otherTestType) ); - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->registry->lookupName(new TextType()); } @@ -90,7 +90,7 @@ public function testRegisterWithAlradyRegisteredName(): void { $this->registry->register('some', new TextType()); - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->registry->register('some', new TextType()); } @@ -100,7 +100,7 @@ public function testRegisterWithAlreadyRegisteredInstance(): void $this->registry->register('some', $newType); - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->registry->register('other', $newType); } @@ -132,13 +132,13 @@ public function testOverrideWithAlreadyRegisteredInstance(): void $this->registry->register('first', $newType); $this->registry->register('second', new StringType()); - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->registry->override('second', $newType); } public function testOverrideWithUnknownType(): void { - $this->expectException(Exception::class); + $this->expectException(DBALException::class); $this->registry->override('unknown', new TextType()); }