Skip to content

Commit a668bcd

Browse files
committed
Fix CS and refactoring
1 parent 3b7243e commit a668bcd

File tree

12 files changed

+48
-45
lines changed

12 files changed

+48
-45
lines changed

instrumentation/symfony/OtelSdkBundle/DependencyInjection/ConfigMappings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ interface ConfigMappings
2626
Configuration::OTLP_GRPC_EXPORTER => SpanExporters::OTLP_GRPC,
2727
Configuration::ZIPKIN_TO_NEWRELIC_EXPORTER => SpanExporters::ZIPKIN_TO_NEWRELIC,
2828
];
29-
}
29+
}

instrumentation/symfony/OtelSdkBundle/DependencyInjection/OtelSdkExtension.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ private function createAndRegisterExporterClassDefinition(string $exporterKey, a
292292
}
293293

294294
/**
295-
* @param $config
295+
* @param array $config
296296
* @return array
297297
*/
298-
private function normalizeExporterOptions($config): array
298+
private function normalizeExporterOptions(array $config): array
299299
{
300300
$definedOptions = (ExporterFactory::create($this->resolveExporterClass($config)))
301301
->getOptionsResolver()
@@ -335,10 +335,10 @@ private function createExporterId(string $exporterKey): string
335335
}
336336

337337
/**
338-
* @param $config
338+
* @param array $config
339339
* @return bool
340340
*/
341-
private function isExporterClassConfiguration($config): bool
341+
private function isExporterClassConfiguration(array $config): bool
342342
{
343343
if (in_array($config[Conf::TYPE_NODE], Conf::EXPORTERS_NODE_VALUES, true)) {
344344
return true;
@@ -351,10 +351,10 @@ private function isExporterClassConfiguration($config): bool
351351
}
352352

353353
/**
354-
* @param $config
354+
* @param array $config
355355
* @return bool
356356
*/
357-
private function isExporterReferenceConfiguration($config): bool
357+
private function isExporterReferenceConfiguration(array $config): bool
358358
{
359359
return $config[Conf::TYPE_NODE] === Conf::CUSTOM_TYPE && isset($config[Conf::ID_NODE]);
360360
}
@@ -562,7 +562,7 @@ private function getContainer(): ContainerBuilder
562562
return $this->container;
563563
}
564564

565-
private function loadDefaultConfig()
565+
private function loadDefaultConfig(): void
566566
{
567567
try {
568568
self::createPhpFileLoader($this->container)

instrumentation/symfony/OtelSdkBundle/DependencyInjection/Samplers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ interface Samplers
1919
self::TRACE_ID_RATIO_BASED,
2020
];
2121
public const DEFAULT_SAMPLER = self::ALWAYS_ON;
22-
}
22+
}

instrumentation/symfony/OtelSdkBundle/DependencyInjection/SpanProcessors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ interface SpanProcessors
2020
];
2121
public const DEFAULT = self::BATCH;
2222
public const NAMESPACE = 'OpenTelemetry\SDK\Trace\SpanProcessor';
23-
}
23+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace OpenTelemetry\Instrumentation\Symfony\OtelSdkBundle\DependencyInjection;
46

57
interface Tracer
68
{
79
public const DEFAULT_KEY = 'io.opentelemetry.contrib.php';
8-
}
10+
}

instrumentation/symfony/OtelSdkBundle/Factory/GenericFactoryTrait.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
use InvalidArgumentException;
88
use ReflectionClass;
9-
use ReflectionParameter;
9+
use ReflectionException;
1010
use ReflectionNamedType;
11+
use ReflectionParameter;
1112
use Symfony\Component\OptionsResolver\OptionsResolver;
1213
use Throwable;
13-
use ReflectionException;
1414

1515
trait GenericFactoryTrait
1616
{
@@ -42,7 +42,7 @@ public static function create(string $buildClass, ?OptionsResolver $resolver = n
4242

4343
/**
4444
* @param array $options
45-
* @throws \ReflectionException
45+
* @throws ReflectionException
4646
* @return object
4747
*/
4848
private function doBuild(array $options = []): object
@@ -131,7 +131,7 @@ public function getOptionsResolver(): OptionsResolver
131131
return $this->resolver;
132132
}
133133

134-
private function init(string $buildClass, OptionsResolver $resolver)
134+
private function init(string $buildClass, OptionsResolver $resolver): void
135135
{
136136
try {
137137
$this->setupReflectionClass($buildClass);
@@ -146,7 +146,7 @@ private function init(string $buildClass, OptionsResolver $resolver)
146146
$this->inspectExporter();
147147
}
148148

149-
private function validateExporterClass(string $buildClass)
149+
private function validateExporterClass(string $buildClass): void
150150
{
151151
if (!class_exists($buildClass)) {
152152
throw new InvalidArgumentException(
@@ -159,20 +159,20 @@ private function validateExporterClass(string $buildClass)
159159
* @param string $buildClass
160160
* @throws ReflectionException
161161
*/
162-
private function setupReflectionClass(string $buildClass)
162+
private function setupReflectionClass(string $buildClass): void
163163
{
164164
$this->validateExporterClass($buildClass);
165165

166166
/** @psalm-suppress ArgumentTypeCoercion */
167167
$this->reflectionClass = new ReflectionClass($buildClass);
168168
}
169169

170-
private function setOptionsResolver(OptionsResolver $resolver)
170+
private function setOptionsResolver(OptionsResolver $resolver): void
171171
{
172172
$this->resolver = $resolver;
173173
}
174174

175-
private function inspectExporter()
175+
private function inspectExporter(): void
176176
{
177177
if (!$constructor = $this->getReflectionClass()->getConstructor()) {
178178
return;
@@ -205,13 +205,13 @@ private function inspectExporter()
205205
);
206206
}
207207

208-
private function addOption(int $position, string $option)
208+
private function addOption(int $position, string $option): void
209209
{
210210
$this->options[$position] = $option;
211211
$this->getOptionsResolver()->setDefined($option);
212212
}
213213

214-
private function addRequiredOption(string $option)
214+
private function addRequiredOption(string $option): void
215215
{
216216
$this->requiredOptions[] = $option;
217217
$this->getOptionsResolver()->setRequired($option);
@@ -220,22 +220,23 @@ private function addRequiredOption(string $option)
220220
/**
221221
* To be overwritten by implementing classes
222222
* @param ReflectionParameter $parameter
223+
* @param string $option
223224
*/
224-
private function parameterCallback(ReflectionParameter $parameter, string $option)
225+
private function parameterCallback(ReflectionParameter $parameter, string $option): void
225226
{
226227
}
227228

228229
private static function camelToSnakeCase(string $value): string
229230
{
230-
return ltrim(
231-
strtolower(
231+
return strtolower(
232+
ltrim(
232233
preg_replace(
233234
'/[A-Z]([A-Z](?![a-z]))*/',
234235
'_$0',
235236
$value
236-
)
237-
),
238-
'_'
237+
),
238+
'_'
239+
)
239240
);
240241
}
241242
}

instrumentation/symfony/OtelSdkBundle/OtelSdkBundle.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php /** @noinspection SpellCheckingInspection */
1+
<?php
2+
3+
/** @noinspection SpellCheckingInspection */
24

35
declare(strict_types=1);
46

instrumentation/symfony/OtelSdkBundle/Resources/config/sdk.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace OpenTelemetry\Instrumentation\Symfony\OtelSdkBundle\Resources;
66

7-
use OpenTelemetry\Instrumentation\Symfony\OtelSdkBundle\DependencyInjection\Parameters;
87
use OpenTelemetry\Instrumentation\Symfony\OtelSdkBundle\DependencyInjection\Ids;
8+
use OpenTelemetry\Instrumentation\Symfony\OtelSdkBundle\DependencyInjection\Parameters;
99
use OpenTelemetry\Instrumentation\Symfony\OtelSdkBundle\DependencyInjection\Tracer;
1010
use OpenTelemetry\Instrumentation\Symfony\OtelSdkBundle\Util\ConfigHelper;
1111
use OpenTelemetry\Instrumentation\Symfony\OtelSdkBundle\Util\ServiceHelper;
@@ -124,4 +124,3 @@
124124
* @codeCoverageIgnoreEnd
125125
*/
126126
};
127-

instrumentation/symfony/OtelSdkBundle/Trace/ExporterFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use Psr\Http\Client\ClientInterface;
1212
use Psr\Http\Message\RequestFactoryInterface;
1313
use Psr\Http\Message\StreamFactoryInterface;
14-
use ReflectionParameter;
1514
use ReflectionNamedType;
15+
use ReflectionParameter;
1616
use RuntimeException;
1717
use Symfony\Component\OptionsResolver\Options;
1818
use Throwable;
@@ -53,6 +53,9 @@ public function __invoke(array $options = []): SpanExporterInterface
5353
return $this->build($options);
5454
}
5555

56+
/**
57+
* @return void
58+
*/
5659
private function parameterCallback(ReflectionParameter $parameter, string $option)
5760
{
5861
$name = self::camelToSnakeCase($parameter->getName());

instrumentation/symfony/OtelSdkBundle/Util/ExporterDsn.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,13 @@ public function getEndpoint(): string
8484
);
8585
$dsn .= $this->getUser() !== null && $this->getPassword() !== null ? sprintf(
8686
'%s:%s@',
87-
/** @psalm-ignore-nullable-return */
88-
$this->getUser(),
89-
/** @psalm-ignore-nullable-return */
90-
$this->getPassword()
87+
(string)$this->getUser(),
88+
(string)$this->getPassword()
9189
) : '';
9290
$dsn .= $this->getHost();
9391
$dsn .= $this->getPort() !== null ? sprintf(
9492
':%s',
95-
/** @psalm-ignore-nullable-return */
96-
$this->getPort(),
93+
(string)$this->getPort(),
9794
) : '';
9895
$dsn .= $this->getPath() ?? '';
9996

0 commit comments

Comments
 (0)