Skip to content

Commit d41b097

Browse files
committed
Rename driver classes
1 parent f7e8b5f commit d41b097

File tree

103 files changed

+4378
-4093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+4378
-4093
lines changed

UPGRADE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Upgrade to 2.11
22

3+
## Driver-level classes have been renamed
4+
5+
- `DriverException` => `Exception`
6+
- `AbstractDriverException` => `AbstractException`
7+
- `IBMDB2\DB2Driver` => `IBMDB2\Driver`
8+
- `IBMDB2\DB2Connection` => `IBMDB2\Connection`
9+
- `IBMDB2\DB2Statement` => `IBMDB2\Statement`
10+
- `IBMDB2\DB2Exception` => `IBMDB2\Exception`
11+
- `Mysqli\MysqliConnection` => `Mysqli\Connection`
12+
- `Mysqli\MysqliStatement` => `Mysqli\Statement`
13+
- `Mysqli\MysqliException` => `Mysqli\Exception`
14+
- `OCI8\OCI8Connection` => `OCI8\Connection`
15+
- `OCI8\OCI8Statement` => `OCI8\Statement`
16+
- `OCI8\OCI8Exception` => `OCI8\Exception`
17+
- `SQLSrv\SQLSrvConnection` => `SQLSrv\Connection`
18+
- `SQLSrv\SQLSrvStatement` => `SQLSrv\Statement`
19+
- `SQLSrv\SQLSrvException` => `SQLSrv\Exception`
20+
- `PDOConnection` => `PDO\Connection`
21+
- `PDOStatement` => `PDO\Statement`
22+
- `PDOException` => `PDO\Exception`
23+
24+
The `Driver\AbstractException` class has been marked internal.
25+
326
## `Connection::getParams()` has been marked internal
427

528
Consumers of the Connection class should not rely on connection parameters stored in the connection object. If needed, they should be obtained from a different source, e.g. application configuration.

lib/Doctrine/DBAL/Cache/ResultCacheStatement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use ArrayIterator;
66
use Doctrine\Common\Cache\Cache;
7-
use Doctrine\DBAL\Driver\DriverException;
7+
use Doctrine\DBAL\Driver\Exception;
88
use Doctrine\DBAL\Driver\FetchUtils;
99
use Doctrine\DBAL\Driver\Result;
1010
use Doctrine\DBAL\Driver\ResultStatement;
@@ -297,7 +297,7 @@ public function free(): void
297297
/**
298298
* @return array<string,mixed>|false
299299
*
300-
* @throws DriverException
300+
* @throws Exception
301301
*/
302302
private function doFetch()
303303
{

lib/Doctrine/DBAL/DBALException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Doctrine\DBAL;
44

5-
use Doctrine\DBAL\Driver\DriverException as DriverExceptionInterface;
5+
use Doctrine\DBAL\Driver\Exception as DriverExceptionInterface;
66
use Doctrine\DBAL\Driver\ExceptionConverterDriver;
77
use Doctrine\DBAL\Exception\DriverException;
88
use Doctrine\DBAL\Platforms\AbstractPlatform;

lib/Doctrine/DBAL/Driver/AbstractDriverException.php

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,11 @@
22

33
namespace Doctrine\DBAL\Driver;
44

5-
use Exception;
6-
75
/**
8-
* Abstract base implementation of the {@link DriverException} interface.
6+
* @deprecated
97
*
108
* @psalm-immutable
119
*/
12-
abstract class AbstractDriverException extends Exception implements DriverException
10+
class AbstractDriverException extends AbstractException
1311
{
14-
/**
15-
* The driver specific error code.
16-
*
17-
* @var int|string|null
18-
*/
19-
private $errorCode;
20-
21-
/**
22-
* The SQLSTATE of the driver.
23-
*
24-
* @var string|null
25-
*/
26-
private $sqlState;
27-
28-
/**
29-
* @param string $message The driver error message.
30-
* @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any.
31-
* @param int|string|null $errorCode The driver specific error code if any.
32-
*/
33-
public function __construct($message, $sqlState = null, $errorCode = null)
34-
{
35-
parent::__construct($message);
36-
37-
$this->errorCode = $errorCode;
38-
$this->sqlState = $sqlState;
39-
}
40-
41-
/**
42-
* {@inheritdoc}
43-
*/
44-
public function getErrorCode()
45-
{
46-
return $this->errorCode;
47-
}
48-
49-
/**
50-
* {@inheritdoc}
51-
*/
52-
public function getSQLState()
53-
{
54-
return $this->sqlState;
55-
}
5612
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace Doctrine\DBAL\Driver;
4+
5+
use Doctrine\DBAL\Driver\Exception as ExceptionInterface;
6+
use Exception as BaseException;
7+
8+
/**
9+
* Base implementation of the {@link Exception} interface.
10+
*
11+
* @internal
12+
*
13+
* @psalm-immutable
14+
*/
15+
abstract class AbstractException extends BaseException implements ExceptionInterface
16+
{
17+
/**
18+
* The driver specific error code.
19+
*
20+
* @var int|string|null
21+
*/
22+
private $errorCode;
23+
24+
/**
25+
* The SQLSTATE of the driver.
26+
*
27+
* @var string|null
28+
*/
29+
private $sqlState;
30+
31+
/**
32+
* @param string $message The driver error message.
33+
* @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any.
34+
* @param int|string|null $errorCode The driver specific error code if any.
35+
*/
36+
public function __construct($message, $sqlState = null, $errorCode = null)
37+
{
38+
parent::__construct($message);
39+
40+
$this->errorCode = $errorCode;
41+
$this->sqlState = $sqlState;
42+
}
43+
44+
/**
45+
* {@inheritdoc}
46+
*/
47+
public function getErrorCode()
48+
{
49+
return $this->errorCode;
50+
}
51+
52+
/**
53+
* {@inheritdoc}
54+
*/
55+
public function getSQLState()
56+
{
57+
return $this->sqlState;
58+
}
59+
}

lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@
55
use Doctrine\DBAL\Connection;
66
use Doctrine\DBAL\DBALException;
77
use Doctrine\DBAL\Driver;
8-
use Doctrine\DBAL\Exception;
8+
use Doctrine\DBAL\Exception\ConnectionException;
9+
use Doctrine\DBAL\Exception\DeadlockException;
10+
use Doctrine\DBAL\Exception\DriverException;
11+
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
12+
use Doctrine\DBAL\Exception\InvalidFieldNameException;
13+
use Doctrine\DBAL\Exception\LockWaitTimeoutException;
14+
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
15+
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
16+
use Doctrine\DBAL\Exception\SyntaxErrorException;
17+
use Doctrine\DBAL\Exception\TableExistsException;
18+
use Doctrine\DBAL\Exception\TableNotFoundException;
19+
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
920
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
1021
use Doctrine\DBAL\Platforms\MySQL57Platform;
1122
use Doctrine\DBAL\Platforms\MySQL80Platform;
@@ -29,44 +40,44 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
2940
* @link https://dev.mysql.com/doc/refman/8.0/en/client-error-reference.html
3041
* @link https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html
3142
*/
32-
public function convertException($message, DriverException $exception)
43+
public function convertException($message, Exception $exception)
3344
{
3445
switch ($exception->getErrorCode()) {
3546
case '1213':
36-
return new Exception\DeadlockException($message, $exception);
47+
return new DeadlockException($message, $exception);
3748

3849
case '1205':
39-
return new Exception\LockWaitTimeoutException($message, $exception);
50+
return new LockWaitTimeoutException($message, $exception);
4051

4152
case '1050':
42-
return new Exception\TableExistsException($message, $exception);
53+
return new TableExistsException($message, $exception);
4354

4455
case '1051':
4556
case '1146':
46-
return new Exception\TableNotFoundException($message, $exception);
57+
return new TableNotFoundException($message, $exception);
4758

4859
case '1216':
4960
case '1217':
5061
case '1451':
5162
case '1452':
5263
case '1701':
53-
return new Exception\ForeignKeyConstraintViolationException($message, $exception);
64+
return new ForeignKeyConstraintViolationException($message, $exception);
5465

5566
case '1062':
5667
case '1557':
5768
case '1569':
5869
case '1586':
59-
return new Exception\UniqueConstraintViolationException($message, $exception);
70+
return new UniqueConstraintViolationException($message, $exception);
6071

6172
case '1054':
6273
case '1166':
6374
case '1611':
64-
return new Exception\InvalidFieldNameException($message, $exception);
75+
return new InvalidFieldNameException($message, $exception);
6576

6677
case '1052':
6778
case '1060':
6879
case '1110':
69-
return new Exception\NonUniqueFieldNameException($message, $exception);
80+
return new NonUniqueFieldNameException($message, $exception);
7081

7182
case '1064':
7283
case '1149':
@@ -80,7 +91,7 @@ public function convertException($message, DriverException $exception)
8091
case '1541':
8192
case '1554':
8293
case '1626':
83-
return new Exception\SyntaxErrorException($message, $exception);
94+
return new SyntaxErrorException($message, $exception);
8495

8596
case '1044':
8697
case '1045':
@@ -94,7 +105,7 @@ public function convertException($message, DriverException $exception)
94105
case '1429':
95106
case '2002':
96107
case '2005':
97-
return new Exception\ConnectionException($message, $exception);
108+
return new ConnectionException($message, $exception);
98109

99110
case '1048':
100111
case '1121':
@@ -104,10 +115,10 @@ public function convertException($message, DriverException $exception)
104115
case '1263':
105116
case '1364':
106117
case '1566':
107-
return new Exception\NotNullConstraintViolationException($message, $exception);
118+
return new NotNullConstraintViolationException($message, $exception);
108119
}
109120

110-
return new Exception\DriverException($message, $exception);
121+
return new DriverException($message, $exception);
111122
}
112123

113124
/**

lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@
55
use Doctrine\DBAL\Connection;
66
use Doctrine\DBAL\Driver;
77
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
8-
use Doctrine\DBAL\Exception;
8+
use Doctrine\DBAL\Exception\ConnectionException;
9+
use Doctrine\DBAL\Exception\DriverException;
10+
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
11+
use Doctrine\DBAL\Exception\InvalidFieldNameException;
12+
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
13+
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
14+
use Doctrine\DBAL\Exception\SyntaxErrorException;
15+
use Doctrine\DBAL\Exception\TableExistsException;
16+
use Doctrine\DBAL\Exception\TableNotFoundException;
17+
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
918
use Doctrine\DBAL\Platforms\OraclePlatform;
1019
use Doctrine\DBAL\Schema\OracleSchemaManager;
1120

@@ -17,44 +26,44 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
1726
/**
1827
* {@inheritdoc}
1928
*/
20-
public function convertException($message, DriverException $exception)
29+
public function convertException($message, Exception $exception)
2130
{
2231
switch ($exception->getErrorCode()) {
2332
case '1':
2433
case '2299':
2534
case '38911':
26-
return new Exception\UniqueConstraintViolationException($message, $exception);
35+
return new UniqueConstraintViolationException($message, $exception);
2736

2837
case '904':
29-
return new Exception\InvalidFieldNameException($message, $exception);
38+
return new InvalidFieldNameException($message, $exception);
3039

3140
case '918':
3241
case '960':
33-
return new Exception\NonUniqueFieldNameException($message, $exception);
42+
return new NonUniqueFieldNameException($message, $exception);
3443

3544
case '923':
36-
return new Exception\SyntaxErrorException($message, $exception);
45+
return new SyntaxErrorException($message, $exception);
3746

3847
case '942':
39-
return new Exception\TableNotFoundException($message, $exception);
48+
return new TableNotFoundException($message, $exception);
4049

4150
case '955':
42-
return new Exception\TableExistsException($message, $exception);
51+
return new TableExistsException($message, $exception);
4352

4453
case '1017':
4554
case '12545':
46-
return new Exception\ConnectionException($message, $exception);
55+
return new ConnectionException($message, $exception);
4756

4857
case '1400':
49-
return new Exception\NotNullConstraintViolationException($message, $exception);
58+
return new NotNullConstraintViolationException($message, $exception);
5059

5160
case '2266':
5261
case '2291':
5362
case '2292':
54-
return new Exception\ForeignKeyConstraintViolationException($message, $exception);
63+
return new ForeignKeyConstraintViolationException($message, $exception);
5564
}
5665

57-
return new Exception\DriverException($message, $exception);
66+
return new DriverException($message, $exception);
5867
}
5968

6069
/**

0 commit comments

Comments
 (0)