Skip to content

Commit

Permalink
84 implicit null (#1394)
Browse files Browse the repository at this point in the history
* 8.4: fixing some implicit nullable params

* fix withspan handler nullable + example (#1377)

- class is nullable for pre hooks
- add phpt tests for withspan and its interaction with auto root span

* fix: update references to logging exporter (#1383)

This exporter has been replaced by the debug exporter and will be removed soon. Related to open-telemetry/opentelemetry-collector#11037

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>

* fix: Update collector tag in example to latest (#1384)

Follow-up from #1383. Debug exporter isn't available until v0.86.0, so this new configuration throws an error when trying to run the collector. `Error: cannot unmarshal the configuration: unknown exporters type "debug" for "debug"` Instead of setting to v0.86.0, I noticed the other docker files omitted the tag (so latest is pulled). I just updated this to match.

* Remove `MeterInterface::isEnabled()` and fix meter config re-enabling (#1387)

* Update SPI dependency to v1. (#1388)

* Fix README badges. (#1389)

* add phpDocumentor instructions to Makefile (#1385)

* add phpDocumentor instructions to Makefile

Signed-off-by: svrnm <neumanns@cisco.com>

* update DEVELOPMENT.md

Signed-off-by: svrnm <neumanns@cisco.com>

---------

Signed-off-by: svrnm <neumanns@cisco.com>

* Update README.md (#1344)

* Fix `IncompatibleReturnValueException` in `MessageFactoryTest` (#1392)

PSR7 `RequestInterface::getUri()` must return `UriInterface`, not `string`; explicit typehint was added in `2.0`.

* more implicit nulls

---------

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
Signed-off-by: svrnm <neumanns@cisco.com>
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
Co-authored-by: Jamie Danielson <jamieedanielson@gmail.com>
Co-authored-by: Tobias Bachert <git@b-privat.de>
Co-authored-by: Chris Lightfoot-Wild <github-clw@wild.me.uk>
Co-authored-by: Severin Neumann <neumanns@cisco.com>
Co-authored-by: Oleg <142805497+devactivity-team@users.noreply.github.com>
  • Loading branch information
7 people authored Oct 2, 2024
1 parent fd24607 commit 0ae2723
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/Config/SDK/Configuration/Loader/YamlSymfonyFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/SDK/Metrics/MeterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public function test_uses_default_view_if_null_views_returned(): void
/**
* @param iterable<MetricReaderInterface&MetricSourceRegistryInterface&DefaultAggregationProviderInterface> $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,
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/SDK/Trace/SamplerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/SDK/Trace/SpanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/SDK/Util/SpanData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 0ae2723

Please sign in to comment.