NaifyView\Engine\RuntimeSession クラス
RuntimeSession — render 中に共有する request-local state
template recursion、trusted root、観測用 metadata など、1 render の間だけ必要な状態を保持する。 global state へ逃がさず、compiled runtime と executor の間で明示的に渡す。
使用例
$session = RuntimeSession::forTemplate($templatePath);
$session->setMeta('naify.mode', 'compiled');
プロパティ
| 名前 | 型 | 説明 |
|---|---|---|
private
static
$activeSessions
|
array |
render 中だけ積む active session stack |
private
$currentScope
|
array |
|
private
$trustedRootBindings
|
array |
render 開始時に確定した trusted root binding |
private
$trustPublicScope
|
bool |
A PHP-registered IR provider may opt its artifact into public binding trust. |
private
$parentScopes
|
array |
Parent bindings stay live by reference; stack membership is session-local. |
private
$visibleCurrentScopeCache
|
?array |
current scope から抽出した visible public scope cache |
private
$visibleCurrentScopeBindingCountCache
|
?int |
|
private
$naifySpecialScopePayloadCache
|
array |
|
private
$naifyTemplateMetadataCache
|
?array |
|
private
$naifyCacheMetadataCache
|
?array |
|
private
$observationState
|
stdClass |
render 派生 session 間で共有する軽量観測 state |
private
$requestMemo
|
stdClass |
Immutable artifacts may be shared by scopes within one render, never across renders. |
private
$publicContext
|
array |
|
private
$originalTrustedRoots
|
array |
|
private
$renderTrustedRoots
|
array |
|
private
$internalState
|
array |
|
private
$renderStartedAt
|
int |
メソッド
| メソッド | 説明 |
|---|---|
public
static
clearProcessCaches(): void
|
|
public
__construct(array $publicContext, array $originalTrustedRoots, array $renderTrustedRoots, ?array $currentScope, array $internalState = '...', int $renderStartedAt = 0, ?stdClass $observationState, ?array $trustedRootBindings): void
|
インスタンスを初期化する |
public
static
fromPublicContext(array $publicContext, array $trustedRoots = '...'): RuntimeSession
|
`fromPublicContext()` を実行する |
public
deriveForScope(array $scope): RuntimeSession
|
`deriveForScope()` を実行する |
public
pushParentScope(array $parent, bool $allowWrite): int
|
Enter a child scope; the token must be released in a finally block. |
public
popParentScope(int $token): void
|
Leave exactly the most recently entered scope, including on control-flow signals. |
public
readParentScope(int $depth, ?string $binding): array
|
Read one public binding for a path, or snapshot the whole public scope when requested. |
public
writeParentBinding(int $depth, string $name, mixed $value, bool $append = false): void
|
Explicit ancestor assignment cannot cross any intervening isolation boundary. |
private
parentScopeIndex(int $depth): int
|
|
public
activate(): void
|
`activate()` を実行する |
public
deactivate(): void
|
`deactivate()` を実行する |
public
static
getActiveSession(): ?RuntimeSession
|
`getActiveSession()` の値を返す |
public
getPublicContext(): array
|
`getPublicContext()` の値を返す |
public
replacePublicContext(array $publicContext): void
|
`replacePublicContext()` を実行する |
public
getCurrentScope(): array
|
`getCurrentScope()` の値を返す |
public
replaceCurrentScope(array $currentScope): void
|
`replaceCurrentScope()` を実行する |
public
getInternalState(): array
|
`getInternalState()` の値を返す |
public
getInternalValue(string $key, mixed $default): mixed
|
`getInternalValue()` の値を返す |
public
setInternalValue(string $key, mixed $value): void
|
`setInternalValue()` の値を設定する |
public
getRequestId(): string
|
`getRequestId()` の値を返す |
public
setNaifyMode(string $mode): void
|
`setNaifyMode()` の値を設定する |
public
getNaifyMode(string $fallbackMode): string
|
`getNaifyMode()` の値を返す |
public
setNaifyTemplateMetadata(array $templateMetadata): void
|
`setNaifyTemplateMetadata()` の値を設定する |
public
getNaifyTemplateMetadata(string $fallbackTemplatePath): array
|
`getNaifyTemplateMetadata()` の値を返す |
public
setNaifyCacheMetadata(array $cacheMetadata): void
|
`setNaifyCacheMetadata()` の値を設定する |
public
getVisibleCurrentScope(): array
|
`getVisibleCurrentScope()` の値を返す |
public
getVisibleCurrentScopeBindingCount(): int
|
`getVisibleCurrentScopeBindingCount()` の値を返す |
public
buildCurrentNaifySpecialScopePayload(string $fallbackTemplatePath, string $fallbackMode, bool $usesInternalBag = true): array
|
`buildCurrentNaifySpecialScopePayload()` を実行する |
public
getNaifyCacheMetadata(): array
|
`getNaifyCacheMetadata()` の値を返す |
public
recordCompiledEvaluateFallback(string $expression): void
|
compiled fast path が runtime evaluator に fallback した式を記録する |
public
getCompiledEvaluateFallbackStats(): array
|
compiled evaluator fallback の観測結果を返す |
public
buildNaifySpecialScopePayload(int $publicBindingCount, string $fallbackTemplatePath, string $fallbackMode, bool $usesInternalBag = true): array
|
`buildNaifySpecialScopePayload()` を実行する |
public
getRenderStartedAt(): int
|
`getRenderStartedAt()` の値を返す |
public
getOriginalTrustedRoots(): array
|
`getOriginalTrustedRoots()` の値を返す |
public
getRenderTrustedRoots(): array
|
`getRenderTrustedRoots()` の値を返す |
public
getTrustedRootsForScope(array $scope): array
|
指定 scope で元の binding が保たれている trusted root 名だけを返す |
public
setTrustPublicScope(bool $enabled): void
|
The policy is artifact-local; it is never read from user context. |
public
trustsPublicScope(): bool
|
|
public
isTrustedRootAvailable(string $name, array $scope): bool
|
Test one binding without rebuilding a list for every compiled variable read. |
public
hasTrustedRootsOverride(): bool
|
`hasTrustedRootsOverride()` かを返す |
private
static
normalizeTemplatePath(string $templatePath): string
|
`normalizeTemplatePath()` を実行する |
private
static
createObservationState(): stdClass
|
`createObservationState()` を実行する |
private
static
captureTrustedRootBindings(array $scope, array $trustedRoots): array
|
render 開始時の trusted root 値を provenance として保存する |
private
static
normalizeObservationExpression(string $expression): string
|
`normalizeObservationExpression()` を実行する |
private
static
isVisiblePublicBindingKey(mixed $key): bool
|
`isVisiblePublicBindingKey()` かを返す |
private
invalidateNaifySpecialScopeCaches(): void
|
`invalidateNaifySpecialScopeCaches()` を実行する |
private
static
generateRequestId(): string
|
`generateRequestId()` を実行する |