Skip to content

Commit f210b4f

Browse files
committed
try again
1 parent de3b833 commit f210b4f

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

src/Tracing/Doctrine/DBAL/TracingDriverConnection.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,28 @@ public function rollBack(): bool
167167

168168
/**
169169
* {@inheritdoc}
170+
*
171+
* @return resource|object
170172
*/
171-
public function errorCode(): ?string
173+
public function getNativeConnection()
172174
{
173-
if (method_exists($this->decoratedConnection, 'errorCode')) {
174-
return $this->decoratedConnection->errorCode();
175+
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
176+
throw new BadMethodCallException(sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
175177
}
176178

177-
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
179+
return $this->decoratedConnection->getNativeConnection();
178180
}
179181

180182
/**
181183
* {@inheritdoc}
182184
*/
183-
public function getNativeConnection()
185+
public function errorCode(): ?string
184186
{
185-
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
186-
throw new BadMethodCallException(sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
187+
if (method_exists($this->decoratedConnection, 'errorCode')) {
188+
return $this->decoratedConnection->errorCode();
187189
}
188190

189-
return $this->decoratedConnection->getNativeConnection();
191+
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
190192
}
191193

192194
/**

src/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnection.php

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

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

7+
use BadMethodCallException;
78
use Doctrine\DBAL\Driver\Connection;
89
use Doctrine\DBAL\Driver\Result;
910
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
1011
use Doctrine\DBAL\Driver\Statement;
1112
use Doctrine\DBAL\ParameterType;
12-
use LogicException;
1313
use function method_exists;
1414
use function sprintf;
1515

@@ -118,6 +118,20 @@ public function getServerVersion(): string
118118
return $wrappedConnection->getServerVersion();
119119
}
120120

121+
/**
122+
* {@inheritdoc}
123+
*
124+
* @return resource|object
125+
*/
126+
public function getNativeConnection()
127+
{
128+
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
129+
throw new BadMethodCallException(sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
130+
}
131+
132+
return $this->decoratedConnection->getNativeConnection();
133+
}
134+
121135
/**
122136
* {@inheritdoc}
123137
*/
@@ -164,13 +178,4 @@ public function getWrappedConnection(): Connection
164178
{
165179
return $this->decoratedConnection->getWrappedConnection();
166180
}
167-
168-
public function getNativeConnection()
169-
{
170-
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
171-
throw new LogicException(sprintf('The decoratedConnection %s does not support accessing the native connection.', \get_class($this->decoratedConnection)));
172-
}
173-
174-
return $this->decoratedConnection->getNativeConnection();
175-
}
176181
}

0 commit comments

Comments
 (0)