Document : Definition+

@return DocumentNode
@throws SyntaxErrorException
@throws \ReflectionException
344619
protected function lexDocument(): DocumentNode
    {
        $start = $this->lexer->getToken();

        $this->expect(TokenKindEnum::SOF);

        $definitions = [];

        do {
            $definitions[] = $this->lexDefinition();
        } while (!$this->skip(TokenKindEnum::EOF));

        return new DocumentNode($definitions, $this->createLocation($start));
    }
1012741
public function getDocumentation()
    {
        $documentation = null;
        $documentationNodes = $this->element->getElementsByTagName('documentation');
        if ($documentationNodes->length > 0) {
            $documentation = $documentationNodes->item(0)->nodeValue;
        }
        return $documentation;
    }
269082
protected function buildAST(): DocumentAST
    {
        $schemaString = $this->schemaSourceProvider->getSchemaString();

        // Allow to register listeners that add in additional schema definitions.
        // This can be used by plugins to hook into the schema building process
        // while still allowing the user to add in their schema as usual.
        $additionalSchemas = (array) $this->eventDispatcher->dispatch(
            new BuildSchemaString($schemaString)
        );

        $documentAST = $this->astBuilder->build(
            implode(
                PHP_EOL,
                Arr::prepend($additionalSchemas, $schemaString)
            )
        );

        // Listeners may manipulate the DocumentAST that is passed by reference
        // into the ManipulateAST event. This can be useful for extensions
        // that want to programmatically change the schema.
        $this->eventDispatcher->dispatch(
            new ManipulateAST($documentAST)
        );

        return $documentAST;
    }
717217
public function evaluate()
    {
        $baseNode = null;
        $baseNodeName = $this->getBaseNodeName() ?: 'documentNode';
        $currentContext = $this->runtime->getCurrentContext();
        if (isset($currentContext[$baseNodeName])) {
            $baseNode = $currentContext[$baseNodeName];
        } else {
            throw new NeosException(sprintf('Could not find a node instance in Fusion context with name "%s" and no node instance was given to the node argument. Set a node instance in the Fusion context or pass a node object to resolve the URI.', $baseNodeName), 1373100400);
        }

        try {
            return $this->linkingService->createNodeUri(
                $this->runtime->getControllerContext(),
                $this->getNode(),
                $baseNode,
                $this->getFormat(),
                $this->isAbsolute(),
                $this->getAdditionalParams(),
                $this->getSection(),
                $this->getAddQueryString(),
                $this->getArgumentsToBeExcludedFromQueryString()
            );
        } catch (NeosException $exception) {
            // TODO: Revisit if we actually need to store a stack trace.
            $logMessage = $this->throwableStorage->logThrowable($exception);
            $this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
            return '';
        }
    }
817297
public function toUnsignedXML() : DOMElement
    {
        $this->document = DOMDocumentFactory::create();

        $root = $this->document->createElementNS(Constants::NS_SAMLP, 'samlp:'.$this->tagName);
        $this->document->appendChild($root);

        /* Ugly hack to add another namespace declaration to the root element. */
        $root->setAttributeNS(Constants::NS_SAML, 'saml:tmp', 'tmp');
        $root->removeAttributeNS(Constants::NS_SAML, 'tmp');

        $root->setAttribute('ID', $this->id);
        $root->setAttribute('Version', '2.0');
        $root->setAttribute('IssueInstant', gmdate('Y-m-d\TH:i:s\Z', $this->issueInstant));

        if ($this->destination !== null) {
            $root->setAttribute('Destination', $this->destination);
        }
        if ($this->consent !== Constants::CONSENT_UNSPECIFIED) {
            $root->setAttribute('Consent', $this->consent);
        }

        if ($this->issuer !== null) {
            $this->issuer->toXML($root);
        }

        Extensions::addList($root, $this->extensions);

        return $root;
    }
620319
protected function lexInterfaceTypeDefinition(): InterfaceTypeDefinitionNode
    {
        $start = $this->lexer->getToken();

        $description = $this->lexDescription();

        $this->expectKeyword(KeywordEnum::INTERFACE);

        return new InterfaceTypeDefinitionNode(
            $description,
            $this->lexName(),
            $this->lexDirectives(),
            $this->lexFieldsDefinition(),
            $this->createLocation($start)
        );
    }
806525
protected function appendDescriptionNode()
    {
        if ($this->template) {
            $descriptionTag = $this->getTemplateRegistrationDescriptionTag();
        } else {
            $descriptionTag = $this->getRegistrationDescriptionTag();
        }

        $descriptionElement = $this->dom->createElement($descriptionTag);
        $descriptionElement->setAttribute('xmlns:i', 'http://www.w3.org/2001/XMLSchema-instance');
        $descriptionElement->setAttribute('xmlns', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');

        return $this->content->appendChild($descriptionElement);
    }
104028
protected function lexObjectTypeDefinition(): ObjectTypeDefinitionNode
    {
        $start = $this->lexer->getToken();

        $description = $this->lexDescription();

        $this->expectKeyword(KeywordEnum::TYPE);

        return new ObjectTypeDefinitionNode(
            $description,
            $this->lexName(),
            $this->lexImplementsInterfaces(),
            $this->lexDirectives(),
            $this->lexFieldsDefinition(),
            $this->createLocation($start)
        );
    }
1115418
public function generate($document)
    {
        $lexer = new Lexer();
        $tokenStream = $lexer->tokenize($document);
        $tokenParser = new TokenParser();
        $nodeStream = $tokenParser->parse($tokenStream);
        $nodeParser = new NodeParser();
        $this->classBuilder = $nodeParser->parse($nodeStream);
        $compiler = new Compiler($this->options);
        $this->streamWriter = $compiler->compile($this->classBuilder);

        return $this;
    }
1193722
public function conditionalExpression()
    {
        $conditionalTerms = array();
        $conditionalTerms[] = $this->conditionalTerm();

        while ($this->lexer->isNextToken(Lexer::T_OR)) {
            $this->match(Lexer::T_OR);

            $conditionalTerms[] = $this->conditionalTerm();
        }

        // Phase 1 AST optimization: Prevent AST\ConditionalExpression
        // if only one AST\ConditionalTerm is defined
        if (count($conditionalTerms) == 1) {
            return $conditionalTerms[0];
        }

        return new ConditionalExpressionNode($conditionalTerms);
    }
637644
public function getDocument()
    {
        $doc = new Document();
        $doc->setData($this->getSource());
        $hit = $this->getHit();
        unset($hit['_source']);
        unset($hit['_explanation']);
        unset($hit['highlight']);
        unset($hit['_score']);
        $doc->setParams($hit);

        return $doc;
    }
291129
private function useDeclaration() {
    $declaration = new UseDeclarationNode();
    $node = new NameNode();
    $this->tryMatch(T_NS_SEPARATOR, $node);
    $this->mustMatch(T_STRING, $node, NULL, TRUE)->getText();
    while ($this->tryMatch(T_NS_SEPARATOR, $node)) {
      $this->mustMatch(T_STRING, $node, NULL, TRUE)->getText();
    }
    $declaration->addChild($node, 'name');
    if ($this->tryMatch(T_AS, $declaration)) {
      $this->mustMatch(T_STRING, $declaration, 'alias', TRUE)->getText();
    }
    return $declaration;
  }
306502
private function functionDeclaration() {
    $node = new FunctionDeclarationNode();
    $this->matchDocComment($node);
    $this->mustMatch(T_FUNCTION, $node);
    $this->tryMatch('&', $node, 'reference');
    $name_node = new NameNode();
    $this->mustMatch(T_STRING, $name_node, NULL, TRUE);
    $node->addChild($name_node, 'name');
    $this->parameterList($node);
    $this->matchHidden($node);
    $this->body($node);
    return $node;
  }
1320924
public function setDocument(Document $document): self
    {
        $this->_data = $document;

        $metadata = $this->_getMetadata($document);

        $this->setMetadata($metadata);

        return $this;
    }
1270128
protected function lexVariableDefinition(): VariableDefinitionNode
    {
        $start = $this->lexer->getToken();

        /**
         * @return TypeNodeInterface
         */
        $parseType = function (): TypeNodeInterface {
            $this->expect(TokenKindEnum::COLON);
            return $this->lexType();
        };

        return new VariableDefinitionNode(
            $this->lexVariable(),
            $parseType(),
            $this->skip(TokenKindEnum::EQUALS)
                ? $this->lexValue(true)
                : null,
            $this->createLocation($start)
        );
    }
90355
public function sign()
	{
		// the document must be set up
		if (is_null($this->doc))
		{
			return new \UnexpectedValueException('No document structure to sign');
		}
		
		// find the SignedInfo element, which is what we will actually sign
		$signedInfo = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignedInfo')->item(0);		
		if (is_null($signedInfo))
		{
			throw new \UnexpectedValueException('Unabled to locate the SignedInfo node');
		}
		
		// canonicalize the SignedInfo element for signing
		$c14nSignedInfo = $this->canonicalize($signedInfo);

		// make sure that we know which OpenSSL algo type to use
		if (!array_key_exists($this->digestMethod, $this->openSSLAlgoMapping))
		{
			throw new \UnexpectedValueException('No OpenSSL algorithm has been defined for digest of type ' . $this->digestMethod);
		}
		
		// sign the SignedInfo element using the private key
		if (!openssl_sign($c14nSignedInfo, $signature, $this->privateKey, $this->openSSLAlgoMapping[$this->digestMethod]))
		{
			throw new \UnexpectedValueException('Unable to sign the document. Error: ' . openssl_error_string());
		}
		
		$signature = base64_encode($signature);
		
		// find the signature value node, to which we will append the base64 encoded signature
		$signatureNode = $this->doc->getElementsByTagName($this->nodeNsPrefix . 'SignatureValue')->item(0);		
		if (is_null($signatureNode))
		{
			throw new \UnexpectedValueException('Unabled to locate the SingatureValue node');
		}
		
		$signatureNode->appendChild($this->doc->createTextNode($signature));
		
		return true;
	}
1335961
protected function lexType(): TypeNodeInterface
    {
        $start = $this->lexer->getToken();

        if ($this->skip(TokenKindEnum::BRACKET_L)) {
            $type = $this->lexType();

            $this->expect(TokenKindEnum::BRACKET_R);

            $type = new ListTypeNode($type, $this->createLocation($start));
        } else {
            $type = $this->lexNamedType();
        }

        if ($this->skip(TokenKindEnum::BANG)) {
            return new NonNullTypeNode($type, $this->createLocation($start));
        }

        return $type;
    }