@param InlineParserContext $context

@return bool
436254
public function parse(InlineParserContext $context): bool
    {
        // The cursor should be positioned on the opening '@'.
        $cursor = $context->getCursor();

        // If this isn't the start of an XREF, we'll need to rewind.
        $previous_state = $cursor->saveState();

        $handle = $cursor->match('/@' . Gedcom::REGEX_XREF . '@/');
        if (empty($handle)) {
            // Not an XREF?
            $cursor->restoreState($previous_state);

            return false;
        }

        $xref = trim($handle, '@');

        $record = GedcomRecord::getInstance($xref, $this->tree);

        if ($record === null) {
            // Linked record does not exist?
            $cursor->restoreState($previous_state);

            return false;
        }

        $url   = $record->url();
        $label = $handle;
        $title = strip_tags($record->fullName());
        $context->getContainer()->appendChild(new Link($url, $label, $title));

        return true;
    }
1030527
public static function parse($text, $context = null)
    {
        if (!static::$_enabled || strpos($text, '{') === false) {
            return $text;
        }

        if ($context === null) {
            $context = static::_getDefaultContext();
        }

        static::cache('context', $context);
        $pattern = static::_regex();

        return preg_replace_callback("/{$pattern}/s", 'static::_doShortcode', $text);
    }
75654
private function nestContext(&$context)
    {
        foreach ($context as $key => $value) {
            $dot = strpos($key, '.');
            if ($dot && $dot !== strlen($key) - 1) {
                $currentContext = &$context;
                foreach (explode('.', $key) as $k) {
                    if (!isset($currentContext[$k])) {
                        $currentContext[$k] = [];
                    }
                    $currentContext = &$currentContext[$k];
                }
                $currentContext = $value;
                unset($context[$key]);
            }
        }

        return $context;
    }
731068
public function getContext( $ref )
	{
		return isset( $this->contexts[ $ref ] )
			? $this->contexts[ $ref ]
			: false;
	}
535614
public function parse(ContextInterface $context, Cursor $cursor): bool
    {
        $container = $context->getContainer();

        // Replace paragraphs with tables
        if (!$container instanceof Paragraph) {
            return false;
        }

        $lines = $container->getStrings();

        $first_line = array_pop($lines);

        if (!preg_match(self::REGEX_CENSUS_TABLE_HEADER, $first_line)) {
            return false;
        }

        $head = $this->parseRow($first_line, TableCell::TYPE_HEAD);

        $table = new Table(function (Cursor $cursor) use (&$table): bool {
            $row = $this->parseRow($cursor->getLine(), TableCell::TYPE_BODY);
            if ($row === null) {
                return false;
            }
            $table->getBody()->appendChild($row);

            return true;
        });

        $table->getHead()->appendChild($head);
        $context->replaceContainerBlock($table);

        return true;
    }
823128
private function configureContext(Context $context)
    {
        foreach ($this->attributes as $key => $value) {
            $context->setAttribute($key, $value);
        }
        if (!empty($this->groups)) {
            $context->setGroups($this->groups);
        }

        if (($context instanceof SerializationContext) && $this->serializeNulls !== null) {
            $context->setSerializeNull($this->serializeNulls);
        }

        if ($this->enableMaxDepthChecks === true) {
            $context->enableMaxDepthChecks();
        }

        if ($this->version !== null) {
            $context->setVersion($this->version);
        }

        return $context;
    }
395563
public function inContext($context)
    {
        $length = count($this->context);

        return $length < 2 ? false : $this->context[$length - 1] === $context;
    }
939730
public function assemble(ContextInterface $context): bool
    {
        $class = $context->getClass();
        $class->setExtendedClass(Client::class);
        $method = $context->getMethod();
        try {
            $phpMethodName = Normalizer::normalizeMethodName($method->getMethodName());
            $param = $this->createParamsFromContext($context);
            $class->removeMethod($phpMethodName);
            $docblock = $context->isMultiArgument() ?
                $this->generateMultiArgumentDocblock($context) :
                $this->generateSingleArgumentDocblock($context);

            $class->addMethodFromGenerator(
                MethodGenerator::fromArray(
                    [
                        'name' => $phpMethodName,
                        'parameters' => [$param],
                        'visibility' => MethodGenerator::VISIBILITY_PUBLIC,
                        'body' => sprintf(
                            'return $this->call(\'%s\', $%s);',
                            $method->getMethodName(),
                            $param->getName()
                        ),
                        'returntype' => $method->getNamespacedReturnType(),
                        'docblock' => $docblock,
                    ]
                )
            );
        } catch (\Exception $e) {
            throw AssemblerException::fromException($e);
        }

        return true;
    }
1035427
public function evaluate($expression, Context $context)
    {
        $expression = trim($expression);
        $parser = new InterpretedEelParser($expression, $context);
        $res = $parser->match_Expression();

        if ($res === false) {
            throw new ParserException(sprintf('Expression "%s" could not be parsed.', $expression), 1344514198);
        } elseif ($parser->pos !== strlen($expression)) {
            throw new ParserException(sprintf('Expression "%s" could not be parsed. Error starting at character %d: "%s".', $expression, $parser->pos, substr($expression, $parser->pos)), 1344514188);
        } elseif (!array_key_exists('val', $res)) {
            throw new ParserException(sprintf('Parser error, no val in result %s ', json_encode($res)), 1344514204);
        }

        if ($res['val'] instanceof Context) {
            return $res['val']->unwrap();
        } else {
            return $res['val'];
        }
    }
1113234
protected function prepareParser()
    {
        return function (InlineParserInterface $stack, AbstractInlineParser $parser) {
            $parser->setNextParser($stack);
            $parser->setContext($this);

            return $parser;
        };
    }
685878
public function validateEntity(ExecutionContextInterface $context)
    {
        if ($this->getType() == self::TYPE_PAGE_LINK && !$this->getNodeTranslation()) {
            $context->buildViolation('Please select a page')
              ->atPath('nodeTranslation')
              ->addViolation();
        } elseif ($this->getType() == self::TYPE_URL_LINK) {
            if (strlen($this->getTitle()) == 0) {
                $context->buildViolation('Please set the link title')
                  ->atPath('title')
                  ->addViolation();
            }
            if (strlen($this->getUrl()) == 0) {
                $context->buildViolation('Please set the link URL')
                  ->atPath('url')
                  ->addViolation();
            }
        }
    }
1329299
protected static function hasScope(ContextInterface $context, string $scope): bool
    {
        $result = false;

        if (static::ctxHasCurrentAccount($context) === true) {
            /** @var PassportAccountInterface $account */
            $account = self::ctxGetCurrentAccount($context);
            $result  = $account->hasScope($scope);
        }

        return $result;
    }
662367
public function is($context, $original = '')
    {
        return (($this->context === $context) && ($this->original === $original)) ? true : false;
    }
142999
protected static function rawblock(&$token, &$context) {
        $inner = $token[Token::POS_INNERTAG];
        trim($inner);

        // skip parse when inside raw block
        if ($context['rawblock'] && !(($token[Token::POS_BEGINRAW] === '{{') && ($token[Token::POS_OP] === '/') && ($context['rawblock'] === $inner))) {
            return true;
        }

        $token[Token::POS_INNERTAG] = $inner;

        // Handle raw block
        if ($token[Token::POS_BEGINRAW] === '{{') {
            if ($token[Token::POS_ENDRAW] !== '}}') {
                $context['error'][] = 'Bad token ' . Token::toString($token) . ' ! Do you mean ' . Token::toString($token, array(Token::POS_ENDRAW => '}}')) . ' ?';
            }
            if ($context['rawblock']) {
                Parser::setDelimiter($context);
                $context['rawblock'] = false;
            } else {
                if ($token[Token::POS_OP]) {
                    $context['error'][] = "Wrong raw block begin with " . Token::toString($token) . ' ! Remove "' . $token[Token::POS_OP] . '" to fix this issue.';
                }
                $context['rawblock'] = $token[Token::POS_INNERTAG];
                Parser::setDelimiter($context);
                $token[Token::POS_OP] = '#';
            }
            $token[Token::POS_ENDRAW] = '}}';
        }
    }
122202
public function canEvaluate($context)
    {
        if (count($context) === 0) {
            return true;
        }

        foreach ($context as $contextNode) {
            if (!$contextNode instanceof NodeInterface) {
                return false;
            }
        }
        return true;
    }
561667
protected function _actionDispatch(AnCommandContext $context)
    {
        if ($this->action === 'confirm' && $this->token) {
            $context->data->append(array(
               '_action' => 'confirm',
               'token' => $this->token,
            ));

            return $this->execute('post', $context);
        }

        return parent::_actionDispatch($context);
    }
1293680
protected function hasNodeParser(string $class): bool
    {
        if (Validator::key($class, Validator::instance(NodeParserInterface::class))
            ->validate($this->nodeParsers)) {
            return true;
        }
        return false;
    }