Skip to content

Commit

Permalink
[PHP 8.4] Fixes for implicit nullability deprecation (#1297)
Browse files Browse the repository at this point in the history
  • Loading branch information
andypost authored Apr 29, 2024
1 parent fc161a8 commit f2cba82
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
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

0 comments on commit f2cba82

Please sign in to comment.