Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Context.php

function Context::with

Overrides ContextInterface::with

File

vendor/open-telemetry/context/Context.php, line 97

Class

Context

Namespace

OpenTelemetry\Context

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal