Skip to content

Commit

Permalink
Change Context::storage() return type to ContextStorageInterface
Browse files Browse the repository at this point in the history
`ExecutionContextAwareInterface` should not be relevant for end-users / it was mainly exposed for the FFI fiber handler; calling any of its method with enabled fiber handler would have broken the storage.
Swoole context storage README creates a new storage instead of wrapping `Context::storage()`: `Context::setStorage(new SwooleContextStorage(new ContextStorage()));`.
  • Loading branch information
Nevay committed Apr 5, 2024
1 parent dd03281 commit b54e078
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 35 deletions.
6 changes: 3 additions & 3 deletions src/Context/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class Context implements ContextInterface
{
private const OTEL_PHP_DEBUG_SCOPES_DISABLED = 'OTEL_PHP_DEBUG_SCOPES_DISABLED';

private static ContextStorageInterface&ExecutionContextAwareInterface $storage;
private static ContextStorageInterface $storage;

// Optimization for spans to avoid copying the context array.
private static ContextKeyInterface $spanContextKey;
Expand All @@ -36,12 +36,12 @@ public static function createKey(string $key): ContextKeyInterface
return new ContextKey($key);
}

public static function setStorage(ContextStorageInterface&ExecutionContextAwareInterface $storage): void
public static function setStorage(ContextStorageInterface $storage): void
{
self::$storage = $storage;
}

public static function storage(): ContextStorageInterface&ExecutionContextAwareInterface
public static function storage(): ContextStorageInterface
{
/** @psalm-suppress RedundantPropertyInitializationCheck */
return self::$storage ??= new FiberBoundContextStorage();
Expand Down
29 changes: 0 additions & 29 deletions src/Context/ExecutionContextAwareNotSupported.php

This file was deleted.

4 changes: 1 addition & 3 deletions src/Context/FiberBoundContextStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
/**
* @internal
*/
final class FiberBoundContextStorage implements ContextStorageInterface, ContextStorageHeadAware, ExecutionContextAwareInterface
final class FiberBoundContextStorage implements ContextStorageInterface, ContextStorageHeadAware
{
use ExecutionContextAwareNotSupported;

/** @var WeakMap<object, ContextStorageHead> */
private WeakMap $heads;

Expand Down

0 comments on commit b54e078

Please sign in to comment.