Skip to content

Commit 93c704e

Browse files
committed
Add accessor for wrapped DBAL Connection to TracingDriverConnection
Allows accessing e.g. underlying PDO instance so reflection does not have to be used for that. Mimics DBAL's `Connection::getWrappedConnection()`` https://github.com/doctrine/dbal/blob/25496429ef4bba2352b0ced7daffe1b3dec83d13/src/Connection.php#L1518-L1525
1 parent c5caac2 commit 93c704e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Tracing/Doctrine/DBAL/TracingDriverConnection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ public function errorInfo()
188188
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
189189
}
190190

191+
public function getWrappedConnection(): DriverConnectionInterface
192+
{
193+
return $this->decoratedConnection;
194+
}
195+
191196
/**
192197
* @phpstan-template T
193198
*

tests/Tracing/Doctrine/DBAL/TracingDriverConnectionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@ public function testRollBackDoesNothingIfNoSpanIsSetOnHub(): void
336336
$this->assertFalse($this->connection->rollBack());
337337
}
338338

339+
public function testCanAccessDecoratedConnection(): void
340+
{
341+
$connection = new TracingDriverConnection($this->hub, $this->decoratedConnection, 'foo_platform', []);
342+
343+
self::assertSame($this->decoratedConnection, $connection->getWrappedConnection());
344+
}
345+
339346
/**
340347
* @return \Generator<mixed>
341348
*/

0 commit comments

Comments
 (0)