Skip to content

ScopeToken

Handle to an active LogContext scope frame.

Closing it (explicitly or on destruction) pops exactly that frame. Idempotent. Usage: $scope = LogContext::push([‘userId’ => 7]); try { … } finally { $scope->close(); } or simply let $scope go out of scope.

final class ScopeToken

SourceLogging/ScopeToken.php

public function __construct(int $id): mixed

ParameterTypeDescription
$idint

Returns mixed

MethodDescription
__destruct(): mixed
close(): voidPops the scope frame this token represents.

public function __destruct(): mixed

Returns mixed

public function close(): void

Pops the scope frame this token represents.

Idempotent: a second call does nothing, so closing explicitly and then letting the token be destroyed pops the frame only once.