31 $this->
claim($context);
36 $this->call_locations = [];
47 if (in_array(
$context, $this->stack)) {
48 throw new LogicException(
"A context can only be claimed once");
62 $called_classes = array_filter(
63 debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),
65 if (!isset($item[
'class'])) {
69 return (!in_array($item[
'class'], [CalledContexts::class, ContextCollection::class]));
75 $item = $item[
'class'] .
":" . $item[
'line'];
79 $call_location = reset($called_classes);
81 if (isset($this->call_locations[
$context->getUniqueContextIdentifier()])) {
82 $first_location = $this->call_locations[
$context->getUniqueContextIdentifier()];
83 throw new LogicException(
"context '{$context->getUniqueContextIdentifier()}' already claimed in $first_location, second try in $call_location");
85 $this->call_locations[
$context->getUniqueContextIdentifier()] = $call_location;
An exception for terminatinating execution or to throw for unit testing.
checkCallLocation(ScreenContext $context)
claim(ScreenContext $context)
push(ScreenContext $context)