Skip to content

Commit d6aedfd

Browse files
authored
Fix compatibility issue with Doctrine >= 2.6 (#608)
1 parent 348c5e0 commit d6aedfd

File tree

6 files changed

+24
-17
lines changed

6 files changed

+24
-17
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Unreleased
44

5-
- ...
5+
- Fix compatibility issue with Doctrine Bundle `>= 2.6.0` (#608)
66

77
## 4.2.7 (2022-02-18)
88

phpstan-baseline.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ parameters:
136136
path: src/DependencyInjection/SentryExtension.php
137137

138138
-
139-
message: "#^Parameter \\#2 \\$value of method Symfony\\\\Component\\\\DependencyInjection\\\\Container\\:\\:setParameter\\(\\) expects array\\|bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
139+
message: "#^Parameter \\#2 \\$value of method Symfony\\\\Component\\\\DependencyInjection\\\\Container\\:\\:setParameter\\(\\) expects array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null, mixed given\\.$#"
140140
count: 2
141141
path: src/DependencyInjection/SentryExtension.php
142142

psalm-baseline.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.20.0@f82a70e7edfc6cf2705e9374c8a0b6a974a779ed">
2+
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
33
<file src="src/DependencyInjection/SentryExtension.php">
44
<UndefinedClass occurrences="1">
55
<code>FatalErrorException</code>
@@ -31,6 +31,9 @@
3131
<code>iterable</code>
3232
</LessSpecificImplementedReturnType>
3333
</file>
34+
<file src="src/Tracing/Doctrine/DBAL/Compatibility/MiddlewareInterface.php">
35+
<UnrecognizedStatement occurrences="1"/>
36+
</file>
3437
<file src="src/Tracing/Doctrine/DBAL/TracingDriverForV2.php">
3538
<UndefinedClass occurrences="1">
3639
<code>ExceptionConverterDriver</code>

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

+16-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@
55
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility;
66

77
use Doctrine\DBAL\Driver as DriverInterface;
8+
use Doctrine\DBAL\Driver\Middleware as DoctrineMiddlewareInterface;
89

9-
/**
10-
* @internal
11-
*/
12-
interface MiddlewareInterface
13-
{
14-
public function wrap(DriverInterface $driver): DriverInterface;
10+
if (interface_exists(DoctrineMiddlewareInterface::class)) {
11+
/**
12+
* @internal
13+
*/
14+
interface MiddlewareInterface extends DoctrineMiddlewareInterface
15+
{
16+
}
17+
} else {
18+
/**
19+
* @internal
20+
*/
21+
interface MiddlewareInterface
22+
{
23+
public function wrap(DriverInterface $driver): DriverInterface;
24+
}
1525
}

src/Tracing/Doctrine/DBAL/TracingDriverMiddleware.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL;
66

77
use Doctrine\DBAL\Driver;
8-
use Doctrine\DBAL\Driver\Middleware;
8+
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\MiddlewareInterface;
99
use Sentry\State\HubInterface;
1010

1111
/**
@@ -14,7 +14,7 @@
1414
*
1515
* @internal since version 4.2
1616
*/
17-
final class TracingDriverMiddleware implements Middleware
17+
final class TracingDriverMiddleware implements MiddlewareInterface
1818
{
1919
/**
2020
* @var TracingDriverConnectionFactoryInterface

src/aliases.php

-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Sentry\SentryBundle;
66

7-
use Doctrine\DBAL\Driver\Middleware as DoctrineMiddlewareInterface;
87
use Doctrine\DBAL\Result;
98
use Sentry\SentryBundle\EventListener\ErrorListenerExceptionEvent;
109
use Sentry\SentryBundle\EventListener\RequestListenerControllerEvent;
@@ -18,7 +17,6 @@
1817
use Sentry\SentryBundle\Tracing\Cache\TraceableTagAwareCacheAdapter;
1918
use Sentry\SentryBundle\Tracing\Cache\TraceableTagAwareCacheAdapterForV2;
2019
use Sentry\SentryBundle\Tracing\Cache\TraceableTagAwareCacheAdapterForV3;
21-
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\MiddlewareInterface;
2220
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverForV2;
2321
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverForV3;
2422
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatementForV2;
@@ -107,10 +105,6 @@ class_alias(TraceableTagAwareCacheAdapterForV2::class, TraceableTagAwareCacheAda
107105
}
108106
}
109107

110-
if (!interface_exists(DoctrineMiddlewareInterface::class)) {
111-
class_alias(MiddlewareInterface::class, DoctrineMiddlewareInterface::class);
112-
}
113-
114108
if (!class_exists('Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement')) {
115109
if (class_exists(Result::class)) {
116110
class_alias(TracingStatementForV3::class, 'Sentry\\SentryBundle\\Tracing\\Doctrine\\DBAL\\TracingStatement');

0 commit comments

Comments
 (0)