Skip to content

Commit 6485a3e

Browse files
committed
Remove Driver and Middleware aliases
1 parent f78f283 commit 6485a3e

File tree

7 files changed

+18
-73
lines changed

7 files changed

+18
-73
lines changed

src/Tracing/Doctrine/DBAL/Compatibility/DriverInterface.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Tracing/Doctrine/DBAL/Compatibility/ExceptionConverterDriverInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility;
66

77
/**
8+
* TODO: can we remove this? We will need tests from #517 to check.
9+
*
810
* @internal
911
*/
1012
interface ExceptionConverterDriverInterface

src/Tracing/Doctrine/DBAL/Compatibility/MiddlewareInterface.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Tracing/Doctrine/DBAL/TracingDriver.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL;
66

77
use Doctrine\DBAL\Connection;
8-
use Doctrine\DBAL\Driver\API\ExceptionConverter;
9-
use Doctrine\DBAL\Driver as DriverInterface;
8+
use Doctrine\DBAL\Driver as DBALDriver;
109
use Doctrine\DBAL\Driver\DriverException as LegacyDriverExceptionInterface;
1110
use Doctrine\DBAL\Driver\ExceptionConverterDriver as ExceptionConverterDriverInterface;
1211
use Doctrine\DBAL\Driver\ResultStatement;
@@ -16,32 +15,30 @@
1615
use Sentry\State\HubInterface;
1716

1817
/**
19-
* This is a simple implementation of the {@see DriverInterface} interface that
18+
* This is a simple implementation of the {@see DBALDriver} interface that
2019
* decorates an existing driver to support distributed tracing capabilities.
21-
* This implementation IS and MUST be compatible with all versions of Doctrine
22-
* DBAL >= 2.10.
20+
* This implementation IS cross-compatible with both DBAL 2 and 3 thanks to
21+
* the FC layer provided since DBAL 2.13.
2322
*
2423
* @internal
2524
*/
26-
final class TracingDriver implements DriverInterface, VersionAwarePlatformDriverInterface, ExceptionConverterDriverInterface
25+
final class TracingDriver implements DBALDriver, VersionAwarePlatformDriverInterface, ExceptionConverterDriverInterface
2726
{
2827
/**
2928
* @var HubInterface The current hub
3029
*/
3130
private $hub;
3231

3332
/**
34-
* @var DriverInterface|VersionAwarePlatformDriverInterface|ExceptionConverterDriverInterface The instance of the decorated driver
33+
* @var DBALDriver|VersionAwarePlatformDriverInterface|ExceptionConverterDriverInterface The instance of the decorated driver
3534
*/
3635
private $decoratedDriver;
3736

3837
/**
39-
* Constructor.
40-
*
41-
* @param HubInterface $hub The current hub
42-
* @param DriverInterface $decoratedDriver The instance of the driver to decorate
38+
* @param HubInterface $hub The current hub
39+
* @param DBALDriver $decoratedDriver The instance of the driver to decorate
4340
*/
44-
public function __construct(HubInterface $hub, DriverInterface $decoratedDriver)
41+
public function __construct(HubInterface $hub, DBALDriver $decoratedDriver)
4542
{
4643
$this->hub = $hub;
4744
$this->decoratedDriver = $decoratedDriver;

src/Tracing/Doctrine/DBAL/TracingDriverMiddleware.php

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

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

7-
use Doctrine\DBAL\Driver as DriverInterface;
8-
use Doctrine\DBAL\Driver\Middleware as MiddlewareInterface;
7+
use Doctrine\DBAL\Driver;
8+
use Doctrine\DBAL\Driver\Middleware;
99
use Sentry\State\HubInterface;
1010

1111
/**
12-
* This middleware wraps a {@see DriverInterface} instance into one that
12+
* This middleware wraps a {@see Driver} instance into one that
1313
* supports the distributed tracing feature of Sentry.
1414
*/
15-
final class TracingDriverMiddleware implements MiddlewareInterface
15+
final class TracingDriverMiddleware implements Middleware
1616
{
1717
/**
1818
* @var HubInterface The current hub
@@ -32,7 +32,7 @@ public function __construct(HubInterface $hub)
3232
/**
3333
* {@inheritdoc}
3434
*/
35-
public function wrap(DriverInterface $driver): DriverInterface
35+
public function wrap(Driver $driver): Driver
3636
{
3737
return new TracingDriver($this->hub, $driver);
3838
}

src/aliases.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,14 @@
44

55
namespace Sentry\SentryBundle;
66

7-
use Doctrine\DBAL\Driver as DoctrineDriverInterface;
8-
use Doctrine\DBAL\Driver\DriverException as LegacyDriverExceptionInterface;
9-
use Doctrine\DBAL\Driver\Exception as DriverExceptionInterface;
107
use Doctrine\DBAL\Driver\ExceptionConverterDriver as LegacyExceptionConverterDriverInterface;
11-
use Doctrine\DBAL\Driver\Middleware as DoctrineMiddlewareInterface;
12-
use Doctrine\DBAL\Driver\Result;
13-
use Doctrine\DBAL\Driver\Statement;
148
use Sentry\SentryBundle\EventListener\ErrorListenerExceptionEvent;
159
use Sentry\SentryBundle\EventListener\RequestListenerControllerEvent;
1610
use Sentry\SentryBundle\EventListener\RequestListenerRequestEvent;
1711
use Sentry\SentryBundle\EventListener\RequestListenerResponseEvent;
1812
use Sentry\SentryBundle\EventListener\RequestListenerTerminateEvent;
1913
use Sentry\SentryBundle\EventListener\SubRequestListenerRequestEvent;
20-
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\DriverInterface;
2114
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\ExceptionConverterDriverInterface;
22-
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\MiddlewareInterface;
2315
use Symfony\Component\HttpKernel\Event\ControllerEvent;
2416
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
2517
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
@@ -94,26 +86,6 @@ class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class);
9486
}
9587
}
9688

97-
if (interface_exists(Statement::class) && !interface_exists(Result::class)) {
98-
/** @psalm-suppress UndefinedClass */
99-
class_alias(Statement::class, Result::class);
100-
}
101-
102-
if (interface_exists(DriverExceptionInterface::class) && !interface_exists(LegacyDriverExceptionInterface::class)) {
103-
/** @psalm-suppress UndefinedClass */
104-
class_alias(DriverExceptionInterface::class, LegacyDriverExceptionInterface::class);
105-
}
106-
107-
if (!interface_exists(DoctrineMiddlewareInterface::class)) {
108-
/** @psalm-suppress UndefinedClass */
109-
class_alias(MiddlewareInterface::class, DoctrineMiddlewareInterface::class);
110-
}
111-
112-
if (!interface_exists(DoctrineDriverInterface::class)) {
113-
/** @psalm-suppress UndefinedClass */
114-
class_alias(DriverInterface::class, DoctrineDriverInterface::class);
115-
}
116-
11789
if (!interface_exists(LegacyExceptionConverterDriverInterface::class)) {
11890
/** @psalm-suppress UndefinedClass */
11991
class_alias(ExceptionConverterDriverInterface::class, LegacyExceptionConverterDriverInterface::class);

tests/Tracing/Doctrine/DBAL/TracingDriverMiddlewareTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL;
66

77
use Doctrine\DBAL\Driver as DriverInterface;
8+
use Doctrine\DBAL\Driver\Middleware;
89
use PHPUnit\Framework\MockObject\MockObject;
910
use Sentry\SentryBundle\Tests\DoctrineTestCase;
1011
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriver;
@@ -25,7 +26,7 @@ final class TracingDriverMiddlewareTest extends DoctrineTestCase
2526

2627
public static function setUpBeforeClass(): void
2728
{
28-
if (!self::isDoctrineBundlePackageInstalled()) {
29+
if (!class_exists(Middleware::class)) {
2930
self::markTestSkipped();
3031
}
3132
}

0 commit comments

Comments
 (0)