19declare(strict_types=1);
47 $context->getUniqueContextIdentifier() ===
'external'
53 $this->
claim($this->repo->external(),
true);
60 $this->call_locations = [];
68 if (!$silent && in_array(
$context, $this->stack)) {
69 throw new LogicException(
"A context can only be claimed once");
80 $called_classes = array_filter(
81 debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),
82 function ($item) :
bool {
83 if (!isset($item[
'class'])) {
87 return (!in_array($item[
'class'], [CalledContexts::class, ContextCollection::class]));
92 function (&$item) :
void {
93 $item = ($item[
'class'] ??
'') .
":" . ($item[
'line'] ??
'');
97 $call_location = reset($called_classes);
99 if (!$silent && isset($this->call_locations[
$context->getUniqueContextIdentifier()])) {
100 $first_location = $this->call_locations[
$context->getUniqueContextIdentifier()];
101 throw new LogicException(
"context '{$context->getUniqueContextIdentifier()}' already claimed in $first_location, second try in $call_location");
103 $this->call_locations[
$context->getUniqueContextIdentifier()] = $call_location;
An exception for terminatinating execution or to throw for unit testing.
claim(ScreenContext $context, bool $silent=false)
push(ScreenContext $context)
checkCallLocation(ScreenContext $context, bool $silent=false)