diff --git a/CHANGELOG.md b/CHANGELOG.md index 58d84e48..06a46daf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- ... +- Fix compatibility issue with Doctrine Bundle `>= 2.6.0` (#608) ## 4.2.7 (2022-02-18) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ce6769cf..0ac7d1c2 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -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 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index cb50c90a..5ef7a1e3 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + FatalErrorException @@ -31,6 +31,9 @@ iterable + + + ExceptionConverterDriver diff --git a/src/Tracing/Doctrine/DBAL/Compatibility/MiddlewareInterface.php b/src/Tracing/Doctrine/DBAL/Compatibility/MiddlewareInterface.php index 8a5dc609..d4bf6fd2 100644 --- a/src/Tracing/Doctrine/DBAL/Compatibility/MiddlewareInterface.php +++ b/src/Tracing/Doctrine/DBAL/Compatibility/MiddlewareInterface.php @@ -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; + } } diff --git a/src/Tracing/Doctrine/DBAL/TracingDriverMiddleware.php b/src/Tracing/Doctrine/DBAL/TracingDriverMiddleware.php index 74ee08e5..0ef93b70 100644 --- a/src/Tracing/Doctrine/DBAL/TracingDriverMiddleware.php +++ b/src/Tracing/Doctrine/DBAL/TracingDriverMiddleware.php @@ -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; /** @@ -14,7 +14,7 @@ * * @internal since version 4.2 */ -final class TracingDriverMiddleware implements Middleware +final class TracingDriverMiddleware implements MiddlewareInterface { /** * @var TracingDriverConnectionFactoryInterface diff --git a/src/aliases.php b/src/aliases.php index 64629412..e5a62c8f 100644 --- a/src/aliases.php +++ b/src/aliases.php @@ -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; @@ -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; @@ -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');