fix implicit null usage (#1362)

php8.4 deprecates implicit null (now checked by phan)
This commit is contained in:
Brett McBride 2024-08-21 10:29:20 +10:00 committed by GitHub
parent 80e97da6eb
commit 69825d395a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 27 additions and 29 deletions

View File

@ -20,7 +20,7 @@ final class BaggageBuilder implements BaggageBuilderInterface
}
/** @inheritDoc */
public function set(string $key, $value, MetadataInterface $metadata = null): BaggageBuilderInterface
public function set(string $key, $value, ?MetadataInterface $metadata = null): BaggageBuilderInterface
{
$metadata ??= Metadata::getEmpty();

View File

@ -11,7 +11,7 @@ interface BaggageBuilderInterface
/**
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/baggage/api.md#set-value
*/
public function set(string $key, mixed $value, API\MetadataInterface $metadata = null): API\BaggageBuilderInterface;
public function set(string $key, mixed $value, ?API\MetadataInterface $metadata = null): API\BaggageBuilderInterface;
/**
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/baggage/api.md#remove-value

View File

@ -16,7 +16,7 @@ interface EventLoggerInterface
mixed $body = null,
?int $timestamp = null,
?ContextInterface $context = null,
Severity $severityNumber = null,
?Severity $severityNumber = null,
iterable $attributes = [],
): void;
}

View File

@ -93,7 +93,7 @@ class LogRecord
/**
* @param int|null $observedTimestamp Time, in nanoseconds since the unix epoch, when the event was observed by the collection system.
*/
public function setObservedTimestamp(int $observedTimestamp = null): self
public function setObservedTimestamp(?int $observedTimestamp = null): self
{
$this->observedTimestamp = $observedTimestamp;

View File

@ -47,7 +47,7 @@ final class NonRecordingSpan extends Span
}
/** @inheritDoc */
public function addEvent(string $name, iterable $attributes = [], int $timestamp = null): SpanInterface
public function addEvent(string $name, iterable $attributes = [], ?int $timestamp = null): SpanInterface
{
return $this;
}
@ -65,13 +65,13 @@ final class NonRecordingSpan extends Span
}
/** @inheritDoc */
public function setStatus(string $code, string $description = null): SpanInterface
public function setStatus(string $code, ?string $description = null): SpanInterface
{
return $this;
}
/** @inheritDoc */
public function end(int $endEpochNanos = null): void
public function end(?int $endEpochNanos = null): void
{
}
}

View File

@ -83,7 +83,7 @@ interface SpanInterface extends ImplicitContextKeyedInterface
/**
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/trace/api.md#add-events
*/
public function addEvent(string $name, iterable $attributes = [], int $timestamp = null): SpanInterface;
public function addEvent(string $name, iterable $attributes = [], ?int $timestamp = null): SpanInterface;
/**
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/trace/api.md#record-exception
@ -102,10 +102,10 @@ interface SpanInterface extends ImplicitContextKeyedInterface
*
* @psalm-param StatusCode::STATUS_* $code
*/
public function setStatus(string $code, string $description = null): SpanInterface;
public function setStatus(string $code, ?string $description = null): SpanInterface;
/**
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/trace/api.md#end
*/
public function end(int $endEpochNanos = null): void;
public function end(?int $endEpochNanos = null): void;
}

View File

@ -32,14 +32,14 @@ final class MultiTextMapPropagator implements TextMapPropagatorInterface
return $this->fields;
}
public function inject(&$carrier, PropagationSetterInterface $setter = null, ContextInterface $context = null): void
public function inject(&$carrier, ?PropagationSetterInterface $setter = null, ?ContextInterface $context = null): void
{
foreach ($this->propagators as $propagator) {
$propagator->inject($carrier, $setter, $context);
}
}
public function extract($carrier, PropagationGetterInterface $getter = null, ContextInterface $context = null): ContextInterface
public function extract($carrier, ?PropagationGetterInterface $getter = null, ?ContextInterface $context = null): ContextInterface
{
$context ??= Context::getCurrent();

View File

@ -25,7 +25,7 @@ class Exporter implements SpanExporterInterface
public function __construct(
private readonly TransportInterface $transport,
SpanConverterInterface $spanConverter = null,
?SpanConverterInterface $spanConverter = null,
) {
$this->setSpanConverter($spanConverter ?? new SpanConverter());
}

View File

@ -33,7 +33,7 @@ class Util
/**
* @psalm-suppress ArgumentTypeCoercion
*/
public static function triggerClassDeprecationNotice(string $className, string $alternativeClassName = null): void
public static function triggerClassDeprecationNotice(string $className, ?string $alternativeClassName = null): void
{
if (self::getErrorLevel() === self::E_NONE) {
return;
@ -56,8 +56,8 @@ class Util
*/
public static function triggerMethodDeprecationNotice(
string $methodName,
string $alternativeMethodName = null,
string $alternativeClassName = null,
?string $alternativeMethodName = null,
?string $alternativeClassName = null,
): void {
if (self::getErrorLevel() === self::E_NONE) {
return;

View File

@ -31,7 +31,7 @@ class EventLogger implements EventLoggerInterface
mixed $body = null,
?int $timestamp = null,
?ContextInterface $context = null,
Severity $severityNumber = null,
?Severity $severityNumber = null,
iterable $attributes = [],
): void {
$logRecord = new LogRecord();

View File

@ -50,12 +50,12 @@ class LoggerProvider implements LoggerProviderInterface
return $logger;
}
public function shutdown(CancellationInterface $cancellation = null): bool
public function shutdown(?CancellationInterface $cancellation = null): bool
{
return $this->loggerSharedState->shutdown($cancellation);
}
public function forceFlush(CancellationInterface $cancellation = null): bool
public function forceFlush(?CancellationInterface $cancellation = null): bool
{
return $this->loggerSharedState->forceFlush($cancellation);
}

View File

@ -23,7 +23,6 @@ use WeakMap;
final class MeterProvider implements MeterProviderInterface
{
private readonly MetricFactoryInterface $metricFactory;
private readonly MeterInstruments $instruments;
private readonly MetricRegistryInterface $registry;
private readonly MetricWriterInterface $writer;
@ -45,10 +44,9 @@ final class MeterProvider implements MeterProviderInterface
private readonly ViewRegistryInterface $viewRegistry,
private readonly ?ExemplarFilterInterface $exemplarFilter,
private readonly StalenessHandlerFactoryInterface $stalenessHandlerFactory,
MetricFactoryInterface $metricFactory = null,
private readonly MetricFactoryInterface $metricFactory = new StreamFactory(),
private ?Configurator $configurator = null,
) {
$this->metricFactory = $metricFactory ?? new StreamFactory();
$this->instruments = new MeterInstruments();
$registry = new MetricRegistry($contextStorage, $attributesFactory, $clock);

View File

@ -100,7 +100,7 @@ final class Span extends API\Span implements ReadWriteSpanInterface
*
* @codeCoverageIgnore
*/
public static function formatStackTrace(Throwable $e, array &$seen = null): string
public static function formatStackTrace(Throwable $e, ?array &$seen = null): string
{
BcUtil::triggerMethodDeprecationNotice(
__METHOD__,
@ -224,7 +224,7 @@ final class Span extends API\Span implements ReadWriteSpanInterface
}
/** @inheritDoc */
public function setStatus(string $code, string $description = null): self
public function setStatus(string $code, ?string $description = null): self
{
if ($this->hasEnded) {
return $this;
@ -245,7 +245,7 @@ final class Span extends API\Span implements ReadWriteSpanInterface
}
/** @inheritDoc */
public function end(int $endEpochNanos = null): void
public function end(?int $endEpochNanos = null): void
{
if ($this->hasEnded) {
return;

View File

@ -27,10 +27,10 @@ final class TracerProvider implements TracerProviderInterface
/** @param list<SpanProcessorInterface>|SpanProcessorInterface|null $spanProcessors */
public function __construct(
SpanProcessorInterface|array|null $spanProcessors = [],
SamplerInterface $sampler = null,
ResourceInfo $resource = null,
SpanLimits $spanLimits = null,
IdGeneratorInterface $idGenerator = null,
?SamplerInterface $sampler = null,
?ResourceInfo $resource = null,
?SpanLimits $spanLimits = null,
?IdGeneratorInterface $idGenerator = null,
?InstrumentationScopeFactoryInterface $instrumentationScopeFactory = null,
private ?Configurator $configurator = null,
) {