19declare(strict_types=1);
43 $context->getUniqueContextIdentifier() ===
'external'
50 $this->
claim($this->repo->external(),
true);
57 $this->call_locations = [];
65 if (!$silent && in_array(
$context, $this->stack)) {
66 throw new LogicException(
"A context can only be claimed once");
73 $called_classes = array_filter(
74 debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),
75 function ($item):
bool {
76 if (!isset($item[
'class'])) {
80 return (!in_array($item[
'class'], [CalledContexts::class, ContextCollection::class]));
85 function (& $item):
void {
86 $item = ($item[
'class'] ??
'') .
":" . ($item[
'line'] ??
'');
90 $call_location = reset($called_classes);
92 if (!$silent && isset($this->call_locations[
$context->getUniqueContextIdentifier()])) {
93 $first_location = $this->call_locations[
$context->getUniqueContextIdentifier()];
94 throw new LogicException(
"context '{$context->getUniqueContextIdentifier()}' already claimed in $first_location, second try in $call_location");
96 $this->call_locations[
$context->getUniqueContextIdentifier()] = $call_location;
claim(ScreenContext $context, bool $silent=false)
push(ScreenContext $context)
checkCallLocation(ScreenContext $context, bool $silent=false)