function Context::with
Overrides ContextInterface::with
File
-
vendor/
open-telemetry/ context/ Context.php, line 97
Class
Namespace
OpenTelemetry\ContextCode
public function with(ContextKeyInterface $key, $value) : self {
if ($this->get($key) === $value) {
return $this;
}
$self = clone $this;
if ($key === self::$spanContextKey) {
$self->span = $value;
// @phan-suppress-current-line PhanTypeMismatchPropertyReal
return $self;
}
$id = spl_object_id($key);
if ($value !== null) {
$self->context[$id] = $value;
$self->contextKeys[$id] ??= $key;
}
else {
unset($self->context[$id], $self->contextKeys[$id]);
}
return $self;
}