diff --git a/src/Config/SDK/Configuration/Loader/YamlExtensionFileLoader.php b/src/Config/SDK/Configuration/Loader/YamlExtensionFileLoader.php index 8a97c8f17..9356dcb4d 100644 --- a/src/Config/SDK/Configuration/Loader/YamlExtensionFileLoader.php +++ b/src/Config/SDK/Configuration/Loader/YamlExtensionFileLoader.php @@ -18,12 +18,12 @@ final class YamlExtensionFileLoader extends FileLoader { - public function __construct(private readonly ConfigurationLoader $configuration, FileLocatorInterface $locator, string $env = null) + public function __construct(private readonly ConfigurationLoader $configuration, FileLocatorInterface $locator, ?string $env = null) { parent::__construct($locator, $env); } - public function load(mixed $resource, string $type = null): mixed + public function load(mixed $resource, ?string $type = null): mixed { assert(extension_loaded('yaml')); @@ -39,7 +39,7 @@ public function load(mixed $resource, string $type = null): mixed return null; } - public function supports(mixed $resource, string $type = null): bool + public function supports(mixed $resource, ?string $type = null): bool { return extension_loaded('yaml') && is_string($resource) diff --git a/src/Config/SDK/Configuration/Loader/YamlSymfonyFileLoader.php b/src/Config/SDK/Configuration/Loader/YamlSymfonyFileLoader.php index 25d1b02d3..222839144 100644 --- a/src/Config/SDK/Configuration/Loader/YamlSymfonyFileLoader.php +++ b/src/Config/SDK/Configuration/Loader/YamlSymfonyFileLoader.php @@ -20,12 +20,12 @@ final class YamlSymfonyFileLoader extends FileLoader { - public function __construct(private readonly ConfigurationLoader $configuration, FileLocatorInterface $locator, string $env = null) + public function __construct(private readonly ConfigurationLoader $configuration, FileLocatorInterface $locator, ?string $env = null) { parent::__construct($locator, $env); } - public function load(mixed $resource, string $type = null): mixed + public function load(mixed $resource, ?string $type = null): mixed { assert(class_exists(Yaml::class)); @@ -43,7 +43,7 @@ public function load(mixed $resource, string $type = null): mixed return null; } - public function supports(mixed $resource, string $type = null): bool + public function supports(mixed $resource, ?string $type = null): bool { return class_exists(Yaml::class) && is_string($resource) diff --git a/tests/Unit/SDK/Metrics/MeterTest.php b/tests/Unit/SDK/Metrics/MeterTest.php index fa6fd83a7..02af7e0ef 100644 --- a/tests/Unit/SDK/Metrics/MeterTest.php +++ b/tests/Unit/SDK/Metrics/MeterTest.php @@ -376,7 +376,7 @@ public function test_uses_default_view_if_null_views_returned(): void /** * @param iterable $metricReaders */ - private function createMeterProviderForMetricFactory(MetricFactoryInterface $metricFactory, ViewRegistryInterface $viewRegistry = null, iterable $metricReaders = []): MeterProvider + private function createMeterProviderForMetricFactory(MetricFactoryInterface $metricFactory, ?ViewRegistryInterface $viewRegistry = null, iterable $metricReaders = []): MeterProvider { return new MeterProvider( null, diff --git a/tests/Unit/SDK/Trace/SamplerFactoryTest.php b/tests/Unit/SDK/Trace/SamplerFactoryTest.php index 6e73906a1..52534046a 100644 --- a/tests/Unit/SDK/Trace/SamplerFactoryTest.php +++ b/tests/Unit/SDK/Trace/SamplerFactoryTest.php @@ -17,7 +17,7 @@ class SamplerFactoryTest extends TestCase use TestState; #[DataProvider('samplerProvider')] - public function test_create_sampler_from_environment(string $samplerName, string $expected, string $arg = null): void + public function test_create_sampler_from_environment(string $samplerName, string $expected, ?string $arg = null): void { $this->setEnvironmentVariable('OTEL_TRACES_SAMPLER', $samplerName); $this->setEnvironmentVariable('OTEL_TRACES_SAMPLER_ARG', $arg); @@ -39,7 +39,7 @@ public static function samplerProvider(): array ]; } #[DataProvider('invalidSamplerProvider')] - public function test_throws_exception_for_invalid_or_unsupported(?string $sampler, string $arg = null): void + public function test_throws_exception_for_invalid_or_unsupported(?string $sampler, ?string $arg = null): void { $this->setEnvironmentVariable('OTEL_TRACES_SAMPLER', $sampler); $this->setEnvironmentVariable('OTEL_TRACES_SAMPLER_ARG', $arg); diff --git a/tests/Unit/SDK/Trace/SpanExporter/FriendlySpanConverterTest.php b/tests/Unit/SDK/Trace/SpanExporter/FriendlySpanConverterTest.php index 118ae66db..95285378c 100644 --- a/tests/Unit/SDK/Trace/SpanExporter/FriendlySpanConverterTest.php +++ b/tests/Unit/SDK/Trace/SpanExporter/FriendlySpanConverterTest.php @@ -178,7 +178,7 @@ private function createInstrumentationScopeMock(): InstrumentationScopeInterface return $mock; } - private function createSpanContextMock(string $spanId, string $traceId = '0', string $traceState = null): SpanContextInterface + private function createSpanContextMock(string $spanId, string $traceId = '0', ?string $traceState = null): SpanContextInterface { $mock = $this->createMock(SpanContextInterface::class); diff --git a/tests/Unit/SDK/Trace/SpanTest.php b/tests/Unit/SDK/Trace/SpanTest.php index a17dd1554..647558a5d 100644 --- a/tests/Unit/SDK/Trace/SpanTest.php +++ b/tests/Unit/SDK/Trace/SpanTest.php @@ -835,8 +835,8 @@ private function createTestRootSpan(): Span */ private function createTestSpan( int $kind = API\SpanKind::KIND_INTERNAL, - SpanLimits $spanLimits = null, - string $parentSpanId = null, + ?SpanLimits $spanLimits = null, + ?string $parentSpanId = null, iterable $attributes = [], array $links = [], ): Span { diff --git a/tests/Unit/SDK/Util/SpanData.php b/tests/Unit/SDK/Util/SpanData.php index 1c77f5531..dc814f645 100644 --- a/tests/Unit/SDK/Util/SpanData.php +++ b/tests/Unit/SDK/Util/SpanData.php @@ -102,7 +102,7 @@ public function setEvents(array $events): self return $this; } - public function addEvent(string $name, AttributesInterface $attributes, int $timestamp = null): self + public function addEvent(string $name, AttributesInterface $attributes, ?int $timestamp = null): self { $this->events[] = new SDK\Event($name, $timestamp ?? Clock::getDefault()->now(), $attributes);