Skip to content

Commit

Permalink
fix: remove php-cs-fixer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
GCalmels committed Jul 30, 2024
1 parent ffce4f6 commit 4e7c938
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];
}
}
4 changes: 2 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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([])
Expand Down
12 changes: 6 additions & 6 deletions src/DependencyInjection/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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]);
}
}
}
Expand Down Expand Up @@ -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]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/HttpMessageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/TracedResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Http/TracingHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Metrics/EventSubscriber/RequestEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/Metrics/Meter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__));
}

/**
Expand Down Expand Up @@ -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__));
}

/**
Expand Down Expand Up @@ -131,14 +131,14 @@ 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(
callable $callback,
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__));
}
}
2 changes: 1 addition & 1 deletion src/Metrics/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Semantics/Attribute/ClientRequestAttributeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Semantics/Attribute/ServerRequestAttributeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Tracing/Instrumentation/LogHandler/TracingHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit 4e7c938

Please sign in to comment.