Skip to content

Commit c047da6

Browse files
authored
Apply code style fixes (#868)
1 parent a19653c commit c047da6

21 files changed

+36
-36
lines changed

src/Command/SentryTestCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(?HubInterface $hub = null)
2525
parent::__construct();
2626

2727
if (null === $hub) {
28-
@trigger_error(sprintf('Not passing an instance of the "%s" interface as argument of the constructor is deprecated since version 4.12 and will not work since version 5.0.', HubInterface::class), \E_USER_DEPRECATED);
28+
@trigger_error(\sprintf('Not passing an instance of the "%s" interface as argument of the constructor is deprecated since version 4.12 and will not work since version 5.0.', HubInterface::class), \E_USER_DEPRECATED);
2929
}
3030

3131
$this->hub = $hub ?? SentrySdk::getCurrentHub();

src/DependencyInjection/Compiler/DbalTracingPass.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public function process(ContainerBuilder $container): void
4545
}
4646

4747
foreach ($connectionsToTrace as $connectionName) {
48-
if (!\in_array(sprintf(self::CONNECTION_SERVICE_NAME_FORMAT, $connectionName), $connections, true)) {
49-
throw new \InvalidArgumentException(sprintf('The Doctrine connection "%s" does not exists and cannot be instrumented.', $connectionName));
48+
if (!\in_array(\sprintf(self::CONNECTION_SERVICE_NAME_FORMAT, $connectionName), $connections, true)) {
49+
throw new \InvalidArgumentException(\sprintf('The Doctrine connection "%s" does not exists and cannot be instrumented.', $connectionName));
5050
}
5151

5252
if (class_exists(Result::class)) {
@@ -65,7 +65,7 @@ private function configureConnectionForDoctrineDBALVersion3(ContainerBuilder $co
6565

6666
private function configureConnectionForDoctrineDBALVersion2(ContainerBuilder $container, string $connectionName): void
6767
{
68-
$connectionDefinition = $container->getDefinition(sprintf(self::CONNECTION_SERVICE_NAME_FORMAT, $connectionName));
68+
$connectionDefinition = $container->getDefinition(\sprintf(self::CONNECTION_SERVICE_NAME_FORMAT, $connectionName));
6969
$connectionDefinition->setConfigurator([new Reference(ConnectionConfigurator::class), 'configure']);
7070
}
7171

src/ErrorTypesParser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private static function convertErrorConstants(string $value): string
7575
}, $value);
7676

7777
if (null === $output) {
78-
throw new \InvalidArgumentException(sprintf('The "%s" value could not be parsed.', $value));
78+
throw new \InvalidArgumentException(\sprintf('The "%s" value could not be parsed.', $value));
7979
}
8080

8181
return $output;

src/EventListener/AbstractTracingRequestListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function getRouteName(Request $request): string
6767
$route = $request->attributes->get('_controller');
6868

6969
if (\is_array($route) && \is_callable($route, true)) {
70-
$route = sprintf('%s::%s', \is_object($route[0]) ? get_debug_type($route[0]) : $route[0], $route[1]);
70+
$route = \sprintf('%s::%s', \is_object($route[0]) ? get_debug_type($route[0]) : $route[0], $route[1]);
7171
}
7272
}
7373

src/EventListener/TracingRequestListener.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public function handleKernelRequestEvent(RequestEvent $event): void
4646

4747
$routeName = $request->attributes->get('_route');
4848
if (null !== $routeName && \is_string($routeName)) {
49-
$context->setName(sprintf('%s %s', $request->getMethod(), $routeName));
49+
$context->setName(\sprintf('%s %s', $request->getMethod(), $routeName));
5050
$context->setSource(TransactionSource::route());
5151
} else {
52-
$context->setName(sprintf('%s %s%s%s', $request->getMethod(), $request->getSchemeAndHttpHost(), $request->getBaseUrl(), $request->getPathInfo()));
52+
$context->setName(\sprintf('%s %s%s%s', $request->getMethod(), $request->getSchemeAndHttpHost(), $request->getBaseUrl(), $request->getPathInfo()));
5353
$context->setSource(TransactionSource::url());
5454
}
5555

src/EventListener/TracingSubRequestListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function handleKernelRequestEvent(RequestEvent $event): void
3636

3737
$spanContext = new SpanContext();
3838
$spanContext->setOp('http.server');
39-
$spanContext->setDescription(sprintf('%s %s%s%s', $request->getMethod(), $request->getSchemeAndHttpHost(), $request->getBaseUrl(), $request->getPathInfo()));
39+
$spanContext->setDescription(\sprintf('%s %s%s%s', $request->getMethod(), $request->getSchemeAndHttpHost(), $request->getBaseUrl(), $request->getPathInfo()));
4040
$spanContext->setData([
4141
'http.request.method' => $request->getMethod(),
4242
'http.url' => $request->getUri(),

src/Tracing/Cache/TraceableCacheAdapterForV2.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function get(string $key, callable $callback, float $beta = null, array &
4444
{
4545
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
4646
if (!$this->decoratedAdapter instanceof CacheInterface) {
47-
throw new \BadMethodCallException(sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
47+
throw new \BadMethodCallException(\sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
4848
}
4949

5050
return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);

src/Tracing/Cache/TraceableCacheAdapterForV3.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function get(string $key, callable $callback, float $beta = null, array &
4242
{
4343
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
4444
if (!$this->decoratedAdapter instanceof CacheInterface) {
45-
throw new \BadMethodCallException(sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
45+
throw new \BadMethodCallException(\sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
4646
}
4747

4848
return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);

src/Tracing/Cache/TraceableCacheAdapterTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function delete(string $key): bool
7070
{
7171
return $this->traceFunction('cache.delete_item', function () use ($key): bool {
7272
if (!$this->decoratedAdapter instanceof CacheInterface) {
73-
throw new \BadMethodCallException(sprintf('The %s::delete() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
73+
throw new \BadMethodCallException(\sprintf('The %s::delete() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
7474
}
7575

7676
return $this->decoratedAdapter->delete($key);

src/Tracing/Cache/TraceableTagAwareCacheAdapterForV2.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function get(string $key, callable $callback, float $beta = null, array &
4545
{
4646
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
4747
if (!$this->decoratedAdapter instanceof CacheInterface) {
48-
throw new \BadMethodCallException(sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
48+
throw new \BadMethodCallException(\sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
4949
}
5050

5151
return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);

src/Tracing/Cache/TraceableTagAwareCacheAdapterForV3.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function get(string $key, callable $callback, float $beta = null, array &
4343
{
4444
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
4545
if (!$this->decoratedAdapter instanceof CacheInterface) {
46-
throw new \BadMethodCallException(sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
46+
throw new \BadMethodCallException(\sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
4747
}
4848

4949
return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);

src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV2V3.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function rollBack(): bool
176176
public function getNativeConnection()
177177
{
178178
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
179-
throw new \BadMethodCallException(sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
179+
throw new \BadMethodCallException(\sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
180180
}
181181

182182
return $this->decoratedConnection->getNativeConnection();
@@ -191,7 +191,7 @@ public function errorCode(): ?string
191191
return $this->decoratedConnection->errorCode();
192192
}
193193

194-
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
194+
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
195195
}
196196

197197
/**
@@ -203,7 +203,7 @@ public function errorInfo(): array
203203
return $this->decoratedConnection->errorInfo();
204204
}
205205

206-
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
206+
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
207207
}
208208

209209
public function getWrappedConnection(): DriverConnectionInterface

src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function errorCode(): ?string
184184
return $this->decoratedConnection->errorCode();
185185
}
186186

187-
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
187+
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
188188
}
189189

190190
/**
@@ -196,7 +196,7 @@ public function errorInfo(): array
196196
return $this->decoratedConnection->errorInfo();
197197
}
198198

199-
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
199+
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
200200
}
201201

202202
public function getWrappedConnection(): DriverConnectionInterface

src/Tracing/Doctrine/DBAL/TracingDriverMiddleware.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public function __construct($hubOrConnectionFactory)
3131
if ($hubOrConnectionFactory instanceof TracingDriverConnectionFactoryInterface) {
3232
$this->connectionFactory = $hubOrConnectionFactory;
3333
} elseif ($hubOrConnectionFactory instanceof HubInterface) {
34-
@trigger_error(sprintf('Not passing an instance of the "%s" interface as argument of the constructor is deprecated since version 4.2 and will not work since version 5.0.', TracingDriverConnectionFactoryInterface::class), \E_USER_DEPRECATED);
34+
@trigger_error(\sprintf('Not passing an instance of the "%s" interface as argument of the constructor is deprecated since version 4.2 and will not work since version 5.0.', TracingDriverConnectionFactoryInterface::class), \E_USER_DEPRECATED);
3535

3636
$this->connectionFactory = new TracingDriverConnectionFactory($hubOrConnectionFactory);
3737
} else {
38-
throw new \InvalidArgumentException(sprintf('The constructor requires either an instance of the "%s" interface or an instance of the "%s" interface.', HubInterface::class, TracingDriverConnectionFactoryInterface::class));
38+
throw new \InvalidArgumentException(\sprintf('The constructor requires either an instance of the "%s" interface or an instance of the "%s" interface.', HubInterface::class, TracingDriverConnectionFactoryInterface::class));
3939
}
4040
}
4141

src/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnection.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function getServerVersion(): string
109109
$wrappedConnection = $this->getWrappedConnection();
110110

111111
if (!$wrappedConnection instanceof ServerInfoAwareConnection) {
112-
throw new \BadMethodCallException(sprintf('The wrapped connection must be an instance of the "%s" interface.', ServerInfoAwareConnection::class));
112+
throw new \BadMethodCallException(\sprintf('The wrapped connection must be an instance of the "%s" interface.', ServerInfoAwareConnection::class));
113113
}
114114

115115
return $wrappedConnection->getServerVersion();
@@ -123,7 +123,7 @@ public function getServerVersion(): string
123123
public function getNativeConnection()
124124
{
125125
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
126-
throw new \BadMethodCallException(sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
126+
throw new \BadMethodCallException(\sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
127127
}
128128

129129
return $this->decoratedConnection->getNativeConnection();
@@ -137,11 +137,11 @@ public function requiresQueryForServerVersion(): bool
137137
$wrappedConnection = $this->getWrappedConnection();
138138

139139
if (!$wrappedConnection instanceof ServerInfoAwareConnection) {
140-
throw new \BadMethodCallException(sprintf('The wrapped connection must be an instance of the "%s" interface.', ServerInfoAwareConnection::class));
140+
throw new \BadMethodCallException(\sprintf('The wrapped connection must be an instance of the "%s" interface.', ServerInfoAwareConnection::class));
141141
}
142142

143143
if (!method_exists($wrappedConnection, 'requiresQueryForServerVersion')) {
144-
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
144+
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
145145
}
146146

147147
return $wrappedConnection->requiresQueryForServerVersion();
@@ -156,7 +156,7 @@ public function errorCode(): ?string
156156
return $this->decoratedConnection->errorCode();
157157
}
158158

159-
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
159+
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
160160
}
161161

162162
/**
@@ -168,7 +168,7 @@ public function errorInfo(): array
168168
return $this->decoratedConnection->errorInfo();
169169
}
170170

171-
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
171+
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
172172
}
173173

174174
public function getWrappedConnection(): Connection

src/Tracing/HttpClient/AbstractTraceableHttpClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function stream($responses, float $timeout = null): ResponseStreamInterfa
111111
if ($responses instanceof AbstractTraceableResponse) {
112112
$responses = [$responses];
113113
} elseif (!is_iterable($responses)) {
114-
throw new \TypeError(sprintf('"%s()" expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', __METHOD__, get_debug_type($responses)));
114+
throw new \TypeError(\sprintf('"%s()" expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', __METHOD__, get_debug_type($responses)));
115115
}
116116

117117
return new ResponseStream(AbstractTraceableResponse::stream($this->client, $responses, $timeout));

src/Tracing/HttpClient/AbstractTraceableResponse.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static function stream(HttpClientInterface $client, iterable $responses,
107107

108108
foreach ($responses as $response) {
109109
if (!$response instanceof self) {
110-
throw new \TypeError(sprintf('"%s::stream()" expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', TraceableHttpClient::class, get_debug_type($response)));
110+
throw new \TypeError(\sprintf('"%s::stream()" expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', TraceableHttpClient::class, get_debug_type($response)));
111111
}
112112

113113
$traceableMap[$response->response] = $response;

src/Tracing/Twig/TwigTracingExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private function getSpanDescription(Profile $profile): string
9595
return $profile->getTemplate();
9696

9797
default:
98-
return sprintf('%s::%s(%s)', $profile->getTemplate(), $profile->getType(), $profile->getName());
98+
return \sprintf('%s::%s(%s)', $profile->getTemplate(), $profile->getType(), $profile->getName());
9999
}
100100
}
101101
}

src/Twig/SentryExtension.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ public function getFunctions(): array
3838
*/
3939
public function getTraceMeta(): string
4040
{
41-
return sprintf('<meta name="sentry-trace" content="%s" />', getTraceparent());
41+
return \sprintf('<meta name="sentry-trace" content="%s" />', getTraceparent());
4242
}
4343

4444
/**
4545
* Returns an HTML meta tag named `traceparent`.
4646
*/
4747
public function getW3CTraceMeta(): string
4848
{
49-
return sprintf('<meta name="traceparent" content="%s" />', getW3CTraceparent());
49+
return \sprintf('<meta name="traceparent" content="%s" />', getW3CTraceparent());
5050
}
5151

5252
/**
5353
* Returns an HTML meta tag named `baggage`.
5454
*/
5555
public function getBaggageMeta(): string
5656
{
57-
return sprintf('<meta name="baggage" content="%s" />', getBaggage());
57+
return \sprintf('<meta name="baggage" content="%s" />', getBaggage());
5858
}
5959
}

tests/Tracing/Cache/AbstractTraceableCacheAdapterTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function testGetThrowsExceptionIfDecoratedAdapterDoesNotImplementTheCache
159159
$adapter = $this->createCacheAdapter($this->createMock(static::getAdapterClassFqcn()));
160160

161161
$this->expectException(\BadMethodCallException::class);
162-
$this->expectExceptionMessage(sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "Symfony\\Contracts\\Cache\\CacheInterface" interface.', \get_class($adapter)));
162+
$this->expectExceptionMessage(\sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "Symfony\\Contracts\\Cache\\CacheInterface" interface.', \get_class($adapter)));
163163

164164
$adapter->get('foo', static function () {});
165165
}
@@ -197,7 +197,7 @@ public function testDeleteThrowsExceptionIfDecoratedAdapterDoesNotImplementTheCa
197197
$adapter = $this->createCacheAdapter($this->createMock(static::getAdapterClassFqcn()));
198198

199199
$this->expectException(\BadMethodCallException::class);
200-
$this->expectExceptionMessage(sprintf('The %s::delete() method is not supported because the decorated adapter does not implement the "Symfony\\Contracts\\Cache\\CacheInterface" interface.', \get_class($adapter)));
200+
$this->expectExceptionMessage(\sprintf('The %s::delete() method is not supported because the decorated adapter does not implement the "Symfony\\Contracts\\Cache\\CacheInterface" interface.', \get_class($adapter)));
201201

202202
$adapter->delete('foo');
203203
}

tests/Tracing/HttpClient/TraceableResponseTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testInstanceCannotBeUnserialized(): void
5555
$this->expectException(\BadMethodCallException::class);
5656
$this->expectExceptionMessage('Unserializing instances of this class is forbidden.');
5757

58-
unserialize(sprintf('O:%u:"%s":0:{}', \strlen(TraceableResponse::class), TraceableResponse::class));
58+
unserialize(\sprintf('O:%u:"%s":0:{}', \strlen(TraceableResponse::class), TraceableResponse::class));
5959
}
6060

6161
public function testDestructor(): void

0 commit comments

Comments
 (0)