Skip to content

Commit

Permalink
Fix compatibility issue with Doctrine >= 2.6 (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
ste93cry committed Mar 31, 2022
1 parent 348c5e0 commit d6aedfd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

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

## 4.2.7 (2022-02-18)

Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ parameters:
path: src/DependencyInjection/SentryExtension.php

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

Expand Down
5 changes: 4 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.20.0@f82a70e7edfc6cf2705e9374c8a0b6a974a779ed">
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
<file src="src/DependencyInjection/SentryExtension.php">
<UndefinedClass occurrences="1">
<code>FatalErrorException</code>
Expand Down Expand Up @@ -31,6 +31,9 @@
<code>iterable</code>
</LessSpecificImplementedReturnType>
</file>
<file src="src/Tracing/Doctrine/DBAL/Compatibility/MiddlewareInterface.php">
<UnrecognizedStatement occurrences="1"/>
</file>
<file src="src/Tracing/Doctrine/DBAL/TracingDriverForV2.php">
<UndefinedClass occurrences="1">
<code>ExceptionConverterDriver</code>
Expand Down
22 changes: 16 additions & 6 deletions src/Tracing/Doctrine/DBAL/Compatibility/MiddlewareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility;

use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Middleware as DoctrineMiddlewareInterface;

/**
* @internal
*/
interface MiddlewareInterface
{
public function wrap(DriverInterface $driver): DriverInterface;
if (interface_exists(DoctrineMiddlewareInterface::class)) {
/**
* @internal
*/
interface MiddlewareInterface extends DoctrineMiddlewareInterface
{
}
} else {
/**
* @internal
*/
interface MiddlewareInterface
{
public function wrap(DriverInterface $driver): DriverInterface;
}
}
4 changes: 2 additions & 2 deletions src/Tracing/Doctrine/DBAL/TracingDriverMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL;

use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Middleware;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\MiddlewareInterface;
use Sentry\State\HubInterface;

/**
Expand All @@ -14,7 +14,7 @@
*
* @internal since version 4.2
*/
final class TracingDriverMiddleware implements Middleware
final class TracingDriverMiddleware implements MiddlewareInterface
{
/**
* @var TracingDriverConnectionFactoryInterface
Expand Down
6 changes: 0 additions & 6 deletions src/aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Sentry\SentryBundle;

use Doctrine\DBAL\Driver\Middleware as DoctrineMiddlewareInterface;
use Doctrine\DBAL\Result;
use Sentry\SentryBundle\EventListener\ErrorListenerExceptionEvent;
use Sentry\SentryBundle\EventListener\RequestListenerControllerEvent;
Expand All @@ -18,7 +17,6 @@
use Sentry\SentryBundle\Tracing\Cache\TraceableTagAwareCacheAdapter;
use Sentry\SentryBundle\Tracing\Cache\TraceableTagAwareCacheAdapterForV2;
use Sentry\SentryBundle\Tracing\Cache\TraceableTagAwareCacheAdapterForV3;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\MiddlewareInterface;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverForV2;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverForV3;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatementForV2;
Expand Down Expand Up @@ -107,10 +105,6 @@ class_alias(TraceableTagAwareCacheAdapterForV2::class, TraceableTagAwareCacheAda
}
}

if (!interface_exists(DoctrineMiddlewareInterface::class)) {
class_alias(MiddlewareInterface::class, DoctrineMiddlewareInterface::class);
}

if (!class_exists('Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement')) {
if (class_exists(Result::class)) {
class_alias(TracingStatementForV3::class, 'Sentry\\SentryBundle\\Tracing\\Doctrine\\DBAL\\TracingStatement');
Expand Down

0 comments on commit d6aedfd

Please sign in to comment.