From d51fce850333b142c73432417351b4c007a67bda Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Wed, 2 Oct 2024 13:33:32 +1000 Subject: [PATCH] 8.4: fixing some implicit nullable params --- .../SDK/Configuration/Loader/YamlExtensionFileLoader.php | 6 +++--- .../SDK/Configuration/Loader/YamlSymfonyFileLoader.php | 6 +++--- tests/Unit/SDK/Metrics/MeterTest.php | 2 +- tests/Unit/SDK/Trace/SamplerFactoryTest.php | 4 ++-- .../SDK/Trace/SpanExporter/FriendlySpanConverterTest.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) 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 1558e7ca1..3aa29b8d9 100644 --- a/tests/Unit/SDK/Metrics/MeterTest.php +++ b/tests/Unit/SDK/Metrics/MeterTest.php @@ -391,7 +391,7 @@ public function test_update_configurator(): 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);