Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP 8.4] Fixes for implicit nullability deprecation #1297

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/API/Baggage/Propagation/BaggagePropagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function fields(): array
return [self::BAGGAGE];
}

public function inject(&$carrier, PropagationSetterInterface $setter = null, ContextInterface $context = null): void
public function inject(&$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void
{
$setter ??= ArrayAccessGetterSetter::getInstance();
$context ??= Context::getCurrent();
Expand Down Expand Up @@ -70,7 +70,7 @@ public function inject(&$carrier, PropagationSetterInterface $setter = null, Con
}
}

public function extract($carrier, PropagationGetterInterface $getter = null, ContextInterface $context = null): ContextInterface
public function extract($carrier, ?PropagationGetterInterface $getter = null, ?ContextInterface $context = null): ContextInterface
{
$getter ??= ArrayAccessGetterSetter::getInstance();
$context ??= Context::getCurrent();
Expand Down
4 changes: 2 additions & 2 deletions src/API/Trace/Propagation/TraceContextPropagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function fields(): array
}

/** {@inheritdoc} */
public function inject(&$carrier, PropagationSetterInterface $setter = null, ContextInterface $context = null): void
public function inject(&$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void
{
$setter ??= ArrayAccessGetterSetter::getInstance();
$context ??= Context::getCurrent();
Expand All @@ -81,7 +81,7 @@ public function inject(&$carrier, PropagationSetterInterface $setter = null, Con
}

/** {@inheritdoc} */
public function extract($carrier, PropagationGetterInterface $getter = null, ContextInterface $context = null): ContextInterface
public function extract($carrier, ?PropagationGetterInterface $getter = null, ?ContextInterface $context = null): ContextInterface
{
$getter ??= ArrayAccessGetterSetter::getInstance();
$context ??= Context::getCurrent();
Expand Down
4 changes: 2 additions & 2 deletions src/Context/Propagation/NoopTextMapPropagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public function fields(): array
return [];
}

public function extract($carrier, PropagationGetterInterface $getter = null, ContextInterface $context = null): ContextInterface
public function extract($carrier, ?PropagationGetterInterface $getter = null, ?ContextInterface $context = null): ContextInterface
{
return $context ?? Context::getCurrent();
}

public function inject(&$carrier, PropagationSetterInterface $setter = null, ContextInterface $context = null): void
public function inject(&$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void
{
}
}
4 changes: 2 additions & 2 deletions src/Context/Propagation/TextMapPropagatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public function fields() : array;
*
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/context/api-propagators.md#textmap-inject
*/
public function inject(mixed &$carrier, PropagationSetterInterface $setter = null, ContextInterface $context = null): void;
public function inject(mixed &$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void;

/**
* Extracts specific values from the provided carrier into the provided {@see ContextInterface}
* via an {@see PropagationGetterInterface}.
*
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/context/api-propagators.md#textmap-extract
*/
public function extract($carrier, PropagationGetterInterface $getter = null, ContextInterface $context = null): ContextInterface;
public function extract($carrier, ?PropagationGetterInterface $getter = null, ?ContextInterface $context = null): ContextInterface;
}
16 changes: 8 additions & 8 deletions src/SDK/Common/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function has(string $name): bool
return CompositeResolver::instance()->hasVariable($name);
}

public static function getInt(string $key, int $default = null): int
public static function getInt(string $key, ?int $default = null): int
{
return (int) self::validateVariableValue(
CompositeResolver::instance()->resolve(
Expand All @@ -40,7 +40,7 @@ public static function getInt(string $key, int $default = null): int
);
}

public static function getString(string $key, string $default = null): string
public static function getString(string $key, ?string $default = null): string
{
return (string) self::validateVariableValue(
CompositeResolver::instance()->resolve(
Expand All @@ -50,7 +50,7 @@ public static function getString(string $key, string $default = null): string
);
}

public static function getBoolean(string $key, bool $default = null): bool
public static function getBoolean(string $key, ?bool $default = null): bool
{
$resolved = self::validateVariableValue(
CompositeResolver::instance()->resolve(
Expand Down Expand Up @@ -78,7 +78,7 @@ public static function getMixed(string $key, $default = null)
);
}

public static function getMap(string $key, array $default = null): array
public static function getMap(string $key, ?array $default = null): array
{
return MapParser::parse(
CompositeResolver::instance()->resolve(
Expand All @@ -88,7 +88,7 @@ public static function getMap(string $key, array $default = null): array
);
}

public static function getList(string $key, array $default = null): array
public static function getList(string $key, ?array $default = null): array
{
return ListParser::parse(
CompositeResolver::instance()->resolve(
Expand All @@ -98,7 +98,7 @@ public static function getList(string $key, array $default = null): array
);
}

public static function getEnum(string $key, string $default = null): string
public static function getEnum(string $key, ?string $default = null): string
{
return (string) self::validateVariableValue(
CompositeResolver::instance()->resolve(
Expand All @@ -108,7 +108,7 @@ public static function getEnum(string $key, string $default = null): string
);
}

public static function getFloat(string $key, float $default = null): float
public static function getFloat(string $key, ?float $default = null): float
{
return (float) self::validateVariableValue(
CompositeResolver::instance()->resolve(
Expand All @@ -119,7 +119,7 @@ public static function getFloat(string $key, float $default = null): float
);
}

public static function getRatio(string $key, float $default = null): float
public static function getRatio(string $key, ?float $default = null): float
{
return RatioParser::parse(
self::validateVariableValue(
Expand Down
Loading