From 4e7c9383efa437c760563097ef791ad38f1a40a4 Mon Sep 17 00:00:00 2001 From: GCalmels Date: Tue, 30 Jul 2024 07:50:55 +0200 Subject: [PATCH] fix: remove php-cs-fixer warnings --- .../Doctrine/TraceContextInfoProviderSpec.php | 4 ++-- src/DependencyInjection/Configuration.php | 4 ++-- src/DependencyInjection/Extension.php | 12 ++++++------ src/Http/HttpMessageHelper.php | 2 +- src/Http/TracedResponse.php | 2 +- src/Http/TracingHttpClient.php | 2 +- .../EventSubscriber/RequestEventSubscriber.php | 2 +- src/Metrics/Meter.php | 8 ++++---- src/Metrics/Registry.php | 2 +- .../Attribute/ClientRequestAttributeProvider.php | 2 +- .../Attribute/ServerRequestAttributeProvider.php | 2 +- .../ClientRequestOperationNameResolver.php | 2 +- .../OperationName/CommandOperationNameResolver.php | 2 +- .../OperationName/MessageOperationNameResolver.php | 2 +- .../RouteNameServerRequestOperationNameResolver.php | 2 +- .../RoutePathServerRequestOperationNameResolver.php | 2 +- .../EventSubscriber/RequestEventSubscriber.php | 2 +- .../Instrumentation/LogHandler/TracingHandler.php | 2 +- .../Doctrine/TraceContextInfoProvider.php | 2 +- .../EventSubscriber/RequestEventSubscriber.php | 2 +- .../Messenger/PropagationStrategyStamp.php | 2 +- 21 files changed, 31 insertions(+), 31 deletions(-) diff --git a/spec/Tracing/Propagation/Doctrine/TraceContextInfoProviderSpec.php b/spec/Tracing/Propagation/Doctrine/TraceContextInfoProviderSpec.php index 992fdec..f256ee7 100644 --- a/spec/Tracing/Propagation/Doctrine/TraceContextInfoProviderSpec.php +++ b/spec/Tracing/Propagation/Doctrine/TraceContextInfoProviderSpec.php @@ -71,8 +71,8 @@ public function it_gets_controller_and_route(ResourceInfo $info, AttributesInter private function getMinimalInfo(): array { return [ - 'db_driver' => sprintf('doctrine/dbal-%s', InstalledVersions::getVersion('doctrine/dbal')), - 'framework' => sprintf('symfony-%s', Kernel::VERSION), + 'db_driver' => \sprintf('doctrine/dbal-%s', InstalledVersions::getVersion('doctrine/dbal')), + 'framework' => \sprintf('symfony-%s', Kernel::VERSION), ]; } } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index a5b1683..92c5e34 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -34,7 +34,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->scalarPrototype()->end() ->beforeNormalization() ->ifTrue(fn ($v) => !isset($v[ResourceAttributes::SERVICE_NAME])) - ->thenInvalid(sprintf('You must provide the "%s" attribute in resource info.', ResourceAttributes::SERVICE_NAME)) + ->thenInvalid(\sprintf('You must provide the "%s" attribute in resource info.', ResourceAttributes::SERVICE_NAME)) ->end() ->end() @@ -91,7 +91,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->enumNode('level') ->defaultValue(Level::Info) ->values(Level::cases()) - ->info(sprintf('One of the %s levels.', Level::class)) + ->info(\sprintf('One of the %s levels.', Level::class)) ->end() ->arrayNode('channels') ->defaultValue([]) diff --git a/src/DependencyInjection/Extension.php b/src/DependencyInjection/Extension.php index 379372c..6161591 100644 --- a/src/DependencyInjection/Extension.php +++ b/src/DependencyInjection/Extension.php @@ -112,7 +112,7 @@ public function process(ContainerBuilder $container): void foreach ($providedMetrics as $name => $metric) { if (isset($metrics[$name])) { - throw new \RuntimeException(sprintf('A metric named %s is already registered.', $name)); + throw new \RuntimeException(\sprintf('A metric named %s is already registered.', $name)); } $metrics[$name] = $metric; } @@ -133,13 +133,13 @@ public function process(ContainerBuilder $container): void } foreach ($connectionsToTrace as $connection) { - $serviceId = sprintf('doctrine.dbal.%s_connection', $connection); + $serviceId = \sprintf('doctrine.dbal.%s_connection', $connection); if (!\in_array($serviceId, $connections, true)) { - throw new \InvalidArgumentException(sprintf('No such connection: "%s".', $connection)); + throw new \InvalidArgumentException(\sprintf('No such connection: "%s".', $connection)); } - $configDef = $container->getDefinition(sprintf('%s.configuration', $serviceId)); + $configDef = $container->getDefinition(\sprintf('%s.configuration', $serviceId)); $middlewares = []; foreach ($configDef->getMethodCalls() as $call) { @@ -252,7 +252,7 @@ protected function loadTracing(array $config, ContainerBuilder $container): void foreach (['blacklist', 'methods'] as $property) { if (isset($config[$feature][$property])) { - $container->setParameter(sprintf('tracing.%s.%s', $feature, $property), $config[$feature][$property]); + $container->setParameter(\sprintf('tracing.%s.%s', $feature, $property), $config[$feature][$property]); } } } @@ -281,7 +281,7 @@ protected function loadLogging(array $config, ContainerBuilder $container): void } foreach ($config['handlers'] as $handler) { - if ($container->hasDefinition(sprintf('monolog.handler.%s', $handler))) { + if ($container->hasDefinition(\sprintf('monolog.handler.%s', $handler))) { $container->getDefinition(\Instrumentation\Logging\Processor\TraceContextProcessor::class) ->addTag('monolog.processor', ['handler' => $handler]); } diff --git a/src/Http/HttpMessageHelper.php b/src/Http/HttpMessageHelper.php index dc4ad4a..0b7e294 100644 --- a/src/Http/HttpMessageHelper.php +++ b/src/Http/HttpMessageHelper.php @@ -21,7 +21,7 @@ public static function formatHeadersForSpanAttribute(array $headers): string $lines = []; foreach ($headers as $name => $values) { foreach ($values as $value) { - $lines[] = sprintf('%s: %s', mb_strtolower($name), $value); + $lines[] = \sprintf('%s: %s', mb_strtolower($name), $value); } } diff --git a/src/Http/TracedResponse.php b/src/Http/TracedResponse.php index 7f15dce..a462a5c 100644 --- a/src/Http/TracedResponse.php +++ b/src/Http/TracedResponse.php @@ -123,7 +123,7 @@ public static function stream(HttpClientInterface $client, iterable $responses, foreach ($responses as $r) { if (!$r instanceof self) { - throw new \TypeError(sprintf('"%s::stream()" expects parameter 1 to be an iterable of TracedResponse objects, "%s" given.', TracingHttpClient::class, get_debug_type($r))); + throw new \TypeError(\sprintf('"%s::stream()" expects parameter 1 to be an iterable of TracedResponse objects, "%s" given.', TracingHttpClient::class, get_debug_type($r))); } $traceableMap[$r->response] = $r; diff --git a/src/Http/TracingHttpClient.php b/src/Http/TracingHttpClient.php index 5cda904..18a2f94 100644 --- a/src/Http/TracingHttpClient.php +++ b/src/Http/TracingHttpClient.php @@ -70,7 +70,7 @@ protected function getExtraSpanAttributes(array|null $attributes): array } if (!\is_array($attributes)) { - throw new \RuntimeException(sprintf('Extra span attributes must be a comma separated list of attributes or an array. %s given.', get_debug_type($attributes))); + throw new \RuntimeException(\sprintf('Extra span attributes must be a comma separated list of attributes or an array. %s given.', get_debug_type($attributes))); } return $attributes; diff --git a/src/Metrics/EventSubscriber/RequestEventSubscriber.php b/src/Metrics/EventSubscriber/RequestEventSubscriber.php index c906771..09240a5 100644 --- a/src/Metrics/EventSubscriber/RequestEventSubscriber.php +++ b/src/Metrics/EventSubscriber/RequestEventSubscriber.php @@ -78,7 +78,7 @@ public function onTerminate(Event\TerminateEvent $event): void } $time = microtime(true) - $event->getRequest()->server->get('REQUEST_TIME_FLOAT'); - $code = sprintf('%sxx', substr((string) $event->getResponse()->getStatusCode(), 0, 1)); + $code = \sprintf('%sxx', substr((string) $event->getResponse()->getStatusCode(), 0, 1)); $operation = $this->mainSpanContext?->getOperationName() ?: 'unknown'; $this->registry->getGauge('requests_handling')->dec(); diff --git a/src/Metrics/Meter.php b/src/Metrics/Meter.php index 86426c1..dc39ce8 100644 --- a/src/Metrics/Meter.php +++ b/src/Metrics/Meter.php @@ -58,7 +58,7 @@ public function createCounter(string $name, string|null $unit = null, string|nul */ public function createObservableCounter(string $name, string|null $unit = null, string|null $description = null, $advisory = [], callable ...$callbacks): ObservableCounterInterface { - throw new \LogicException(sprintf('Method %s is not implemented', __METHOD__)); + throw new \LogicException(\sprintf('Method %s is not implemented', __METHOD__)); } /** @@ -95,7 +95,7 @@ public function createHistogram(string $name, string|null $unit = null, string|n */ public function createObservableGauge(string $name, string|null $unit = null, string|null $description = null, $advisory = [], callable ...$callbacks): ObservableGaugeInterface { - throw new \LogicException(sprintf('Method %s is not implemented', __METHOD__)); + throw new \LogicException(\sprintf('Method %s is not implemented', __METHOD__)); } /** @@ -131,7 +131,7 @@ public function createUpDownCounter(string $name, string|null $unit = null, stri */ public function createObservableUpDownCounter(string $name, string|null $unit = null, string|null $description = null, $advisory = [], callable ...$callbacks): ObservableUpDownCounterInterface { - throw new \LogicException(sprintf('Method %s is not implemented', __METHOD__)); + throw new \LogicException(\sprintf('Method %s is not implemented', __METHOD__)); } public function batchObserve( @@ -139,6 +139,6 @@ public function batchObserve( AsynchronousInstrument $instrument, AsynchronousInstrument ...$instruments ): ObservableCallbackInterface { - throw new \LogicException(sprintf('Method %s is not implemented', __METHOD__)); + throw new \LogicException(\sprintf('Method %s is not implemented', __METHOD__)); } } diff --git a/src/Metrics/Registry.php b/src/Metrics/Registry.php index ca89b65..cba3534 100644 --- a/src/Metrics/Registry.php +++ b/src/Metrics/Registry.php @@ -63,7 +63,7 @@ private function getMetric(string $name): MetricDefinition { if (!isset($this->instantiated[$name])) { if (!isset($this->metrics[$name])) { - throw new \InvalidArgumentException(sprintf('No metric registered with that name: "%s".', $name)); + throw new \InvalidArgumentException(\sprintf('No metric registered with that name: "%s".', $name)); } /** diff --git a/src/Semantics/Attribute/ClientRequestAttributeProvider.php b/src/Semantics/Attribute/ClientRequestAttributeProvider.php index 1f3c73e..cec2f3c 100644 --- a/src/Semantics/Attribute/ClientRequestAttributeProvider.php +++ b/src/Semantics/Attribute/ClientRequestAttributeProvider.php @@ -36,7 +36,7 @@ public function getAttributes(string $method, string $url, array $headers = []): $headers[$header] = implode(',', $headers[$header]); } - $attributes[sprintf('http.request.header.%s', str_replace('-', '_', $header))] = $headers[$header]; + $attributes[\sprintf('http.request.header.%s', str_replace('-', '_', $header))] = $headers[$header]; } $components = parse_url($url); diff --git a/src/Semantics/Attribute/ServerRequestAttributeProvider.php b/src/Semantics/Attribute/ServerRequestAttributeProvider.php index 6e7392d..56daeed 100644 --- a/src/Semantics/Attribute/ServerRequestAttributeProvider.php +++ b/src/Semantics/Attribute/ServerRequestAttributeProvider.php @@ -44,7 +44,7 @@ public function getAttributes(Request $request): array } foreach ($this->capturedHeaders as $header) { - $attributes[sprintf('http.response.header.%s', str_replace('-', '_', $header))] = [(string) $request->headers->get($header, '')]; + $attributes[\sprintf('http.response.header.%s', str_replace('-', '_', $header))] = [(string) $request->headers->get($header, '')]; } return array_filter($attributes); diff --git a/src/Semantics/OperationName/ClientRequestOperationNameResolver.php b/src/Semantics/OperationName/ClientRequestOperationNameResolver.php index b91602a..b8b5bf6 100644 --- a/src/Semantics/OperationName/ClientRequestOperationNameResolver.php +++ b/src/Semantics/OperationName/ClientRequestOperationNameResolver.php @@ -15,6 +15,6 @@ public function getOperationName(string $method, string $url): string { $url = parse_url($url); - return sprintf('http.%s %s://%s', strtolower($method), $url['scheme'] ?? 'http', $url['host'] ?? 'unknown'); + return \sprintf('http.%s %s://%s', strtolower($method), $url['scheme'] ?? 'http', $url['host'] ?? 'unknown'); } } diff --git a/src/Semantics/OperationName/CommandOperationNameResolver.php b/src/Semantics/OperationName/CommandOperationNameResolver.php index ce7d7ed..fbfc848 100644 --- a/src/Semantics/OperationName/CommandOperationNameResolver.php +++ b/src/Semantics/OperationName/CommandOperationNameResolver.php @@ -21,6 +21,6 @@ public function getOperationName(Command|null $command): string $name = $command->getName() ?: $command->getDefaultName(); } - return sprintf('cli %s', $name); + return \sprintf('cli %s', $name); } } diff --git a/src/Semantics/OperationName/MessageOperationNameResolver.php b/src/Semantics/OperationName/MessageOperationNameResolver.php index 78d6071..a3011e0 100644 --- a/src/Semantics/OperationName/MessageOperationNameResolver.php +++ b/src/Semantics/OperationName/MessageOperationNameResolver.php @@ -25,6 +25,6 @@ public function getOperationName(Envelope $envelope, string $operation): string $name = $stamp->getOperationName(); } - return sprintf('message.%s %s', $name, $operation); + return \sprintf('message.%s %s', $name, $operation); } } diff --git a/src/Semantics/OperationName/RouteNameServerRequestOperationNameResolver.php b/src/Semantics/OperationName/RouteNameServerRequestOperationNameResolver.php index 215bf6b..4d488a1 100644 --- a/src/Semantics/OperationName/RouteNameServerRequestOperationNameResolver.php +++ b/src/Semantics/OperationName/RouteNameServerRequestOperationNameResolver.php @@ -21,6 +21,6 @@ public function getOperationName(Request $request): string $routeName = $request->getPathInfo(); } - return sprintf('http.%s %s', strtolower($request->getMethod()), $routeName); + return \sprintf('http.%s %s', strtolower($request->getMethod()), $routeName); } } diff --git a/src/Semantics/OperationName/RoutePathServerRequestOperationNameResolver.php b/src/Semantics/OperationName/RoutePathServerRequestOperationNameResolver.php index f1c8dce..74fddfa 100644 --- a/src/Semantics/OperationName/RoutePathServerRequestOperationNameResolver.php +++ b/src/Semantics/OperationName/RoutePathServerRequestOperationNameResolver.php @@ -31,6 +31,6 @@ public function getOperationName(Request $request): string $path = $request->getPathInfo(); } - return sprintf('http.%s %s', strtolower($request->getMethod()), $path); + return \sprintf('http.%s %s', strtolower($request->getMethod()), $path); } } diff --git a/src/Tracing/Instrumentation/EventSubscriber/RequestEventSubscriber.php b/src/Tracing/Instrumentation/EventSubscriber/RequestEventSubscriber.php index 5215b8d..4c5c395 100644 --- a/src/Tracing/Instrumentation/EventSubscriber/RequestEventSubscriber.php +++ b/src/Tracing/Instrumentation/EventSubscriber/RequestEventSubscriber.php @@ -96,7 +96,7 @@ public function onRouteResolved(Event\RequestEvent $event): void $span = $this->getSpanForRequest($request); - $span->updateName(sprintf('sf.controller.%s', $event->isMainRequest() ? 'main' : 'sub')); + $span->updateName(\sprintf('sf.controller.%s', $event->isMainRequest() ? 'main' : 'sub')); $span->setAttribute('sf.controller', $controller); if ($event->isMainRequest()) { diff --git a/src/Tracing/Instrumentation/LogHandler/TracingHandler.php b/src/Tracing/Instrumentation/LogHandler/TracingHandler.php index 02e64e0..681194b 100644 --- a/src/Tracing/Instrumentation/LogHandler/TracingHandler.php +++ b/src/Tracing/Instrumentation/LogHandler/TracingHandler.php @@ -57,7 +57,7 @@ protected function write(LogRecord $record): void $span = match ($this->strategy) { self::STRATEGY_MAIN_SPAN => $this->mainSpanContext->getMainSpan(), self::STRATEGY_CURRENT_SPAN => Span::getCurrent(), - default => throw new \InvalidArgumentException(sprintf('Unkown strategy "%s".', $this->strategy)) + default => throw new \InvalidArgumentException(\sprintf('Unkown strategy "%s".', $this->strategy)) }; if (isset($record->context['exception']) && $record->context['exception'] instanceof \Throwable) { diff --git a/src/Tracing/Propagation/Doctrine/TraceContextInfoProvider.php b/src/Tracing/Propagation/Doctrine/TraceContextInfoProvider.php index ceac5c2..8f0128c 100644 --- a/src/Tracing/Propagation/Doctrine/TraceContextInfoProvider.php +++ b/src/Tracing/Propagation/Doctrine/TraceContextInfoProvider.php @@ -40,7 +40,7 @@ public function getTraceContext(): array $info['framework'] = 'symfony-'.Kernel::VERSION; try { - $info['db_driver'] = sprintf('doctrine/dbal-%s', InstalledVersions::getVersion('doctrine/dbal')); + $info['db_driver'] = \sprintf('doctrine/dbal-%s', InstalledVersions::getVersion('doctrine/dbal')); } catch (\Exception) { // Ignore } diff --git a/src/Tracing/Propagation/EventSubscriber/RequestEventSubscriber.php b/src/Tracing/Propagation/EventSubscriber/RequestEventSubscriber.php index 7741470..d8ba0b3 100644 --- a/src/Tracing/Propagation/EventSubscriber/RequestEventSubscriber.php +++ b/src/Tracing/Propagation/EventSubscriber/RequestEventSubscriber.php @@ -50,7 +50,7 @@ public function onRequest(Event\RequestEvent $event): void $sampled = $this->incomingTraceResolver->isSampled($request); if (null !== $traceId && null !== $spanId && null !== $sampled) { - $w3cHeader = sprintf('00-%s-%s-%s', $traceId, $spanId, $sampled ? '01' : '00'); + $w3cHeader = \sprintf('00-%s-%s-%s', $traceId, $spanId, $sampled ? '01' : '00'); ContextInitializer::fromW3CHeader($w3cHeader); return; diff --git a/src/Tracing/Propagation/Messenger/PropagationStrategyStamp.php b/src/Tracing/Propagation/Messenger/PropagationStrategyStamp.php index c8a5207..7428419 100644 --- a/src/Tracing/Propagation/Messenger/PropagationStrategyStamp.php +++ b/src/Tracing/Propagation/Messenger/PropagationStrategyStamp.php @@ -19,7 +19,7 @@ final class PropagationStrategyStamp implements StampInterface public function __construct(private string $strategy) { if (!\in_array($strategy, [self::STRATEGY_LINK, self::STRATEGY_PARENT])) { - throw new \InvalidArgumentException(sprintf('"%s" is not a valid value for strategy', $strategy)); + throw new \InvalidArgumentException(\sprintf('"%s" is not a valid value for strategy', $strategy)); } }