Skip to content

Commit

Permalink
Relax return types of getExceptionConverter() implementations (doctri…
Browse files Browse the repository at this point in the history
…ne#6221)

|      Q       |   A
|------------- | -----------
| Type         | improvement
| Fixed issues | N/A

#### Summary

This takes back a change I made with doctrine#4926. If I want to implement a new
let's say MySQL driver that uses a custom exception converter, I'm
forced to extend the MySQL exception converter which feels too
restrictive.

Background: I maintain a custom ODBC driver for DBAL and since ODBC has
its own error codes, the MySQL exception converter is useless for me in
that context.
  • Loading branch information
derrabus committed Nov 14, 2023
1 parent 9adbeca commit 8861620
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Driver/AbstractDB2Driver.php
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\IBMDB2\ExceptionConverter;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\ServerVersionProvider;
Expand All @@ -19,7 +20,7 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): DB2
return new DB2Platform();
}

public function getExceptionConverter(): ExceptionConverter
public function getExceptionConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
Expand Down
3 changes: 2 additions & 1 deletion src/Driver/AbstractMySQLDriver.php
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion;
Expand Down Expand Up @@ -52,7 +53,7 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Abs
return new MySQLPlatform();
}

public function getExceptionConverter(): ExceptionConverter
public function getExceptionConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
Expand Down
3 changes: 2 additions & 1 deletion src/Driver/AbstractOracleDriver.php
Expand Up @@ -6,6 +6,7 @@

use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\OCI\ExceptionConverter;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\ServerVersionProvider;
Expand All @@ -20,7 +21,7 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Ora
return new OraclePlatform();
}

public function getExceptionConverter(): ExceptionConverter
public function getExceptionConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
Expand Down
3 changes: 2 additions & 1 deletion src/Driver/AbstractPostgreSQLDriver.php
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\PostgreSQL\ExceptionConverter;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\ServerVersionProvider;
Expand All @@ -19,7 +20,7 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Pos
return new PostgreSQLPlatform();
}

public function getExceptionConverter(): ExceptionConverter
public function getExceptionConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
Expand Down
3 changes: 2 additions & 1 deletion src/Driver/AbstractSQLServerDriver.php
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\SQLSrv\ExceptionConverter;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\ServerVersionProvider;
Expand All @@ -19,7 +20,7 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): SQL
return new SQLServerPlatform();
}

public function getExceptionConverter(): ExceptionConverter
public function getExceptionConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
Expand Down
3 changes: 2 additions & 1 deletion src/Driver/AbstractSQLiteDriver.php
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\DBAL\Driver;

use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\SQLite\ExceptionConverter;
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Doctrine\DBAL\ServerVersionProvider;
Expand All @@ -19,7 +20,7 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): SQL
return new SQLitePlatform();
}

public function getExceptionConverter(): ExceptionConverter
public function getExceptionConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
Expand Down

0 comments on commit 8861620

Please sign in to comment.