@param UriInterface         $referenceUri
@param Value\ReferenceValue $reference

@return Value\ValueInterface
@throws Exception\UndefinedReferenceException
971520
protected function resolveExternal(
        UriInterface $referenceUri,
        Value\ReferenceValue $reference
    ) {
        try {
            $value = $this->reader()->read(
                $this->uriFactory()->create(
                    $referenceUri->toString()
                ),
                $reference->mimeType()
            );
        } catch (ReadException $e) {
            throw new Exception\UndefinedReferenceException(
                $reference,
                $this->currentBaseUri(),
                $e
            );
        }

        $this->pushScopeMap(
            $this->scopeMapFactory()->create($referenceUri, $value)
        );
        $value = $value->accept($this);
        $this->popScopeMap();

        $referencePointer = $this->pointerFactory()->createFromUri(
            $referenceUri
        );
        if ($referencePointer->hasAtoms()) {
            $value = $this->pointerResolver()->resolve(
                $referencePointer,
                $value
            );

            if (null === $value) {
                throw new Exception\UndefinedReferenceException(
                    $reference,
                    $this->currentBaseUri()
                );
            }
        }

        return $value;
    }
416381
private function renderReference($value, $reference, &$isRendered)
    {
        if ((true === $isRendered) || !isset($reference[$value])) {
            return $value;
        }

        $isRendered = true;

        if (\is_array($reference[$value])) {
            return $reference[$value][0];
        }

        return $reference[$value];
    }
397960
public static function isRelativePathReference(UriInterface $uri)
    {
        return $uri->getScheme() === ''
            && $uri->getAuthority() === ''
            && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/');
    }
869418
private static URI asRefBase( JsonString uri)
    {
    try
      {
      return
        uri == null
        ? null
        : new URI( uri.getChars().toString());
      }
    catch( Exception e)
      {
      throw new ProjectException( String.format( "Error defining reference base=%s", uri), e);
      }
    }
40837
public function usingReference($reference, $description)
    {
        $this->reference   = $reference;
        $this->description = $description;

        return $this;
    }
583848
public function setReferenceId($referenceId)
    {
        $this->referenceId = $referenceId;
        $this->email = null;
        $this->executed = false;
        return $this;
    }
966578
public function resolveReferences(ReferenceContext $context = null)
    {
        foreach ($this->_paths as $key => $path) {
            if ($path === null) {
                continue;
            }
            $path->resolveReferences($context);
        }
    }
853577
public function removeReferenceUri(string $fqn, string $uri)
    {
        if (!isset($this->references[$fqn])) {
            return;
        }
        $index = array_search($fqn, $this->references[$fqn], true);
        if ($index === false) {
            return;
        }
        array_splice($this->references[$fqn], $index, 1);
    }
935094
public function getReferrer(): ?UrlInterface
    {
        $referrerHeader = $this->getHeader('Referer');
        if ($referrerHeader === null) {
            return null;
        }

        return Url::tryParse($referrerHeader);
    }
795584
public function setReferenceContext(ReferenceContext $context)
    {
        foreach ($this->_properties as $property => $value) {
            if ($value instanceof Reference) {
                $value->setContext($context);
            } elseif ($value instanceof SpecObjectInterface) {
                $value->setReferenceContext($context);
            } elseif (is_array($value)) {
                foreach ($value as $k => $item) {
                    if ($item instanceof Reference) {
                        $item->setContext($context);
                    } elseif ($item instanceof SpecObjectInterface) {
                        $item->setReferenceContext($context);
                    }
                }
            }
        }
    }
1017389
public function withUri(UriInterface $uri, $preserveHost = false)
    {
        $request = $this->copy();
        $request->uri = $uri;
        
        if (!$preserveHost) {
            $request = $request->withHeader('Host', $request->uri->getHost());
        }
        
        return $request;
    }
813253
public function setReferenceContext(ReferenceContext $context)
    {
        if ($this->_pathItem !== null) {
            $this->_pathItem->setReferenceContext($context);
        }
    }
1129126
public function parse($value, $providers = [], $references = [])
    {
        $referenceName = substr($value, 1);

        if (isset($references[$referenceName])) {
            return $references[$referenceName];
        }

        return $value;
    }
562512
private function getServiceCall($id, Reference $reference = null)
    {
        while ($this->container->hasAlias($id)) {
            $id = (string) $this->container->getAlias($id);
        }
        $id = $this->container->normalizeId($id);

        if ('service_container' === $id) {
            return '$this';
        }

        if ($this->container->hasDefinition($id) && ($definition = $this->container->getDefinition($id)) && !$definition->isSynthetic()) {
            if (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) {
                $code = 'null';
                if (!$definition->isShared()) {
                    return $code;
                }
            } elseif ($this->isTrivialInstance($definition)) {
                $code = substr($this->addNewInstance($definition, '', '', $id), 8, -2);
                if ($definition->isShared()) {
                    $code = sprintf('$this->services[\'%s\'] = %s', $id, $code);
                }
            } elseif ($this->asFiles && $definition->isShared() && !$this->isHotPath($definition)) {
                $code = sprintf("\$this->load('%s.php')", $this->generateMethodName($id));
            } else {
                $code = sprintf('$this->%s()', $this->generateMethodName($id));
            }
        } elseif (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) {
            return 'null';
        } elseif (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
            $code = sprintf('$this->get(\'%s\', /* ContainerInterface::NULL_ON_INVALID_REFERENCE */ %d)', $id, ContainerInterface::NULL_ON_INVALID_REFERENCE);
        } else {
            $code = sprintf('$this->get(\'%s\')', $id);
        }

        // The following is PHP 5.5 syntax for what could be written as "(\$this->services['$id'] ?? $code)" on PHP>=7.0

        return "\${(\$_ = isset(\$this->services['$id']) ? \$this->services['$id'] : $code) && false ?: '_'}";
    }
783545
public function findByReference(Reference $reference)
    {
        try {
            $object = $this->getCachedDataByReference($reference);
        } catch (CacheMissException $e) {
            if ($object = $this->rm->getRepositoryForClassName($reference->getClassName())->findById($reference->getId())) {
                $object = clone $object;
                $this->setCachedData($reference->getClassName(), $reference->getId(), $object);
                $this->mm->getMetadataForObject($object)->prepareToLoad($this, $object);
            }
        }

        return $object;
    }
1153039
public function setUseURI(string $use_uri = "N") : CNabuDataObject
    {
        if ($use_uri === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$use_uri")
            );
        }
        $this->setValue('nb_site_map_use_uri', $use_uri);
        
        return $this;
    }
1307811
public function copyBefore(NodeInterface $referenceNode, $nodeName): NodeInterface
    {
        if ($referenceNode->getParent()->getNode($nodeName) !== null) {
            throw new NodeExistsException(sprintf('Node with path "%s/%s" already exists.', $referenceNode->getParent()->getPath(), $nodeName), 1292503465);
        }

        if (!$referenceNode->getParent()->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
            throw new NodeConstraintException(sprintf('Cannot copy %s before %s', $this, $referenceNode), 1402050232);
        }

        $this->emitBeforeNodeCopy($this, $referenceNode->getParent());
        $copiedNode = $this->createRecursiveCopy($referenceNode->getParent(), $nodeName, $this->getNodeType()->isAggregate());
        $copiedNode->moveBefore($referenceNode);

        $this->context->getFirstLevelNodeCache()->flush();
        $this->emitNodeAdded($copiedNode);
        $this->emitAfterNodeCopy($copiedNode, $referenceNode->getParent());

        return $copiedNode;
    }