Skip to content

Commit b42a9bb

Browse files
Use AbstractDriverMiddleware class instead implementing the interface (#810)
Co-authored-by: Stefano Arlandini <[email protected]>
1 parent fe4480a commit b42a9bb

File tree

2 files changed

+7
-57
lines changed

2 files changed

+7
-57
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"symfony/security-http": "^4.4.20||^5.0.11||^6.0||^7.0"
4242
},
4343
"require-dev": {
44-
"doctrine/dbal": "^2.13||^3.0",
44+
"doctrine/dbal": "^2.13||^3.3",
4545
"doctrine/doctrine-bundle": "^2.6",
4646
"friendsofphp/php-cs-fixer": "^2.19||^3.40",
4747
"masterminds/html5": "^2.8",

src/Tracing/Doctrine/DBAL/TracingDriverForV3.php

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44

55
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL;
66

7-
use Doctrine\DBAL\Connection;
87
use Doctrine\DBAL\Driver;
9-
use Doctrine\DBAL\Driver\API\ExceptionConverter;
10-
use Doctrine\DBAL\Platforms\AbstractPlatform;
11-
use Doctrine\DBAL\Schema\AbstractSchemaManager;
12-
use Doctrine\DBAL\VersionAwarePlatformDriver;
8+
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
139

1410
/**
1511
* This is a simple implementation of the {@see Driver} interface that decorates
@@ -20,18 +16,13 @@
2016
*
2117
* @phpstan-import-type Params from \Doctrine\DBAL\DriverManager as ConnectionParams
2218
*/
23-
final class TracingDriverForV3 implements Driver, VersionAwarePlatformDriver
19+
final class TracingDriverForV3 extends AbstractDriverMiddleware
2420
{
2521
/**
2622
* @var TracingDriverConnectionFactoryInterface The connection factory
2723
*/
2824
private $connectionFactory;
2925

30-
/**
31-
* @var Driver|VersionAwarePlatformDriver The instance of the decorated driver
32-
*/
33-
private $decoratedDriver;
34-
3526
/**
3627
* Constructor.
3728
*
@@ -40,8 +31,9 @@ final class TracingDriverForV3 implements Driver, VersionAwarePlatformDriver
4031
*/
4132
public function __construct(TracingDriverConnectionFactoryInterface $connectionFactory, Driver $decoratedDriver)
4233
{
34+
parent::__construct($decoratedDriver);
35+
4336
$this->connectionFactory = $connectionFactory;
44-
$this->decoratedDriver = $decoratedDriver;
4537
}
4638

4739
/**
@@ -52,51 +44,9 @@ public function __construct(TracingDriverConnectionFactoryInterface $connectionF
5244
public function connect(array $params): TracingDriverConnectionInterface
5345
{
5446
return $this->connectionFactory->create(
55-
$this->decoratedDriver->connect($params),
56-
$this->decoratedDriver->getDatabasePlatform(),
47+
parent::connect($params),
48+
$this->getDatabasePlatform(),
5749
$params
5850
);
5951
}
60-
61-
/**
62-
* {@inheritdoc}
63-
*/
64-
public function getDatabasePlatform(): AbstractPlatform
65-
{
66-
return $this->decoratedDriver->getDatabasePlatform();
67-
}
68-
69-
/**
70-
* {@inheritdoc}
71-
*
72-
* @phpstan-template T of AbstractPlatform
73-
*
74-
* @phpstan-param T $platform
75-
*
76-
* @phpstan-return AbstractSchemaManager<T>
77-
*/
78-
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager
79-
{
80-
return $this->decoratedDriver->getSchemaManager($conn, $platform);
81-
}
82-
83-
/**
84-
* {@inheritdoc}
85-
*/
86-
public function getExceptionConverter(): ExceptionConverter
87-
{
88-
return $this->decoratedDriver->getExceptionConverter();
89-
}
90-
91-
/**
92-
* {@inheritdoc}
93-
*/
94-
public function createDatabasePlatformForVersion($version): AbstractPlatform
95-
{
96-
if ($this->decoratedDriver instanceof VersionAwarePlatformDriver) {
97-
return $this->decoratedDriver->createDatabasePlatformForVersion($version);
98-
}
99-
100-
return $this->getDatabasePlatform();
101-
}
10252
}

0 commit comments

Comments
 (0)