Skip to content

SlotExecutionGuard

SlotExecutionGuard centralizes recursion limit enforcement for slot dispatches.

final readonly class SlotExecutionGuard

SourceExecution/SlotExecutionGuard.php

public function __construct(int $limit): mixed

ParameterTypeDescription
$limitint

Returns mixed

MethodDescription
enter(SlotStack $stack, string $key): voidPush the key and throw if over the hard limit.
leave(SlotStack $stack): voidRemove the last pushed key.
wouldExceed(SlotStack $stack, string $key): boolNon-throwing check: would pushing this key exceed the configured limit?

public function enter(SlotStack $stack, string $key): void

Push the key and throw if over the hard limit.

ParameterTypeDescription
$stackSlotStack
$keystring

public function leave(SlotStack $stack): void

Remove the last pushed key.

ParameterTypeDescription
$stackSlotStack

public function wouldExceed(SlotStack $stack, string $key): bool

Non-throwing check: would pushing this key exceed the configured limit?

Useful to allow callers to fail soft (return empty) instead of throwing.

ParameterTypeDescription
$stackSlotStack
$keystring

Returns bool