Skip to content

Commit

Permalink
Replace implicitly nullable parameters for PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
JeppeKnockaert committed Dec 3, 2024
1 parent c1cde2d commit a3e7f6a
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/DDTrace/Integrations/AMQP/AMQPIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public function setGenericTags(
SpanData $span,
string $name,
string $spanKind,
string $resourceDetail = null,
?string $resourceDetail = null,
$exception = null
) {
$span->name = "amqp.$name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CodeIgniterIntegration extends Integration
/**
* Add instrumentation to CodeIgniter requests
*/
public function init(\CI_Router $router = null): int
public function init(?\CI_Router $router = null): int
{
$integration = $this;
$rootSpan = \DDTrace\root_span();
Expand Down
18 changes: 9 additions & 9 deletions src/DDTrace/Integrations/Logs/LogsIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public static function laminasLogLevelToString(int $logLevel, string $fallback):
}

public static function getPlaceholders(
string $traceIdSubstitute = null,
string $spanIdSubstitute = null
?string $traceIdSubstitute = null,
?string $spanIdSubstitute = null
): array {
$placeholders = [
'%dd.trace_id%' => 'dd.trace_id="' . ($traceIdSubstitute ?? logs_correlation_trace_id()) . '"',
Expand Down Expand Up @@ -84,8 +84,8 @@ public static function messageContainsPlaceholders(string $message): bool

public static function appendTraceIdentifiersToMessage(
string $message,
string $traceIdSubstitute = null,
string $spanIdSubstitute = null
?string $traceIdSubstitute = null,
?string $spanIdSubstitute = null
): string {
$placeholders = LogsIntegration::getPlaceholders($traceIdSubstitute, $spanIdSubstitute);
LogsIntegration::replacePlaceholders($message, $placeholders);
Expand All @@ -108,9 +108,9 @@ public static function appendTraceIdentifiersToMessage(

public static function replacePlaceholders(
string $message,
array $placeholders = null,
string $traceIdSubstitute = null,
string $spanIdSubstitute = null
?array $placeholders = null,
?string $traceIdSubstitute = null,
?string $spanIdSubstitute = null
): string {
return strtr(
$message,
Expand All @@ -120,8 +120,8 @@ public static function replacePlaceholders(

public static function addTraceIdentifiersToContext(
array $context,
string $traceIdSubstitute = null,
string $spanIdSubstitute = null
?string $traceIdSubstitute = null,
?string $spanIdSubstitute = null
): array {
if (!isset($context['dd.trace_id'])) {
$context['dd.trace_id'] = $traceIdSubstitute ?? logs_correlation_trace_id();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static function setCommonTags(
WordPressIntegration $integration,
SpanData $span,
string $name,
string $resource = null
?string $resource = null
) {
$span->name = $name;
$span->resource = $resource ?: $name;
Expand Down
10 changes: 5 additions & 5 deletions src/DDTrace/OpenTelemetry/Span.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function addLink(SpanContextInterface $context, iterable $attributes = []
/**
* @inheritDoc
*/
public function addEvent(string $name, iterable $attributes = [], int $timestamp = null): SpanInterface
public function addEvent(string $name, iterable $attributes = [], ?int $timestamp = null): SpanInterface
{
if (!$this->hasEnded()) {
$this->span->events[] = new SpanEvent(
Expand Down Expand Up @@ -427,7 +427,7 @@ public function updateName(string $name): SpanInterface
/**
* @inheritDoc
*/
public function setStatus(string $code, string $description = null): SpanInterface
public function setStatus(string $code, ?string $description = null): SpanInterface
{
if ($this->hasEnded()) {
return $this;
Expand Down Expand Up @@ -459,7 +459,7 @@ public function setStatus(string $code, string $description = null): SpanInterfa
/**
* @inheritDoc
*/
public function end(int $endEpochNanos = null): void
public function end(?int $endEpochNanos = null): void
{
if ($this->hasEnded()) {
return;
Expand All @@ -472,7 +472,7 @@ public function end(int $endEpochNanos = null): void
$this->spanProcessor->onEnd($this);
}

public function endOTelSpan(int $endEpochNanos = null): void
public function endOTelSpan(?int $endEpochNanos = null): void
{
if ($this->hasEnded()) {
return;
Expand Down Expand Up @@ -572,7 +572,7 @@ private function updateSpanEvents()
$this->totalRecordedEvents = count($otel);
}

private function createAndSaveSpanLink(SpanContextInterface $context, iterable $attributes = [], LinkInterface $link = null)
private function createAndSaveSpanLink(SpanContextInterface $context, iterable $attributes = [], ?LinkInterface $link = null)
{
$spanLink = new SpanLink();
$spanLink->traceId = $context->getTraceId();
Expand Down
2 changes: 1 addition & 1 deletion src/DDTrace/OpenTelemetry/SpanBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function addLink(SpanContextInterface $context, iterable $attributes = []
return $this;
}

public function addEvent(string $name, iterable $attributes = [], int $timestamp = null): SpanBuilderInterface
public function addEvent(string $name, iterable $attributes = [], ?int $timestamp = null): SpanBuilderInterface
{
$this->events[] = new Event(
$name,
Expand Down
4 changes: 2 additions & 2 deletions src/DDTrace/OpenTracer/Tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class Tracer implements OTTracer
/**
* @param TracerInterface|null $tracer
*/
public function __construct(TracerInterface $tracer = null)
public function __construct(?TracerInterface $tracer = null)
{
$this->tracer = $tracer ?: GlobalTracer::get();
}
Expand All @@ -39,7 +39,7 @@ public function __construct(TracerInterface $tracer = null)
* @param array $config
* @return self
*/
public static function make(Transport $transport = null, array $propagators = null, array $config = [])
public static function make(?Transport $transport = null, ?array $propagators = null, array $config = [])
{
return new self(
new DDTracer($transport, $propagators, $config)
Expand Down
4 changes: 2 additions & 2 deletions src/DDTrace/OpenTracer1/Tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class Tracer implements OTTracer
/**
* @param TracerInterface|null $tracer
*/
public function __construct(TracerInterface $tracer = null)
public function __construct(?TracerInterface $tracer = null)
{
$this->tracer = $tracer ?: GlobalTracer::get();
}
Expand All @@ -41,7 +41,7 @@ public function __construct(TracerInterface $tracer = null)
* @param array $config
* @return self
*/
public static function make(Transport $transport = null, array $propagators = null, array $config = [])
public static function make(?Transport $transport = null, ?array $propagators = null, array $config = [])
{
return new self(
new DDTracer($transport, $propagators, $config)
Expand Down
2 changes: 1 addition & 1 deletion src/DDTrace/ScopeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class ScopeManager implements ScopeManagerInterface
*/
private $rootContext;

public function __construct(SpanContext $rootContext = null)
public function __construct(?SpanContext $rootContext = null)
{
$this->rootContext = $rootContext;
}
Expand Down
2 changes: 1 addition & 1 deletion src/DDTrace/Tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final class Tracer implements TracerInterface
* @param Propagator[] $propagators
* @param array $config
*/
public function __construct(Transport $transport = null, array $propagators = null, array $config = [])
public function __construct(?Transport $transport = null, ?array $propagators = null, array $config = [])
{
$this->transport = $transport ?: new Internal();
$textMapPropagator = new TextMap($this);
Expand Down
14 changes: 7 additions & 7 deletions src/ddtrace_php_api.stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function addLink(\OpenTelemetry\API\Trace\SpanContextInterface $context,
/**
* @inheritDoc
*/
public function addEvent(string $name, iterable $attributes = [], int $timestamp = null) : \OpenTelemetry\API\Trace\SpanInterface
public function addEvent(string $name, iterable $attributes = [], ?int $timestamp = null) : \OpenTelemetry\API\Trace\SpanInterface
{
}
/**
Expand All @@ -174,16 +174,16 @@ public function updateName(string $name) : \OpenTelemetry\API\Trace\SpanInterfac
/**
* @inheritDoc
*/
public function setStatus(string $code, string $description = null) : \OpenTelemetry\API\Trace\SpanInterface
public function setStatus(string $code, ?string $description = null) : \OpenTelemetry\API\Trace\SpanInterface
{
}
/**
* @inheritDoc
*/
public function end(int $endEpochNanos = null) : void
public function end(?int $endEpochNanos = null) : void
{
}
public function endOTelSpan(int $endEpochNanos = null) : void
public function endOTelSpan(?int $endEpochNanos = null) : void
{
}
public function getResource() : \OpenTelemetry\SDK\Resource\ResourceInfo
Expand Down Expand Up @@ -212,7 +212,7 @@ public function setParent($context) : \OpenTelemetry\API\Trace\SpanBuilderInterf
public function addLink(\OpenTelemetry\API\Trace\SpanContextInterface $context, iterable $attributes = []) : \OpenTelemetry\API\Trace\SpanBuilderInterface
{
}
public function addEvent(string $name, iterable $attributes = [], int $timestamp = null) : \OpenTelemetry\API\Trace\SpanBuilderInterface
public function addEvent(string $name, iterable $attributes = [], ?int $timestamp = null) : \OpenTelemetry\API\Trace\SpanBuilderInterface
{
}
public function recordException(\Throwable $exception, iterable $attributes = []) : \OpenTelemetry\API\Trace\SpanBuilderInterface
Expand Down Expand Up @@ -506,7 +506,7 @@ public function close();
namespace DDTrace {
final class ScopeManager implements \DDTrace\Contracts\ScopeManager
{
public function __construct(\DDTrace\SpanContext $rootContext = null)
public function __construct(?\DDTrace\SpanContext $rootContext = null)
{
}
/**
Expand Down Expand Up @@ -1341,7 +1341,7 @@ final class Tracer implements \DDTrace\Contracts\Tracer
* @param Propagator[] $propagators
* @param array $config
*/
public function __construct(\DDTrace\Transport $transport = null, array $propagators = null, array $config = [])
public function __construct(?\DDTrace\Transport $transport = null, ?array $propagators = null, array $config = [])
{
}
public function limited()
Expand Down

0 comments on commit a3e7f6a

Please sign in to comment.