Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply code style fixes #868

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Command/SentryTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(?HubInterface $hub = null)
parent::__construct();

if (null === $hub) {
@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);
@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);
}

$this->hub = $hub ?? SentrySdk::getCurrentHub();
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/Compiler/DbalTracingPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function process(ContainerBuilder $container): void
}

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/ErrorTypesParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
}, $value);

if (null === $output) {
throw new \InvalidArgumentException(sprintf('The "%s" value could not be parsed.', $value));
throw new \InvalidArgumentException(\sprintf('The "%s" value could not be parsed.', $value));

Check warning on line 78 in src/ErrorTypesParser.php

View check run for this annotation

Codecov / codecov/patch

src/ErrorTypesParser.php#L78

Added line #L78 was not covered by tests
}

return $output;
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/AbstractTracingRequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function getRouteName(Request $request): string
$route = $request->attributes->get('_controller');

if (\is_array($route) && \is_callable($route, true)) {
$route = sprintf('%s::%s', \is_object($route[0]) ? get_debug_type($route[0]) : $route[0], $route[1]);
$route = \sprintf('%s::%s', \is_object($route[0]) ? get_debug_type($route[0]) : $route[0], $route[1]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/TracingRequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public function handleKernelRequestEvent(RequestEvent $event): void

$routeName = $request->attributes->get('_route');
if (null !== $routeName && \is_string($routeName)) {
$context->setName(sprintf('%s %s', $request->getMethod(), $routeName));
$context->setName(\sprintf('%s %s', $request->getMethod(), $routeName));
$context->setSource(TransactionSource::route());
} else {
$context->setName(sprintf('%s %s%s%s', $request->getMethod(), $request->getSchemeAndHttpHost(), $request->getBaseUrl(), $request->getPathInfo()));
$context->setName(\sprintf('%s %s%s%s', $request->getMethod(), $request->getSchemeAndHttpHost(), $request->getBaseUrl(), $request->getPathInfo()));
$context->setSource(TransactionSource::url());
}

Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/TracingSubRequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function handleKernelRequestEvent(RequestEvent $event): void

$spanContext = new SpanContext();
$spanContext->setOp('http.server');
$spanContext->setDescription(sprintf('%s %s%s%s', $request->getMethod(), $request->getSchemeAndHttpHost(), $request->getBaseUrl(), $request->getPathInfo()));
$spanContext->setDescription(\sprintf('%s %s%s%s', $request->getMethod(), $request->getSchemeAndHttpHost(), $request->getBaseUrl(), $request->getPathInfo()));
$spanContext->setData([
'http.request.method' => $request->getMethod(),
'http.url' => $request->getUri(),
Expand Down
2 changes: 1 addition & 1 deletion src/Tracing/Cache/TraceableCacheAdapterForV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function get(string $key, callable $callback, float $beta = null, array &
{
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
if (!$this->decoratedAdapter instanceof CacheInterface) {
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));
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));
}

return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);
Expand Down
2 changes: 1 addition & 1 deletion src/Tracing/Cache/TraceableCacheAdapterForV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function get(string $key, callable $callback, float $beta = null, array &
{
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
if (!$this->decoratedAdapter instanceof CacheInterface) {
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));
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));
}

return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);
Expand Down
2 changes: 1 addition & 1 deletion src/Tracing/Cache/TraceableCacheAdapterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function delete(string $key): bool
{
return $this->traceFunction('cache.delete_item', function () use ($key): bool {
if (!$this->decoratedAdapter instanceof CacheInterface) {
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));
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));
}

return $this->decoratedAdapter->delete($key);
Expand Down
2 changes: 1 addition & 1 deletion src/Tracing/Cache/TraceableTagAwareCacheAdapterForV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function get(string $key, callable $callback, float $beta = null, array &
{
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
if (!$this->decoratedAdapter instanceof CacheInterface) {
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));
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));
}

return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);
Expand Down
2 changes: 1 addition & 1 deletion src/Tracing/Cache/TraceableTagAwareCacheAdapterForV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function get(string $key, callable $callback, float $beta = null, array &
{
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
if (!$this->decoratedAdapter instanceof CacheInterface) {
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));
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));
}

return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);
Expand Down
6 changes: 3 additions & 3 deletions src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV2V3.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
public function getNativeConnection()
{
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
throw new \BadMethodCallException(sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
throw new \BadMethodCallException(\sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));

Check warning on line 179 in src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV2V3.php

View check run for this annotation

Codecov / codecov/patch

src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV2V3.php#L179

Added line #L179 was not covered by tests
}

return $this->decoratedConnection->getNativeConnection();
Expand All @@ -191,7 +191,7 @@
return $this->decoratedConnection->errorCode();
}

throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));

Check warning on line 194 in src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV2V3.php

View check run for this annotation

Codecov / codecov/patch

src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV2V3.php#L194

Added line #L194 was not covered by tests
}

/**
Expand All @@ -203,7 +203,7 @@
return $this->decoratedConnection->errorInfo();
}

throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));

Check warning on line 206 in src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV2V3.php

View check run for this annotation

Codecov / codecov/patch

src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV2V3.php#L206

Added line #L206 was not covered by tests
}

public function getWrappedConnection(): DriverConnectionInterface
Expand Down
4 changes: 2 additions & 2 deletions src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
return $this->decoratedConnection->errorCode();
}

throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));

Check warning on line 187 in src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php

View check run for this annotation

Codecov / codecov/patch

src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php#L187

Added line #L187 was not covered by tests
}

/**
Expand All @@ -196,7 +196,7 @@
return $this->decoratedConnection->errorInfo();
}

throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
throw new \BadMethodCallException(\sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));

Check warning on line 199 in src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php

View check run for this annotation

Codecov / codecov/patch

src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php#L199

Added line #L199 was not covered by tests
}

public function getWrappedConnection(): DriverConnectionInterface
Expand Down
4 changes: 2 additions & 2 deletions src/Tracing/Doctrine/DBAL/TracingDriverMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public function __construct($hubOrConnectionFactory)
if ($hubOrConnectionFactory instanceof TracingDriverConnectionFactoryInterface) {
$this->connectionFactory = $hubOrConnectionFactory;
} elseif ($hubOrConnectionFactory instanceof HubInterface) {
@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);
@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);

$this->connectionFactory = new TracingDriverConnectionFactory($hubOrConnectionFactory);
} else {
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));
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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getServerVersion(): string
$wrappedConnection = $this->getWrappedConnection();

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

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

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

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

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

return $wrappedConnection->requiresQueryForServerVersion();
Expand All @@ -156,7 +156,7 @@ public function errorCode(): ?string
return $this->decoratedConnection->errorCode();
}

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

/**
Expand All @@ -168,7 +168,7 @@ public function errorInfo(): array
return $this->decoratedConnection->errorInfo();
}

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

public function getWrappedConnection(): Connection
Expand Down
2 changes: 1 addition & 1 deletion src/Tracing/HttpClient/AbstractTraceableHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function stream($responses, float $timeout = null): ResponseStreamInterfa
if ($responses instanceof AbstractTraceableResponse) {
$responses = [$responses];
} elseif (!is_iterable($responses)) {
throw new \TypeError(sprintf('"%s()" expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', __METHOD__, get_debug_type($responses)));
throw new \TypeError(\sprintf('"%s()" expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', __METHOD__, get_debug_type($responses)));
}

return new ResponseStream(AbstractTraceableResponse::stream($this->client, $responses, $timeout));
Expand Down
2 changes: 1 addition & 1 deletion src/Tracing/HttpClient/AbstractTraceableResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static function stream(HttpClientInterface $client, iterable $responses,

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

$traceableMap[$response->response] = $response;
Expand Down
2 changes: 1 addition & 1 deletion src/Tracing/Twig/TwigTracingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private function getSpanDescription(Profile $profile): string
return $profile->getTemplate();

default:
return sprintf('%s::%s(%s)', $profile->getTemplate(), $profile->getType(), $profile->getName());
return \sprintf('%s::%s(%s)', $profile->getTemplate(), $profile->getType(), $profile->getName());
}
}
}
6 changes: 3 additions & 3 deletions src/Twig/SentryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ public function getFunctions(): array
*/
public function getTraceMeta(): string
{
return sprintf('<meta name="sentry-trace" content="%s" />', getTraceparent());
return \sprintf('<meta name="sentry-trace" content="%s" />', getTraceparent());
}

/**
* Returns an HTML meta tag named `traceparent`.
*/
public function getW3CTraceMeta(): string
{
return sprintf('<meta name="traceparent" content="%s" />', getW3CTraceparent());
return \sprintf('<meta name="traceparent" content="%s" />', getW3CTraceparent());
}

/**
* Returns an HTML meta tag named `baggage`.
*/
public function getBaggageMeta(): string
{
return sprintf('<meta name="baggage" content="%s" />', getBaggage());
return \sprintf('<meta name="baggage" content="%s" />', getBaggage());
}
}
4 changes: 2 additions & 2 deletions tests/Tracing/Cache/AbstractTraceableCacheAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function testGetThrowsExceptionIfDecoratedAdapterDoesNotImplementTheCache
$adapter = $this->createCacheAdapter($this->createMock(static::getAdapterClassFqcn()));

$this->expectException(\BadMethodCallException::class);
$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)));
$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)));

$adapter->get('foo', static function () {});
}
Expand Down Expand Up @@ -197,7 +197,7 @@ public function testDeleteThrowsExceptionIfDecoratedAdapterDoesNotImplementTheCa
$adapter = $this->createCacheAdapter($this->createMock(static::getAdapterClassFqcn()));

$this->expectException(\BadMethodCallException::class);
$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)));
$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)));

$adapter->delete('foo');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Tracing/HttpClient/TraceableResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testInstanceCannotBeUnserialized(): void
$this->expectException(\BadMethodCallException::class);
$this->expectExceptionMessage('Unserializing instances of this class is forbidden.');

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

public function testDestructor(): void
Expand Down
Loading